分类: C/C++
2011-10-20 22:55:34
One sample :
cc -I$SYBASE/$SYBASE_OCS/include
-L$SYBASE/$SYBASE_OCS/lib program.c
-Wl,-Bstatic -lsybsrv [ -lsybdb|-lsybct ] -lsybcs -lsybtcl -lsybcomn -lsybintl -lsybunic
-Wl,-Bdynamic -ldl -lnsl -lm -o program
Note - if the linker is being invoked indirectly, via a compiler driver (eg gcc) then all the linker command line options should be prefixed by -Wl, (or whatever is appropriate for the particular compiler driver) like this:
gcc -Wl,--startgroup foo.o bar.o -Wl,--endgroup
This is important, because otherwise the compiler driver program may silently drop the linker options, resulting in a bad link.
-Wl,option
Pass option as an option to the linker. If option contains commas, it is split into multiple options at the commas.
Assuming that default setting of ld is to use dynamic libraries (it is on Linux).
Refer to for more info about ld..