Reputation: 749
Dear All, Here is my command to link libraries and generate an exe:
ld -o readgfile readg_x.o MedLib_x.o cdrsort.o mtcprc.o encoder.o mtcbuil.o dbtprc.o dbtbuil.o DFMLIB_x.o Dyn_SQL_x.o /home/med/src/api/libnapi.a /home/med/src/api/libtabs.a $ORACLE_HOME/lib/libclntsh.so
But when I run the command it failed to locate function used in readg_x.o from file archived in libtabs.a. Here are error like :
readg_x.o: In function `main':
/home/med/src/readg/readg_x.c:565: undefined reference to `options'
/home/med/src/readg/readg_x.c:570: undefined reference to `oraconnect'
/home/med/src/readg/readg_x.c:591: undefined reference to `oracommit'
Upvotes: 1
Views: 1879
Reputation: 213375
You have two problems:
ld
. Once you manage to actually link it, the resulting executable will crash at startup, because you are not properly linking in the C startup (crt0.o
). On UNIX/Linux, one should never use ld
to link anything (with the rare exception of linking OS kernel or a bootloader). You should always use compiler driver instead, like this: gcc -o readgfile readg_x.o MedLib_x.o ...
oraconnect
etc. are defined in libtabs.a
, they are not (or at least they are not defined as global symbols). Without output from readelf -s libtabs.a | grep oraconnect
, it is hard to tell exactly what's happening, but your assertion that the symbols are defined in that library is definitely false.Upvotes: 1
Reputation: 328536
The error means the library libtabs.a
doesn't contain what you think. You can use tools like objdump
to list all symbols defined in a library to make sure what you expect is what really is.
Upvotes: 1