我正在尝试通过MinGW构建RecastNavigation,除了RecastDemo应用程序外,一切似乎都很好。
我做完了:
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 ..
然后让VERBOSE = 1 在最后给我这个(切掉一堆未定义的):
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
我不确定在哪里探索更多,因为图书馆顺序似乎是正确的。我在这里缺少什么?
答案 0 :(得分:1)
问题是你缺少一个链接库,在这种情况下是mingw32。解决它的最简单方法是告诉CMake在哪里找到SDL。您可以通过设置SDLDIR环境变量来完成此操作(请参阅http://cmake.org/cmake/help/v2.8.10/cmake.html#module:FindSDL)。因此,根据您的SDL安装位置,从MinGW提示符开始:
export SDLDIR=/c/_libdist/x86/msys
然后运行CMake:
cmake -G "MSYS Makefiles" ..
这应该找到SDL并正确设置SDL包含目录和链接库。
但是,CMake中存在一个错误,它以错误的顺序将库传递给链接器,请参阅http://public.kitware.com/Bug/view.php?id=13769。该错误已得到修复,但尚未在最新版本中发布(2.8.10.2)。
在有新的CMake版本之前,你可以做的就是编辑缓存 构建目录和交换机中CMakeCache.txt中的SDL_LIBRARY值 然后,SDL库的顺序再次运行CMake。