G ++ binds static and non-static libraries at the same time

I have a makefile project in which I include several different libraries. One of them is the acceleration library, which I statically link to make my program portable. This is what my makefile command looks like:

g++ -O0 -g test.cpp testObject.o -pthread -I/home/user/devel/lmx-sdk-4.7.1/include/ -L/home/user/devel/lmx-sdk-4.7.1/linux_x64 -llmxclient -lrt -ldl -lboost_filesystem  -lboost_system -static -static-libgcc -o $@

I also linked the lmx-sdk library with my project to use the licensing functionality; however, it seems that lmx-sdk does not look like a static link, because it gives the error "Using" dlopen "in statically linked applications requires the shared libraries from the version of glibc used for linking to run at runtime."

How can I link some libraries statically and others dynamically?

Thanks in advance

PS I checked some similar topics and tried several methods that did not work for me.

+4
source share
2 answers

Using -Wl,-Bdynamicand -Wl,-Bstaticinstead of using -Bdynamicand -Bstaticsolved the problem.

Now the full line of links looks like this:

g++ -O0 -g test.cpp testObject.o -pthread -Bdynamic -I/home/user/devel/lmx-sdk-4.7.1/include/ -L/home/user/devel/lmx-sdk-4.7.1/linux_x64 -llmxclient -lrt -ldl -Wl,-Bstatic -lboost_filesystem -lboost_system -o $@

+4
source

You can use -Bstaticto statically link what comes after it, and then -Bdynamicdo the opposite. How many times do you need on the command line.

+1
source

All Articles