How to compile linking statically all except one library (G++)

view story

http://stackoverflow.com – Now i compiling my app using this command: g++ -o newserver test.cpp ... -lboost_system -std=c++0x But how can i compile it statically (glibc and others) but boost::system should be linked dynamically. Thanks! upd When i compile like this: g++ -o newserver test.cpp ... -lboost_system -static -std=c++0x I have an errors: /tmp/cc1hTPLw.o: In function `NativesResolveDns(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)': Natives.cpp:(.text+0x1498): warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared (HowTos)