gpt4 book ai didi

c++ - 无法将 assimp 与 cmake 链接起来

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:15:10 51 4
gpt4 key购买 nike

所以我设置了一个 CMakeLists.txt 脚本(运行良好),它设置了我的项目:问题是当我运行 makefile 时,一切运行正常,直到它打印我:

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})

最佳答案

我想正确的答案是:

target_link_libraries(${PROJECT_NAME} ${ASSIMP_LIBRARIES})

图书馆不是图书馆

关于c++ - 无法将 assimp 与 cmake 链接起来,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31211684/

51 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com