2011-02-07 62 views
1

我试图程序对食人魔和使用cmake在OS X上一些其他的库链接,但我不断收到此错误:在Mac OS链接到框架,cmake的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上运行。我试图链接到我在食人魔网站上从SDK获得的食人魔1.7.2框架。我认为这是一个链接问题,但不是一个食人魔问题。用cmake与框架链接并不像我所希望的那样直观。有想法该怎么解决这个吗?

+0

很可能在你的CMake脚本错误。你介意发布吗? – 2011-02-07 06:44:06

+0

感谢您的回复,并对延误表示歉意。我不得不帮助队友干净地合并,但原始帖子中的所有内容仍然适用。这里是根CMakeLists.txt:http://gitorious.org/physgame/physgame/blobs/master/CMakeLists.txt下面是我们期待的问题:http://gitorious.org/physgame/physgame /blobs/master/physgameengine/CMakeLists.txt – Sqeaky 2011-02-08 18:58:30

回答

5

首先,你应该note${APPLE} “并不意味着该系统是Mac OS X中,只有APPLE在C/C++头文件#define的。”使用IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")检查OS X.

我没有你的构建环境中测试了以下建议,而是给他们一个尝试:

线309321有一个错字。它应该是"${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