Question

I'm trying to build RecastNavigation via MinGW, everything seems builds just fine except RecastDemo application.

I've done:

cmake -G"MSYS Makefiles" -DSDL_INCLUDE_DIR:PATH=/c/_libdist/x86/msys/include/SDL \
-DSDL_LIBRARY:PATH=/c/_libdist/x86/msys/lib/libSDL.a \
-DSDLMAIN_LIBRARY:PATH=/c/_libdist/x86/msys/lib/libSDLMain.a ..

then make VERBOSE=1 gives me this at the end (cut out bunch of undefines):

cd /C/_lib/blackberry/RecastNavigation/build.msys/RecastDemo && /C/app/MinGW/bin/g++.exe  -O3 -DNDEBUG    -mwindows -Wl,
--whole-archive CMakeFiles/RecastDemo.dir/objects.a -Wl,--no-whole-archive  -o ../../RecastDemo/Bin/RecastDemo.exe -Wl,-
-out-implib,../../RecastDemo/Bin/libRecastDemo.dll.a -Wl,--major-image-version,0,--minor-image-version,0  ../DebugUtils/
libDebugUtils.a ../Detour/libDetour.a ../DetourCrowd/libDetourCrowd.a ../DetourTileCache/libDetourTileCache.a ../Recast/
libRecast.a /c/_libdist/x86/msys/lib/libSDL.a /c/_libdist/x86/msys/lib/libSDLMain.a -lglu32 -lopengl32 -lkernel32 -luser
32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32
Creating library file: ../../RecastDemo/Bin/libRecastDemo.dll.a
c:/_libdist/x86/msys/lib/libSDL.a(SDL_systimer.o): In function `SDL_StartTicks':
c:\_lib\SDL\1.2.15/./src/timer/win32/SDL_systimer.c:67: undefined reference to `timeBeginPeriod@4'
c:\_lib\SDL\1.2.15/./src/timer/win32/SDL_systimer.c:68: undefined reference to `timeGetTime@0'
c:/_libdist/x86/msys/lib/libSDL.a(SDL_systimer.o): In function `SDL_GetTicks':
...
...
...
c:/app/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../libmingw32.a(main.o): In function `main':
C:\MinGW\msys\1.0\src\mingwrt/../mingw/main.c:73: undefined reference to `WinMain@16'
collect2: ld returned 1 exit status
make[2]: *** [../RecastDemo/Bin/RecastDemo.exe] Error 1

I'm not sure where to explore more as library order seems correct. What am i missing here?

Was it helpful?

Solution

The problem is you are missing a link library, mingw32 in this case. The easiest way to fix it is to tell CMake where to find SDL. You can do this by setting the SDLDIR environment variable (see http://cmake.org/cmake/help/v2.8.10/cmake.html#module:FindSDL). So based on your SDL install location, from your MinGW prompt:

export SDLDIR=/c/_libdist/x86/msys

Then run CMake:

cmake -G "MSYS Makefiles" ..

This should find SDL and set the SDL include directories and link libraries correctly.

However, there is a bug in CMake that passes libraries to the linker in the wrong order, see http://public.kitware.com/Bug/view.php?id=13769. The bug has been fixed but isn't in the latest release yet (2.8.10.2).

Until there's a new CMake release what you can do is edit the cached SDL_LIBRARY value in CMakeCache.txt in your build directory and switch the order of the SDL libraries around then run CMake again.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top