rev 5455 scripting changes breaks linking under linux

Bug #613556 reported by Stefan Karpinski
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
widelands
Invalid
Undecided
Unassigned

Bug Description

Every time i tried to build widelands rev 5455 and later (as Release or Debug) I got

[ 99%] Built target widelands
Scanning dependencies of target test_widelands_scripting
[ 99%] Building CXX object src/scripting/test/CMakeFiles/test_widelands_scripting.dir/scripting_test_main.cc.o
[ 99%] Building CXX object src/scripting/test/CMakeFiles/test_widelands_scripting.dir/test_luna.cc.o
[100%] Building CXX object src/scripting/test/CMakeFiles/test_widelands_scripting.dir/__/_
/build_info.cc.o
Linking CXX executable test_widelands_scripting
/usr/lib64/gcc/x86_64-suse-linux/4.4/../../../../lib64/crt1.o: In function `_start':
/usr/src/packages/BUILD/glibc-2.10.1/csu/../sysdeps/x86_64/elf/start.S:109: undefined reference to `main'
collect2: ld gab 1 als Ende-Status zurück
make[2]: *** [src/scripting/test/test_widelands_scripting] Fehler 1
make[1]: *** [src/scripting/test/CMakeFiles/test_widelands_scripting.dir/all] Fehler 2
make: *** [all] Fehler 2

I have to comment the line no. 109
set (Boost_FIND_COMPONENTS unit_test_framework)
and change the line no. 113
from
find_package(Boost 1.35.0 COMPONENTS unit_test_framework REQUIRED)
to
find_package(Boost 1.35.0 COMPONENTS REQUIRED)
to fix the error.
Boost packages: boost-1.39.0 (only the shared libs, but it happens with the static libs too) , boost-devel-1.39.0

Related branches

Revision history for this message
Stefan Karpinski (stefan-karpinski) wrote :

Sorry I forget where I made the changes: CMakeLists.txt in the main directory.

Revision history for this message
Stefan Karpinski (stefan-karpinski) wrote :

I don't think this is a duplicate of bug #613590.
Bug 613590 describes what happens if boost_unit_test_framework is not installed.
This bug describes what happens if boost_unit_test_framework is installed.

Maybe this happens only under Linux without crosscompiling or my boost version (1.39.0) is to new.
I can't test it with other boost versions because the server www.boost.org is down.

Revision history for this message
SirVer (sirver) wrote :

you are right, I misunderstood the other bug.

Revision history for this message
Stefan Karpinski (stefan-karpinski) wrote :

After a long search through the cmake generated files I found the reason:
If you have both shared and static boost libs installed,
cmake takes always the shared libs even if you set Boost_USE_STATIC_LIBS to ON.
This happens if you have multithreaded boost libs because the static boost libs on my
system have no -mt part in their names like the shared.
If I create a libboost_unit_test_framework-mt.a the error is gone.
I don't know if this a boost or cmake bug but I think it's not a widelands bug.

Revision history for this message
SirVer (sirver) wrote :

wonderfull! that's pretty much all then for us :)

or is there a nice little workaround we could sneak into our cmake files to avoid this situation in the future?

Changed in widelands:
status: New → Invalid
Revision history for this message
Stefan Karpinski (stefan-karpinski) wrote :

By default boost installs the libs without the -mt part ( until now). Under Linux the package mantainer sets or sets not symlinks with the -mt part or rename the libs. It could be easy if the original filenames stays intact. If so, setting Boost_USE_MULTITHREADED to OFF will do the trick.

Revision history for this message
Timowi (timo-wingender) wrote :

The Boost_USE_MULTITHREADED is senseless for widelands. We do not need this. So I am for removing this.

Revision history for this message
Stefan Karpinski (stefan-karpinski) wrote :

I found an easy way to fix it on all Systems with all boost versions:
Copy the FindBoost.cmake file from the cmake distribution to your cmake/Modules directory and apply the attached patch.

Revision history for this message
Jari Hautio (jarih) wrote :

Ubuntu has just multithreaded libs and at least my ubuntu with cmake 2.6.2 wont find test library if Boost_USE_MULTITHREADED is OFF..

I just committed a fix to make building unit tests optional through BUILD_UNIT_TESTS variable, so that it's easier to deal with this kind of errors.

Revision history for this message
Jari Hautio (jarih) wrote :

In case you are not familiar with CMake, it's easy to override selected libraries if cmake picks wrong library.

I normally use cmake-gui for configuring and after configure step is ready, you can easily check selected libraries and change the library variable Boost_UNIT_TEST_FRAMEWORK_LIBRARY to the correct one in the GUI. Alternatively you can give the library in the command line. CMake caches the variables, so it's enough to set it once.

Revision history for this message
Jari Hautio (jarih) wrote :

This bug propably resurfaced in Bug #662045. In rev 5588 I changed boost unit tests to use dynamic runtime on linux. This was done to support building tests on opensuse 11.3, which did not have static libraries installed. Additionally unit tests are not compiled anymore unless explicitly requested.

Stefan, if you are still around, could you check that widelands and tests compile now without extra steps.

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.