static compilation is broken!?

Bug #594395 reported by Jan
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
openWNS SDK
New
Undecided
Unassigned

Bug Description

When I try to compile the simulator statically (e.g. playground.py 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?

Cheers
Jan

Revision history for this message
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

Cheers
Jan

Revision history for this message
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: https://bugs.launchpad.net/openwns-application/+bug/322715 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.

Cheers
Jan

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

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.