Cmake undefined reference to `_imp__glewExperimental'
已回答
Hi everyone,
I am trying to get an OpenGL project working with CLion on windows but I am having some serious issues with Cmake :( I am using 3 different libraries: GLM, GLEW, GLFW and SOIL. Their all located in a folder outside the project directory:

And for each directory there is an Include and Lib folders:
With windows and Linux library files:

And I am using MingW for the toolchain:

The issue I am having is the fact that My Cmake file is doing something wrong, I got the includes to work just fine but there is some issue with linking. My Cmake file below:
cmake_minimum_required(VERSION 3.6)
project(CL_GL)
set(CMAKE_CXX_STANDARD 11)
include_directories(${PROJECT_SOURCE_DIR}/../OpenGL/Lib_files/GLM/include)
include_directories(${PROJECT_SOURCE_DIR}/../OpenGL/Lib_files/GLEW/include)
include_directories(${PROJECT_SOURCE_DIR}/../OpenGL/Lib_files/GLFW/include)
include_directories(${PROJECT_SOURCE_DIR}/../OpenGL/Lib_files/SOIL/include)
set(GLEW_LIBRARY ${PROJECT_SOURCE_DIR}/../OpenGL/Lib_files/GLEW/lib/libglew32.a)
set(GLFW_LIBRARY ${PROJECT_SOURCE_DIR}/../OpenGL/Lib_files/GLFW/lib/libglfw3.a)
set(SOIL_LIBRARY ${PROJECT_SOURCE_DIR}/../OpenGL/Lib_files/SOIL/lib/libSOIL.a)
set(SOURCE_FILES main.cpp Shader.h Shader.cpp Camera.h Camera.cpp)
add_executable(CL_GL ${SOURCE_FILES})
target_link_libraries(CL_GL libopengl32.a ${GLEW_LIBRARY} ${GLFW_LIBRARY} ${SOIL_LIBRARY})
And when I try to compile the code I get these errors:
"E:\Program Files (x86)\JetBrains\CLion 2016.3\bin\cmake\bin\cmake.exe" --build "W:\GoogleDrive\OpenGL Projects\CL_GL\cmake-build-debug" --target CL_GL -- -j 8
[ 25%] Linking CXX executable CL_GL.exe
CMakeFiles\CL_GL.dir/objects.a(main.cpp.obj): In function `main':
W:/GoogleDrive/OpenGL Projects/CL_GL/main.cpp:53: undefined reference to `_imp__glewExperimental'
W:/GoogleDrive/OpenGL Projects/CL_GL/main.cpp:55: undefined reference to `_imp__glewInit@0'
W:/GoogleDrive/OpenGL Projects/CL_GL/main.cpp:119: undefined reference to `_imp____glewGenVertexArrays'
W:/GoogleDrive/OpenGL Projects/CL_GL/main.cpp:120: undefined reference to `_imp____glewGenBuffers'
W:/GoogleDrive/OpenGL Projects/CL_GL/main.cpp:122: undefined reference to `_imp____glewBindVertexArray'
W:/GoogleDrive/OpenGL Projects/CL_GL/main.cpp:123: undefined reference to `_imp____glewBindBuffer'
W:/GoogleDrive/OpenGL Projects/CL_GL/main.cpp:124: undefined reference to `_imp____glewBufferData'
W:/GoogleDrive/OpenGL Projects/CL_GL/main.cpp:127: undefined reference to `_imp____glewVertexAttribPointer'
W:/GoogleDrive/OpenGL Projects/CL_GL/main.cpp:128: undefined reference to `_imp____glewEnableVertexAttribArray'
W:/GoogleDrive/OpenGL Projects/CL_GL/main.cpp:130: undefined reference to `_imp____glewVertexAttribPointer'
W:/GoogleDrive/OpenGL Projects/CL_GL/main.cpp:131: undefined reference to `_imp____glewEnableVertexAttribArray'
W:/GoogleDrive/OpenGL Projects/CL_GL/main.cpp:133: undefined reference to `_imp____glewBindVertexArray'
W:/GoogleDrive/OpenGL Projects/CL_GL/main.cpp:139: undefined reference to `_imp____glewGenVertexArrays'
W:/GoogleDrive/OpenGL Projects/CL_GL/main.cpp:140: undefined reference to `_imp____glewBindVertexArray'
W:/GoogleDrive/OpenGL Projects/CL_GL/main.cpp:142: undefined reference to `_imp____glewBindBuffer'
W:/GoogleDrive/OpenGL Projects/CL_GL/main.cpp:143: undefined reference to `_imp____glewVertexAttribPointer'
W:/GoogleDrive/OpenGL Projects/CL_GL/main.cpp:144: undefined reference to `_imp____glewEnableVertexAttribArray'
W:/GoogleDrive/OpenGL Projects/CL_GL/main.cpp:145: undefined reference to `_imp____glewBindVertexArray'
W:/GoogleDrive/OpenGL Projects/CL_GL/main.cpp:166: undefined reference to `_imp____glewGenerateMipmap'
W:/GoogleDrive/OpenGL Projects/CL_GL/main.cpp:185: undefined reference to `_imp____glewGenerateMipmap'
W:/GoogleDrive/OpenGL Projects/CL_GL/main.cpp:234: undefined reference to `_imp____glewUseProgram'
W:/GoogleDrive/OpenGL Projects/CL_GL/main.cpp:236: undefined reference to `_imp____glewGetUniformLocation'
W:/GoogleDrive/OpenGL Projects/CL_GL/main.cpp:237: undefined reference to `_imp____glewGetUniformLocation'
W:/GoogleDrive/OpenGL Projects/CL_GL/main.cpp:238: undefined reference to `_imp____glewGetUniformLocation'
W:/GoogleDrive/OpenGL Projects/CL_GL/main.cpp:239: undefined reference to `_imp____glewGetUniformLocation'
....
Any idea what I am doing wrong?
请先登录再写评论。
Please take a look at the related StackOverflow discussion. Basically, something like the following should be enough:
OK got slightly further now but the issue I am getting is in the actual cmake creation:
Output: