2011-02-07 42 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