[freetds] Problem compiling on AIX 220.127.116.11
Lowden, James K
LowdenJK at bernstein.com
Mon Sep 20 16:35:49 EDT 2004
> From: WATTS, RANDY (SBCSI)
> Sent: Monday, September 20, 2004 1:38 PM
> Here is the output of nm on tds/.libs/libtds.so.3 no .0 suffix on this
> machine And this is the complete output for this lib
> f -
> crt0main.s f -
> end B 536871228
> p_xargc B 536871212 4
> p_xargv B 536871216 4
> p_xrc B 536871224 4
> p_xrcfg B 536871220 4
OK, that tells us your linker -- the thing that built this shared library -- isn't exporting *any* FreeTDS functions. That's why you're getting undefined symbol errors.
> Here is what I found in tds/.libs/libtds_objects.a
> nm ./libtds_objects.a | grep tds_alloc_login
> §tds_alloc_login:F167 - 108
> .tds_alloc_login T 3264 288
> tds_alloc_login D 15852 12
> tds_alloc_login d 15676 4
That means '.tds_alloc_login' is in the static library; the 'T' is the clue. The error message said '.tds_alloc_login' (with the leading dot) was undefined, and the static library at any rate has that exact symbol, so you have a chance.
I think I'd reconfigure with --disable-shared, and see if tsql links.
> Forgive my naiveté but where would I add the "-bloadmap or -bnoquiet"
> options so that they get run at the proper place for
> cc -g -o .libs/tsql tsql.o -lcurses -L../tds/.libs -ltds -liconv -Wl,-blibpath:/usr/local/lib:/usr/lib:/lib
I don't know. The suggestion came from ld(1), so they're linker options. Check your cc man page for how to pass linker options on the cc command line. On gcc, for example, it would be "-Xlinker bloadmap". If you want my guess, it'd be:
cc -g -o .libs/tsql tsql.o -lcurses \
-L../tds/.libs -ltds -liconv \
Linker problems are always a royal pain, partly because linkers do a lot of magical stuff. The way out is always the same: you want to read your linker manual very carefully, however tedious and obsure it may be. What you really want is the option to export symbols to shared libraries, but you might settle, say, for the option that tells the linker to prefer static libs to shared ones.
Here's a hack: add "-llibtds.a" to the above command. That will bring in the FreeTDS symbols. tsql should then work.
Chris Eleveld mentions the libtool version. The releases of FreeTDS 0.62.3 and prior were generated with libtool 1.4a. FreeTDS 0.62.4 and current snapshots use a later version, 1.5.2 IIRC. You might want to try an earlier/later release, just to see. Also, I found http://www.nasi.com/pdfs/runninglinuxappsonaix.pdf. Page 82 is interesting.
> Do they need to be added somewhere in libtool and then do a configure or in
> one of the Makefiles?
First just enter the command at the prompt, until you get the right incantation. Then you can edit src/apps/Makefile. Linker flags for tsql can be added thus:
tsql_LDFLAGS = -bloadmap -bnoquiet
approximately. To get ./configure to build the Makefile with the correct linker flags in place, you can set the LDFLAGS environment variable (or similar, according to your linker docs.)
Making all in apps
source='tsql.c' object='tsql.o' libtool=no depfile='.deps/tsql.Po' tmpdepfile='.deps/tsql.TPo' depmode=aix /bi n/sh ../../depcomp cc -DHAVE_CONFIG_H -I. -I. -I../../include
-I../../include -D_FREETDS_LIBRARY_SOURCE -DDEBUG=1 -
g -c `test -f 'tsql.c' || echo './'`tsql.c
/bin/sh ../../libtool --mode=link cc -g -o tsql tsql.o
cc -g -o .libs/tsql tsql.o -lcurses -L../tds/.libs -ltds -liconv -Wl,-blibpath:/usr/local/lib:/usr/lib:/lib
ld: 0711-317 ERROR: Undefined symbol: .tds_alloc_login
ld: 0711-317 ERROR: Undefined symbol: .tds_alloc_context
ld: 0711-317 ERROR: Undefined symbol: .tds_alloc_socket
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
----- END -----
Looks like progress, but there's still some disagreement between the library symbol list and what the compiler wants the linker to import. What does "nm libtds.so.3.0 |grep tds_alloc_login" tell you? Is there a ".tds_alloc_login", or is it perhaps missing that leading dot? Are "-bloadmap or -bnoquiet" of any use?
The information contained in this transmission may contain privileged and confidential information and is intended only for the use of the person(s) named above. If you are not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, any review, dissemination, distribution or duplication of this communication is strictly prohibited. If you are not the intended recipient, please contact the sender immediately by reply e-mail and destroy all copies of the original message. Please note that we do not accept account orders and/or instructions by e-mail, and therefore will not be responsible for carrying out such orders and/or instructions.
If you, as the intended recipient of this message, the purpose of which is to inform and update our clients, prospects and consultants of developments relating to our services and products, would not like to receive further e-mail correspondence from the sender, please "reply" to the sender indicating your wishes. In the U.S.: 1345 Avenue of the Americas, New York, NY 10105.
More information about the FreeTDS