So, I am using freeglut to try to do some openGL stuff, but I keep getting errors saying that references are undefined:
CMakeFiles\texture_mapping.dir/objects.a(TextureMapper.cpp.obj): In function `ZN13TextureMapper4initEv':
.../TextureMapper.cpp:20: undefined reference to `glClearColor@16'
.../TextureMapper.cpp:23: undefined reference to `glMatrixMode@4'
.../TextureMapper.cpp:24: undefined reference to `glLoadIdentity@0'
.../TextureMapper.cpp:25: undefined reference to `glOrtho@48'
CMakeFiles\texture_mapping.dir/objects.a(TextureMapper.cpp.obj): In function `ZN13TextureMapper7displayEv':
.../TextureMapper.cpp:45: undefined reference to `glClear@4'
...TextureMapper.cpp:48: undefined reference to `glColor3f@12'
...TextureMapper.cpp:49: undefined reference to `glBegin@4'
...TextureMapper.cpp:52: undefined reference to `glVertex3f@12'
...TextureMapper.cpp:53: undefined reference to `glVertex3f@12'
...TextureMapper.cpp:54: undefined reference to `glVertex3f@12'
...TextureMapper.cpp:55: undefined reference to `glVertex3f@12'
...TextureMapper.cpp:58: undefined reference to `glEnd@0'
...TextureMapper.cpp:61: undefined reference to `glFlush@0'
I am using MinGW with CLion to do this project. I thought that I got everything correctly. I moved the appropriate files into the include
folder in MinGW, as well as the bin
folder, and also the lib
folder. Then, I have this in my 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)
The libraries I linked were the only library files that freeglut came with.
So, what am I missing? CLion doesn't show any errors before it is compiled. I can even go into the functions in the header files provided by freeglut. Why then, are these functions not defined in my program?