所以我成立了一個腳本的CMakeLists.txt(運行正常),其中規定了我的項目鏈接assimp:問題是,當我運行makefile,一切都正常運行,直到它打印我:不能與cmake的
PS:我這樣安裝了assimp(我在linux/ubuntu上):sudo apt-get install libassimp-dev
;圖書館是肯定安裝好;因爲我已經使用它,在同一個項目中使用code :: blocks!
Linking CXX executable Test
CMakeFiles/Test.dir/src/Mesh.cpp.o: In function `Mesh::Mesh(char const*)':
Mesh.cpp:(.text+0x1db): undefined reference to `Assimp::Importer::Importer()'
Mesh.cpp:(.text+0x1f9): undefined reference to `Assimp::Importer::ReadFile(char const*, unsigned int)'
Mesh.cpp:(.text+0x625): undefined reference to `Assimp::Importer::~Importer()'
Mesh.cpp:(.text+0x672): undefined reference to `Assimp::Importer::~Importer()'
collect2: error: ld returned 1 exit status
make[2]: *** [Test] Error 1
make[1]: *** [CMakeFiles/Test.dir/all] Error 2
make: *** [all] Error 2
這裏是我的CMakeLists.txt:
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
project(Test)
set(CMAKE_CXX_FLAGS "-std=c++11")
################INCLUDE LIBRARIES###################
#specify module path
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
#OPENGL
find_package(OpenGL REQUIRED)
if(OPENGL_FOUND)
include_directories(${OpenGL_INCLUDE_DIRS})
endif()
#SDL2
find_package(SDL2 REQUIRED)
if(SDL2_FOUND)
include_directories(${SDL2_INCLUDE_DIR})
endif()
#GLEW
find_package(GLEW REQUIRED)
if(GLEW_FOUND)
include_directories(${GLEW_INCLUDE_DIR})
endif()
#BOOST
find_package(BOOST REQUIRED)
if(BOOST_FOUND)
include_directories(${BOOST_INCLUDE_DIR})
endif()
#LUA
find_package(LUA REQUIRED)
if(LUA_FOUND)
include_directories(${LUA_INCLUDE_DIR})
endif()
#LUABIND
find_package(LUABIND REQUIRED)
if(LUABIND_FOUND)
include_directories(${LUABIND_INCLUDE_DIR})
endif()
#ASSIMP
find_package(ASSIMP REQUIRED)
if(ASSIMP_FOUND)
include_directories(${ASSIMP_INCLUDE_DIR})
endif()
include_directories(
#include directories are here...
)
add_executable(
${PROJECT_NAME}
#I won't list cpp files, bcause there are a lot !
)
################LINK LIBRARIES#####################
target_link_libraries(Test ${OPENGL_LIBRARY})
target_link_libraries(Test ${SDL2_LIBRARY})
target_link_libraries(Test ${GLEW_LIBRARY})
target_link_libraries(Test ${BOOST_LIBRARY})
target_link_libraries(Test ${LUA_LIBRARY})
target_link_libraries(Test ${LUABIND_LIBRARY})
target_link_libraries(Test ${CMAKE_DL_LIBS})
target_link_libraries(Test ${ASSIMP_LIBRARY})
好感謝:)我會嘗試它現在! – MattMatt
nope,仍然有錯誤...我有我的assimp文件夾... Ispecify包含它的路徑? – MattMatt
沒有,仍然沒有工作....但我有我的cimke文件夾旁邊的assimp文件夾,我如何指定包含它的路徑? – MattMatt