Search code examples
c++boostlinkerbjam

bjam runtime-link=static


I am trying to compile in a way such that the exec links to gcc statically. I presumed running bjam link=static runtime-link=static should do the trick ? When I tried that I get the following errors like :

...failed gcc.link TGT/bin/gcc-4.5.1/debug/link-static/runtime-link-static/datagen...
gcc.compile.c++ TGT/bin/gcc-4.5.1/release/link-static/runtime-link-static/base_data_gen.o
gcc.link TGT/bin/gcc-4.5.1/release/link-static/runtime-link-static/datagen
/usr/bin/ld: cannot find -lstdc++
/usr/bin/ld: cannot find -lm
/usr/bin/ld: cannot find -lc
collect2: ld returned 1 exit status

These don't come when I run bjam link=static. Please advise ?


Solution

  • I belive that libstdc++ is intentionally not linked statically. Doing so is considered by many to be filled with peril (though I have not really heard a good reason). I do not think that there is a simple flag that you can add. For the gcc toolset you would add something like

    -static-libgcc  -Wl,-Bstatic -lstdc++
    

    to your cxxflags for your build variant.