windows compilation, undefined reference

Bug #1168955 reported by Emmanuel
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Stellarium
Expired
Medium
Unassigned

Bug Description

When compiling stellarium 0.12.0 (also applies to previous versions) on windows XP following the instruction provided I get several errors.

1/ At linking stage of libstelMain
        Linking CXX shared library libstelMain.dll
        CMakeFiles/stelMain.dir/core/external/kdewin32/inet.c.obj:inet.c:(.text+0x16): undefined reference to `_inet_addr@4'
=> To fix this add ws2_32 in the TARGET_LINK_LIBRARIES directive for StelMain

2/ At linking stage of dynamic plugins
        A myriad (literally) of undefined references to Qt functions reference from StelGuiLib
=> To fix this, replace, in the CMakeLists.txt of each dynamic plugin, SET(StelMain stelMain) with SET(StelMain StelGuiLib stelMain)
and add a second TARGET_LINK_LIBRARIES directive for the plugin: TARGET_LINK_LIBRARIES(Plugin StelMain ${QT_LIBRARIES})

Don't know to what extent these errors are a due to a discrepancy between my build environment and the official one used by the stellarium team, but in case this affects other people, it's now documented here.

Revision history for this message
Alexander Wolf (alexwolf) wrote :

Which version of cmake you use for compilation of Stellarium?

Revision history for this message
Emmanuel (hacker-emmanuel) wrote :

I use version CMake 2.8.10.2 on Windows XP, and CMake 2.8.9 on linux when cross-compiling for windows, both yield the same errors.

Changed in stellarium:
importance: Undecided → Medium
Revision history for this message
Bogdan Marinov (daggerstab) wrote :

I can confirm the first issue - it happens when you turn off the Telescope Control plug-in when you compile Stellarium, as it's the plug-in that adds the winsock library to the linker flags. (And it's apparently required by the KDEWin fragment that we use, because of some data structures.)

Revision history for this message
Emmanuel (hacker-emmanuel) wrote :

I forgot to mention that I encountered these problems while compiling stellarium with no static plugins.

Revision history for this message
Emmanuel (hacker-emmanuel) wrote :

I just discovered that the proposed solution to issue 2) is a non-solution.
It actually makes the linking succeed, but it causes the application to crash (on windows but not linux) when a toolbar button created by the plugin is merely hovered by the mouse (I used the AngleMeasure plugin to ascertain the causality between the proposed cmake fix and the button-hover crash, because this plugin has no linking issues to start with).
I haven't figured an actual solution yet, it will require delving more into the subteties of linking on windows.

Revision history for this message
Emmanuel (hacker-emmanuel) wrote :

Issue 2 can be fixed in the following way.

As a reminder of this issue, at the linking stage of the plugin dll concerned by the problem we get errors like:
../../../../../src/./libStelGuiLib.a(AddRemoveLandscapesDialog.cpp.obj):AddRemoveLandscapesDialog.cpp:(.text+0x611): référence indéfinie vers « LandscapeMgr::getUserLandscapeIDs() const

In cmake-generated file "link.txt" we have:
/usr/bin/i686-w64-mingw32-g++ [...] ../../../src/libstelMain.dll.a [...] ../../../src/./libStelGuiLib.a -lws2_32 [...] -lcomdlg32 -ladvapi32

Problem is StelGuiLib references some symbols defined in stelMain but is placed after stelMain on the link command.
To fix the issue it suffices to place stelMain after StelGuiLib on the link line.
That was the purpose of the first proposed "solution" but since it has side-effects at run-time it must be done another way.

The following seems to work and not have side-effects at run-time that I noticed.
In the CMakeLists.txt of the plugin add:
ADD_CUSTOM_TARGET(fix_link_txt
 # the $$ way of escaping $ has to do with 'make'
 COMMAND sed -i '3s:$$:../../../src/libstelMain.dll.a:' link.txt
 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/plugins/MyPlugin/src/CMakeFiles/MyPlugin.dir/
)
ADD_DEPENDENCIES(MyPlugin fix_link_txt)

The link.txt file now becomes:
/usr/bin/i686-w64-mingw32-g++ [...] ../../../src/libstelMain.dll.a [...] ../../../src/./libStelGuiLib.a -lws2_32 [...] -lcomdlg32 -ladvapi32 ../../../src/libstelMain.dll.a

Changed in stellarium:
status: New → Confirmed
Revision history for this message
gzotti (georg-zotti) wrote :

A lot has changed in project building over the last year. Is this still an open issue? Most likely it has fix released, or not?

Changed in stellarium:
status: Confirmed → Won't Fix
status: Won't Fix → Incomplete
Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for Stellarium because there has been no activity for 60 days.]

Changed in stellarium:
status: Incomplete → Expired
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.