Link static & share library at the same time!

1237阅读 0评论2011-10-20 weilanse
分类:C/C++

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..

上一篇:Install USB2Serial driver
下一篇:What's linux initial RAM disk(initrd)(-)