我尝试使用cmake将一个程序链接到ogre和OS X上的其他几个库中,但我一直收到这个错误:
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同样的cmake文件可以在windows和Linux上运行。我正在尝试链接到ogre 1.7.2框架,它是我从ogre网站上的SDK获得的。我认为这是一个链接问题,但不是食人魔的问题。使用cmake链接框架并不像我希望的那样直观。有什么办法解决这个问题吗?
发布于 2011-02-14 05:17:53
首先,您应该定义${APPLE}“并不意味着系统是Mac,只是 note 是在C/C++头文件中定义的”。使用IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")检查OS X。
我没有您的构建环境来测试以下建议,但请尝试一下:
Line 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将目标(在本例中应该是物理游戏库)作为第一个参数,但是您已经向它传递了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
https://stackoverflow.com/questions/4918338
复制相似问题