I'm linking GLEW, SDL2 and Assimp with Cmake. It seems to be working fine while building the .o files, however when linking them I get these errors
:-1: error: CMakeFiles/"Projectpath".cpp.o: undefined reference to symbol 'glDrawElements'
/usr/lib/x86_64-linux-gnu/mesa/libGL.so.1:-1: error: error adding symbols: DSO missing from command line
:-1: error: collect2: error: ld returned 1 exit status
Here's the part of the Cmakefile that links the libraries
find_package(OpenGL)
find_package(GLEW)
find_package(SDL2)
find_package(Assimp)
#Include(FindPkgConfig)
#PKG_SEARCH_MODULE(SDL2 REQUIRED sdl2)
set(INCLUDE_DIRS ${OpenGL_INCLUDE_DIRS} ${SDL2_INCLUDE_DIRS} ${GLEW_INCLUDE_DIRS} ${Assimp_INCLUDE_DIRS})
set(LIBS ${LIBS} ${OpenGL_LIBRARIES} ${SDL2_LIBRARIES} ${GLEW_LIBRARIES} ${Assimp_LIBRARIES} )
include_directories(${INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME} ${LIBS})
I tried changing the linking order as I read that could be a problem.
I also added the OpenGL thing because of the libGL thing in the error, it doesn't seem to work.
I also read about checking dependencies using pkg-config --print-requires --print-requires-private glew
, but the problem is that it has like 20 different libraries it depends on. Would I need to link all of them?
It's not that I don't have the correct libraries, I created a basic OpenGL program on this computer last week and that worked fine (I used another way of linking my libraries and also used Code::Blocks instead of Qt-Creator)
I assume that the DSO thing is the problem after reading the answer to this question. But shouldn't that mean that doing the OpenGL thing in the cmakefile fix it?
Thanks!
EDIT: I can create VertexArrays, VertexBuffers etc. But as soon as I add in calls to either. glDrawElements(...)
or glDrawArrays(...)
I get that error. (I might get that error on some other functions as well, but those are the only ones I get that error on when I try to render a basic mesh)