使用CMake OpenGL项目的未定义符号Assimp错误

时间:2019-06-09 05:21:41

标签: c++ opengl cmake assimp

我正在尝试使用Assimp和CMake加载模型,但在终端中始终出现以下错误:

Undefined symbols for architecture x86_64:
  "Assimp::Importer::Importer()", referenced from:
      Model::loadModel(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in ModelLoading.cpp.o
  "Assimp::Importer::~Importer()", referenced from:
      Model::loadModel(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in ModelLoading.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

这是我的CMakeLists.txt文件:

cmake_minimum_required(VERSION 2.8.9)
project(materials)

find_package(OpenGL REQUIRED)
find_package(GLUT REQUIRED)
find_package(GLEW REQUIRED)
find_package(glfw3 REQUIRED)
find_package(ASSIMP REQUIRED)

include_directories(include ${OPENGL_INCLUDE_DIRS}  ${GLUT_INCLUDE_DIRS} ${GLEW_INCLUDE_DIRS} ${ASSIMP_INCLUDE_DIRS})

file(GLOB SOURCES "src/*.cpp")

add_executable(executable ${SOURCES})

target_link_libraries(executable ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${GLEW_LIBRARIES} glfw ${ASSIMP_LIBRARY})

当我使用assimp includes运行一个简单的hello世界时(如下所示),我没有收到任何错误,因此我认为这意味着assimp已正确安装?

#include <assimp/Importer.hpp>
#include <assimp/postprocess.h>
#include <assimp/scene.h>

我有一个带有Main()的ModelLoading.cpp文件,其中包含具有Assimp包含的Model.h。

任何帮助将不胜感激!

edit:这个问题与链接的问题不同,因为我要问的是似乎有用但没有用的东西。我的include不会产生编译器错误,但是会尝试使用这些函数。

0 个答案:

没有答案
相关问题