static compilation is broken!?

Bug #594395 reported by Jan on 2010-06-15
This bug affects 1 person
Affects Status Importance Assigned to Milestone

Bug Description

When I try to compile the simulator statically (e.g. install --static), it will put all the *.a static library files into sandbox/dbg/lib but the executable in sandbox/bin/openwns is only 130kB big - obviously not statically linked. Also, when I try to run it, it complains about missing .so libraries.

Is it currently possible to link statically to get one big executable that contains all necessary library functions?


Jan (jan-ellenbeck) wrote :

After talking to Maciej, I did some more testing. The above mentioned problem with static compiling only seems to happen if the simulator has previously been compiled non-static. If it is freshly checked our or if "scons -c" has been run before, static compilation succeeds.

However, the current static build is not suitable for running the static binary on machines with slightly different Linux installations. If, e.g., the boost library version is different, the static openwns still would not run because only some libraries are included in the archive (everything between -whole-archive and -no-whole-archive in the example below). Is there a way to include more in the static binary? I tried removing the "-no-whole-archive" part but could not make it compile then.

g++ -o .build/dbg/openwns-application/openwns -Wl,--whole-archive -lcopper -lofdmaphy -lwifimac -lwimac -lip -lconstanze -lrise -ltcp -lwns -lglue -ldllbase -lsimpletl -Wl,--no-whole-archive -Wl,-disable-new-dtags .build/dbg/openwns-application/src/Main.o -Lsandbox/dbg/lib -lboost_filesystem-mt -lboost_program_options-mt -lm -ldl -lpython2.6 -lutil -lwns -lboost_date_time-mt -lpthread -lcppunit -lboost_signals-mt


Jan (jan-ellenbeck) wrote :

After some more testing, I found (by trial and error) the following linker command line that successfully links one big static binary that has no further external (e.g. boost, python etc.) dependencies:

g++ -o .build/dbg/openwns-application/openwns -Wl,--whole-archive -lcopper -lofdmaphy -lwifimac -lwimac -lip -lconstanze -lrise -ltcp -lwns -lglue -ldllbase -lsimpletl -Wl,-disable-new-dtags .build/dbg/openwns-application/src/Main.o -Lsandbox/dbg/lib -lboost_filesystem-mt -lboost_program_options-mt -lm -ldl -lpython2.6 -lutil -lboost_date_time-mt -lpthread -lcppunit -lboost_signals-mt -Wl,-zmuldefs -static -lz -lssl -lcrypto -lboost_system -Wl,-no-whole-archive -lc

The above is an alternative fix to this bug: which was fixed - as far as I see - by introducing the -Wl,-no-whole-archive flags that lead to not including all these external libs.


To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers