我正在尝试使用cmake在OS X上针对Ogre和其他一些库链接程序,但我一直收到此错误:
ld: warning: directory '/Library/Frameworks/SDL.framework/Debug' following -L not found
ld: warning: directory '-framework Cocoa/Debug' following -L not found
ld: warning: directory '-framework Cocoa' following -L not found
ld: warning: directory '/System/Library/Frameworks/OpenAL.framework/Debug' following -L not found
ld: warning: directory '/Library/Frameworks/Ogre.framework/Debug' following -L not found
ld: warning: directory '/opt/local/lib/libogg.dylib/Debug' following -L not found
ld: warning: path '/opt/local/lib/libogg.dylib' following -L not a directory
ld: warning: directory '/Users/hydrowolfy/Documents/newphysgame/physgame/physgameengine/data/macosx/ogre/Debug' following -L not found
ld: warning: directory '/Users/hydrowolfy/Documents/newphysgame/physgame/physgameengine/data/macosx/ogre' following -L not found
ld: warning: directory '/Users/hydrowolfy/Documents/newphysgame/physgame/physgameengine/data/macosx/openal/Debug' following -L not found
ld: warning: directory '/Users/hydrowolfy/Documents/newphysgame/physgame/physgameengine/data/macosx/openal' following -L not found
ld: warning: directory '/Users/hydrowolfy/Documents/newphysgame/physgame/physgameengine/data/macosx/oggvorbis/Debug' following -L not found
ld: warning: directory '/Users/hydrowolfy/Documents/newphysgame/physgame/physgameengine/data/macosx/oggvorbis' following -L not found
ld: library not found for -lOgreMain
collect2: ld returned 1 exit status
Command /Developer/usr/bin/g++-4.2 failed with exit code 1
Windows和Linux上都可以使用相同的cmake文件。我试图链接到我从ogre网站上的SDK获得的ogre 1.7.2框架。我认为这是一个联系问题,而不是一个食人魔问题。与cmake链接到框架并不像我希望的那样直观。有想法该怎么解决这个吗?
最佳答案
首先,您应该note,${APPLE}
“并不意味着系统是Mac OS X,只有 APPLE 是在C / C++头文件中定义的。”使用IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
检查OSX。
我没有构建环境来测试以下建议,但请尝试一下:
第309和321行有错字。它应该是"${OGRE_INCLUDE_DIR}"
(不是${OGRE_INCLUDE_DIRS}
)。
在line 327处,${SDL_LIBRARY}
,${OPENAL_LIBRARY}
和${OGG_LIBRARY}
是库文件的路径,而它们应该是这些库目录的路径。 link_directories
告诉链接器哪些目录包含您在target_link_libraries
中指定的库。
除OGRE之外,line 327指定库(SDL,AL和OGG),这些库的FindXXX.cmake
没有定义_LIB_DIR
变量(或等效的指示包含该库的目录)。所以那条线应该是
link_directories("${OGRE_LIB_DIR}")
另外,line 336似乎不是正确的语法。
target_link_libraries
将目标(在本例中为physgame库)作为第一个参数,但是您已将其传递到Ogre库目录的路径。由于在定义目标之前无法调用该命令,因此必须将其推迟到line 386。更改line 386从:
target_link_libraries( ${PROJECT_NAME} OgreMain ${Bullet_LibraryNames} cAudio SDL )
至:
target_link_libraries(
${PROJECT_NAME}
"${OGRE_LIBRARIES}"
${Bullet_LibraryNames}
"${OPENAL_LIBRARY}"
"${SDL_LIBRARY}"
)
您可能也会对此感兴趣:http://www.ogre3d.org/forums/viewtopic.php?f=1&t=58610&start=0
关于c++ - 在Mac OS X上使用cmake链接到框架,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/4918338/