Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linking statically only boost library G++ [duplicate]

Possible Duplicate:
Can I mix static and shared-object libraries when linking?

I want to compile my app, linking statically only boost_system library. Other(glibc and etc) should be linked dynamically. How can i do it?

My command to compile dynamically:

g++  -o newserver  server.cpp ... -lboost_system -std=c++0x

Command to compile statically:

g++ -static  -o newserver  server.cpp ... -pthread -lboost_system -std=c++0x

But this command link statically all! And app weights 2mb more!

Can you advice me what command to compile statically only boost lib?

Thanks!

like image 247
Breakdown Avatar asked Jan 30 '13 13:01

Breakdown


1 Answers

Replace -lboost_system with -Wl,-Bstatic -lboost_system -Wl,-Bdynamic. The -Wl option sends the thing after it to the linker, in the order it appears on the command-line.

like image 161
Mats Petersson Avatar answered Nov 14 '22 21:11

Mats Petersson