Shared lib is compiling without any static lib link (even it has 3rd party APIs)
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Shared lib is compiling without any static lib link (even it has 3rd party APIs)
Hi,
I am preparing my custom shared library (.so) file by including APIs of other static library (net-snmp library).
Here my problem:
My custom shared library is compiling with/without library (net-snmp library) linking.
But at the time of execution, failed to load my custom library and giving undefined "syslog_handler" symbol error in both cases. (This symbol is existed in net-snmp static library).
Please help me to find out the reason for compiling without linking any library & to find out the reason for loading problem even though after static library link.
After adding "-Wl,--no-undefined" option at shared library compilation by linking with static lib (net-snmp lib), I am getting "libnetsnmptrapd.a(snmptrapd_handlers.o): relocation R_X86_64_32S against `a local symbol' can not be used when making a shared object; recompile with -fPIC libnetsnmptrapd.a: could not read symbols: Bad value" error message.Even though we built the static libraries (net-snmp lib) on 64bit machine only.
If we did same thing(netsnmp static library link t executeble) for a executable it successfully linked (and running) but failed to link (net-snmp static lib) for shared-library.
> libnetsnmptrapd.a(snmptrapd_handlers.o): relocation R_X86_64_32S against `a local symbol' can not be used when making a shared object; recompile with -fPIC libnetsnmptrapd.a
Very true, shared lib can only be built from relocatable objects (-fPIC flag at compilation)
PS: The is a special program called libtool especially for handling shared (and static) libraries.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.