所以,我使用freeglut嘗試做一些openGL的東西,但我不斷收到錯誤說引用未定義在OpenGL鏈接錯誤:使用freeglut在克利翁
CMakeFiles\texture_mapping.dir/objects.a(TextureMapper.cpp.obj): In function `ZN13TextureMapper4initEv':
.../TextureMapper.cpp:20: undefined reference to `[email protected]'
.../TextureMapper.cpp:23: undefined reference to `[email protected]'
.../TextureMapper.cpp:24: undefined reference to `[email protected]'
.../TextureMapper.cpp:25: undefined reference to `[email protected]'
CMakeFiles\texture_mapping.dir/objects.a(TextureMapper.cpp.obj): In function `ZN13TextureMapper7displayEv':
.../TextureMapper.cpp:45: undefined reference to `[email protected]'
...TextureMapper.cpp:48: undefined reference to `[email protected]'
...TextureMapper.cpp:49: undefined reference to `[email protected]'
...TextureMapper.cpp:52: undefined reference to `[email protected]'
...TextureMapper.cpp:53: undefined reference to `[email protected]'
...TextureMapper.cpp:54: undefined reference to `[email protected]'
...TextureMapper.cpp:55: undefined reference to `[email protected]'
...TextureMapper.cpp:58: undefined reference to `[email protected]'
...TextureMapper.cpp:61: undefined reference to `[email protected]'
我使用的MinGW與克利翁以做這個項目。我以爲我把一切都正確了。我將相應的文件移動到MinGW中的include
文件夾,以及bin
文件夾以及lib
文件夾中。然後,我有這個在我的CMakeLists.txt
:
cmake_minimum_required(VERSION 3.3)
project(texture_mapping)
find_package(OpenGL REQUIRED)
find_package(GLUT REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(SOURCE_FILES main.cpp TextureMapper.cpp TextureMapper.h Vertex.h ObjParser.cpp ObjParser.h)
add_executable(texture_mapping ${SOURCE_FILES})
target_link_libraries(texture_mapping libfreeglut.a libfreeglut_static.a)
我聯繫的圖書館是該freeglut帶着唯一的庫文件。
那麼,我錯過了什麼? CLion在編譯之前不會顯示任何錯誤。我甚至可以進入freeglut提供的頭文件中的函數。那麼爲什麼這些函數沒有在我的程序中定義?
您的問題有與CLion無關。這只是關於CMake和你的環境。 – Sergey