我无法使用我正在使用的其他库来正确链接到我的项目中.
我正在使用CLion,它使用cmake来构建它的项目.我试图将几个库与OpenGL结合使用来构建一些对象.我最初在Visual Studio中构建它,因为我无法弄清楚如何让cmake与Clion一起工作.但是,现在代码全部工作(无论如何都在Visual Studio中),我希望能够使用CLion,因为这是我首选的IDE.
我还是cmake的新手,我不明白我的错误CMakeLists.txt.这是我有的:
cmake_minimum_required(VERSION 3.3)
project(texture_mapping)
find_package(OpenGL REQUIRED)
link_directories(${OPENGL_gl_LIBRARY})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(SOURCE_FILES main.cpp camera.h display.h display.cpp mesh.cpp mesh.h obj_loader.cpp obj_loader.h shader.cpp shader.h stb_image.c stb_image.h texture.cpp texture.h transform.h)
link_directories(texture_mapping ${PROJECT_SOURCE_DIR}/lib)
add_executable(texture_mapping ${SOURCE_FILES})
target_include_directories(texture_mapping PUBLIC ${PROJECT_SOURCE_DIR}/include)
target_link_libraries(texture_mapping SDL2 SDL2main SDL2test glew32 glew32s ${OPENGL_gl_LIBRARY})
Run Code Online (Sandbox Code Playgroud)
我调整它直到它没有在CLion中给我任何更多的错误,但我的代码仍然无法识别头文件.
所以,我放了我需要的所有库,但它似乎没有在代码中识别它们.Clion在项目中识别它们(它们没有出现错误的红色),但是当它构建时(当我尝试在CLion中运行它时),我得到这些错误:
CMakeFiles\texture_mapping.dir/objects.a(mesh.cpp.obj): In function `ZN4MeshD2Ev':
...texture-mapping/mesh.cpp:30: undefined reference to `_imp____glewDeleteVertexArrays'
CMakeFiles\texture_mapping.dir/objects.a(mesh.cpp.obj): In function `ZN4Mesh8InitMeshERK12IndexedModel':
...texture-mapping/mesh.cpp:36: undefined reference to `_imp____glewGenVertexArrays'
...texture-mapping/mesh.cpp:37: undefined reference to `_imp____glewBindVertexArray'
...texture-mapping/mesh.cpp:39: undefined reference to `_imp____glewGenBuffers'
...texture-mapping/mesh.cpp:40: undefined reference …Run Code Online (Sandbox Code Playgroud)