I think the easiest way for you is to use the linker switch --whole-archive (there are more SO questions on this topic, see how to link a static library to a dynamic library in gcc here ).
The disadvantage of this is that your shared library will export all characters from the static Boost libraries, and you might have strange problems if you use your .so in an application that also uses Boost (but a different version or compiled with different switches) .
So, you need to use the script version to hide what is exported from the library (see How to hide the name of exported characters in the shared library , and also Google for the linker version scripts), leaving only doit() visible. In your case, this version of the script might look like this:
{ global: doit*; local: *; }
You also need to make sure that the static libraries you are linking to are compiled with -fPIC (which is unlikely if you did not configure your build flags), in other words, you will have a performance limitation on i386 and cannot link to amd64 at all.
source share