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.
I'm trying to create a shared library that my application will be loading at run time to determine its branding specific information. I am linking my application statically so that it is able to be run on different Linux platforms that do not have the same libraries as the one I build on. However, the shared library also needs this capability, but I can not figure out how to remove it's dependencies. Any ideas on how this would work?
Somehow, the shared library needs to use the statically linked application for its unresolved dependencies. I am using the -rdynamic flag when I link the application and I have tried using the -static flag when linking the shared library.
If it helps, my application is being linked with these flags:
g++ -static -rdynamic ...
The shared library is being linked like this, so far:
g++ -fPIC -shared -Wl,-static -lpthread -ldl -Wl,-call_shared ...
Some options I have tried using, but not successfully or perhaps not correctly are:
-nodefaultlibs -nostartfiles -nostdlibs -Wl,-nostdlib
Could you be more spesific with the problem in question (with test-cases would be cool).
Also have you read the Program Library HOWTO. Most issues seems to be handled there.
Actually, I've been doing research and I've found that specifying the -Wl,-static flag before linking any libraries should be the correct thing to do.
However, it appears there is a bug in versions of GCC above 3.1.1 (from what I've read, still exploring that) which causes libstdc++.a to have an undefined versioned symbol name std::time_put_w@@CLIBCPP_3.2 when linked in this manner. That means that it is not possible to create a shared library with supporting libraries statically linked in. Here's an example:
Hmm.. I have not done any indepth research to be certain that that is the right way to do it, but the commands seems to work with gcc-2.95 and gcc-3.0, but not any newer official version. IIRC, there has been some major restructuring in the object format in the gcc3.2.
The problem seems to be fixed in the newest(two days old) gcc (version 3.4 20031116 (experimental)) brought from the gcc-snapshot debian package.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.