MantisBT - CMake
View Issue Details
0004539CMakeModulespublic2007-03-06 14:212016-06-10 14:30
Galmes Pierre-AndrĂ© 
Eric Wing 
lowmajoralways
closedmoved 
 
 
0004539: linking issue with FindSDL.cmake and mingw / msys
The short version:

When compiling a project with cmake, the generated linking line has not all the flags needed. It lacks -lmingw32 -lSDLmain -lSDL -lmwindows.

check also this mail:
http://www.mail-archive.com/cmake@cmake.org/msg05054.html [^]

The long version:

Hello,

I've been playing for some days with cmake, and I have to say that I quite love the way it works. But while trying to compile a sourceforge project under Windows using MSYS, I run into a problem.

I do not know if the problem is related to the CMakeLists.txt that I did not wrote correctly or to an issue into the FindSDL.cmake. That's why I write here.

What I did:

- I wrote the CMakeLists.txt under Linux. There, everything compiled like a charm. I added the code of my CMakeLists.txt at the end of the mail

- Under Windows, I then generated the make files for MSYS and tried to compile it using msys and mingw:


$ make
Scanning dependencies of target bloodybeard
[ 25%] Building CXX object CMakeFiles/bloodybeard.dir/main.obj
[ 50%] Building CXX object CMakeFiles/bloodybeard.dir/qGameEngine.obj
[ 75%] Building CXX object CMakeFiles/bloodybeard.dir/moc_qGameEngine.obj
Linking CXX executable bloodybeard.exe
CMakeFiles/bloodybeard.dir/qGameEngine.obj(.text+0x1d7):qGameEngine.cpp: undefined reference to `SDL_Init'
CMakeFiles/bloodybeard.dir/qGameEngine.obj(.text+0x1eb):qGameEngine.cpp : undefined reference to `SDL_WM_SetCaption'
...

So, the SDL lib is not correctly linked under Windows/MSYS.

I then checked the "build.make" file generated. It does not includes all the needed link flags needed for SDL under mingw ( -lmingw32 -lSDLmain -lSDL -lmwindows).

Why aren't those flags added? It looks like the SDL_LIBRARY variable is empty, but why ?

I would need some help to investigate further.

- In the FindSDL.cmake, there is a specific part related to MINGW:

# MinGW needs an additional library, mwindows
# It's total link flags should look like -lmingw32 -lSDLmain -lSDL -lmwindows
# (Actually on second look, I think it only needs one of the m* libraries.)
IF(MINGW)
  SET(MINGW32_LIBRARY mingw32 CACHE STRING "mwindows for MinGW")
ENDIF(MINGW)

So, why doesn't this work ? Is there a specific MSYS flag to add?


I have a few workarounds in order to compile my project, but would
like to help.


Regards,
Pierre-André Galmes


I - Links:

The project is at the following adress:
http://sourceforge.net/projects/bloodybeard [^]

You can access to the svn source if you want to.


II - CMakeLists.txt :

check the web page:
http://www.mail-archive.com/cmake@cmake.org/msg05054.html [^]
No tags attached.
Issue History
2008-10-08 09:16Bill HoffmanAssigned ToBill Hoffman => Eric Wing
2011-01-18 12:06David ColeNote Added: 0024879
2016-06-10 14:27Kitware RobotNote Added: 0041345
2016-06-10 14:27Kitware RobotStatusassigned => resolved
2016-06-10 14:27Kitware RobotResolutionopen => moved
2016-06-10 14:30Kitware RobotStatusresolved => closed

Notes
(0024879)
David Cole   
2011-01-18 12:06   
Is this still an issue with CMake 2.8.3 or CMake 2.8.4-rc1?

Please let us know -- thanks.
(0041345)
Kitware Robot   
2016-06-10 14:27   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.