[freetds] unresolved symbols with freetds-0.63.dev.20040418

Roger Reynolds rogerr at softix.com
Mon Apr 19 22:02:59 EDT 2004

By sheer coincidence, I have been tripping over a very 
similar problem this morning, and haven't yet had a chance
to write it up nice for the group.

The upshot is yes, there are unresolved symbols from the
gcc runtime when you try to link libtdsodc.
However, this does not seem to cause any problems if you
eventually link your application using gcc/g++, as these
symbols will be resolved there.

If you use a different compiler (I use Sun C++) or perhaps
even a different version of gcc (as you seem to be doing) 
to link your application, you get these undefined symbols.

The problem arises because of using ld rather than gcc -G to
build the shared library.  This may be necessary, in order to
get the symbol map right - I don't know.

My solution was to relink the libtdsodbc library, and include
the libgcc.a in there before -lc.

On my system, this looks like this:

/usr/ccs/bin/ld -G -M .libs/libtdsodbc.so.0.0.exp -h libtdsodbc.so.0 -o
.libs/libtdsodbc.so.0.0  .libs/odbc.o .libs/connectparams.o
.libs/convert_tds2sql.o .libs/descriptor.o .libs/prepare_query.o
.libs/odbc_util.o .libs/native.o .libs/sql2tds.o .libs/error.o
.libs/odbc_checks.o -z allextract ../tds/.libs/libtds_objects.a
../replacements/.libs/libreplacements.a -z defaultextract
../tds/.libs/libtds_objects.a -lnsl -lsocket
/usr/local/gcc-2.95.3/lib/gcc-lib/sparc-sun-solaris2.7/2.95.3/libgcc.a  -lc

Hope that helps, and I hope this is sufficient info for somebody 
in the freetds community to work with...

-----Original Message-----
From: Rolf Loudon [mailto:rolf at ses.tas.gov.au]
Sent: Tuesday, April 20, 2004 11:48 AM
To: freetds at lists.ibiblio.org
Subject: [freetds] unresolved symbols with freetds-0.63.dev.20040418


On Solaris (2.6 - yes its old, but its necessary) I have unixODBC version 
2.2.8 installed.

Is this compatible with freetds-0.63.dev.20040418?

If so, read on.

I have had several problems compiling this version of freetds.

Firstly bsqldb in src/apps fails :

bsqldb.c: In function `print_results':
bsqldb.c:438: warning: implicit declaration of function `asprintf'
/bin/ksh ../../libtool --mode=link gcc  -g -O2   -L/usr/local/unixODBC/lib 
-o bsqldb  bsqldb.o ../dblib/libsybdb.la -lnsl -lsocket
gcc -g -O2 -o .libs/bsqldb bsqldb.o  -L/usr/local/unixODBC/lib 
../dblib/.libs/libsybdb.so -lnsl -lsocket -R/usr/local/freetds/lib
Undefined			first referenced
  symbol  			    in file
asprintf                            bsqldb.o
ld: fatal: Symbol referencing errors. No output written to .libs/bsqldb
collect2: ld returned 1 exit status
*** Error code 1
make: Fatal error: Command failed for target `bsqldb'

As I only really want the driver I re-ran configure with --disable-apps 
which got rid of that problem

But then it failed unable to make the documentation, doxygen not found.

No big deal I thought so proceeded with make install to get the library 
into /usr/local/freetds/lib and all the rest.

setting up the driver file and the datasource name from templates all 
worked ok so then I tried the example test:

isql -v servername sa password

and I get

ld.so.1: isql: fatal: relocation error: file 
/usr/local/freetds/lib/libtdsodbc.so: symbol __eprintf: referenced symbol 
not found

looking back through the compile of freetds I found this:

mv -f ".libs/libtdsodbc.expT" ".libs/libtdsodbc.exp"
/usr/ucb/echo "{ global:" > .libs/libtdsodbc.so.0.0.exp
cat .libs/libtdsodbc.exp | sed -e "s/\(.*\)/\1;/" >> 
/usr/ucb/echo "local: *; };" >> .libs/libtdsodbc.so.0.0.exp
  /usr/ccs/bin/ld -G -M .libs/libtdsodbc.so.0.0.exp -h libtdsodbc.so.0 -o 
.libs/libtdsodbc.so.0.0  .libs/odbc.o .libs/connectparams.o 
.libs/convert_tds2sql.o .libs/descriptor.o .libs/prepare_query.o 
.libs/odbc_util.o .libs/native.o .libs/sql2tds.o .libs/error.o 
.libs/odbc_checks.o -z allextract ../tds/.libs/libtds_objects.a 
../replacements/.libs/libreplacements.a -z 
defaultextract  -R/usr/local/unixODBC/lib 
-R/usr/local/unixODBC/lib  -L/usr/local/unixODBC/lib 
../tds/.libs/libtds_objects.a /usr/local/unixODBC/lib/libodbcinst.so -lnsl 
-lsocket ../replacements/.libs/libreplacements.a   -lc  -Bsymbolic
Undefined			first referenced
  symbol  			    in file
__floatdisf                         ../tds/.libs/libtds_objects.a(convert.o)
__floatdidf                         ../tds/.libs/libtds_objects.a(convert.o)
__eprintf                           .libs/odbc.o
ld: warning: Symbol referencing errors

Any help would be gratefully received.



FreeTDS mailing list
FreeTDS at lists.ibiblio.org

More information about the FreeTDS mailing list