How to fix these errors?
unresolved external symbol __imp_glBindBuffer referenced in function main
unresolved external symbol __imp_glGenBuffers referenced in function main
unresolved external symbol __imp_glBufferData referenced in function main
unresolved external symbol __imp_glAttachShader referenced in function main
…
My CMakeLists.txt looks like this
cmake_minimum_required(VERSION 3.7.1)
...
set(SDL2_LIB ${THIRDPARTY_DIR}/SDL2/bin/SDL2.lib)
file(COPY
${THIRDPARTY_DIR}/SDL2/bin/SDL2.dll
DESTINATION ${BIN_DIR})
find_package(OpenGL) # <-- I use this instead of adding the .lib file.
...
target_link_libraries(
${PROJECT_NAME}
LINK_PUBLIC
${SDL2_LIB}
${OPENGL_LIBRARIES}
${VULKAN_LIB_LIST})
The idea about find_package() and ${OPENGL_LIBRARIES} is from this https://github.com/knightcrawler25/GLSL-PathTracer/blob/master/CMakeLists.txt
I notice that OPENGL_LIBRARIES is not set in the CMakeLists.txt.
I googled my problem and people say to add ‘opengl32.lib’ to the linker input, but I don’t understand it, I tried this which doesn’t work:
target_link_libraries(
${PROJECT_NAME}
LINK_PUBLIC
${SDL2_LIB}
#${OPENGL_LIBRARIES}
opengl32.lib # <-- I added this but it doesn't work.
${VULKAN_LIB_LIST})
According to the example in the link I showed (go to the GitHub parent directory > thirdparty/gl3w/GL), they don’t add the file "opengl32.lib"
which is not in the project library too and which is good, smallest project as possible. But I don’t know how to do that.
I used this OpenGL example where there’s an exact comment with the same problem in the comment section