Problem
glew32s.lib is not linking correctly with the main executable. When building with MakeFile given by CMake, an error occurs stating that I have an undefined reference to glewInit().
CMakeFiles\NoGameEngine.dir/objects.a(window.cpp.obj):window.cpp:(.text+0x15d): undefined reference to `glewInit'
However in my top-level CMakeLists.txt I have linked the glew32s.lib through:
target_link_libraries( ${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/Dependencies/glew32s.lib)
I am completely clueless to why I am getting this undefined reference error. Note I have also declared the compile option -DGLEW_STATIC.
What I have tried
Using another way to link the library:
target_link_directories( ${PROJECT_NAME} PRIVATE Dependencies)
target_link_libraries( ${PROJECT_NAME} PRIVATE glew32s.lib)
However I get the following errors:
C:/MinGW64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/PROGRA~4/C__~1/Projects/GAMEPR~1/NOGAME~1/DEPEND~1/glew32s.lib when searching for -lglew32s C:/MinGW64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/PROGRA~4/C__~1/Projects/GAMEPR~1/NOGAME~1/DEPEND~1/glew32s.lib when searching for -lglew32s C:/MinGW64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/PROGRA~4/C__~1/Projects/GAMEPR~1/NOGAME~1/DEPEND~1\glew32s.lib when searching for -lglew32s C:/MinGW64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lglew32s
Resources
CMakeLists.txt:
cmake_minimum_required(VERSION 3.23.)
set(CMAKE_CXX_STANDARD 17)
set(SourceFiles-Core
NoGameEngine-core/src/main.cpp
NoGameEngine-core/src/graphics/window.cpp
)
set(includeFiles-Core NoGameEngine-core/include)
set (includeFiles-Depend Dependencies/include)
add_compile_options(-DGLEW_STATIC)
find_package( OpenGL REQUIRED )
if (OPENGL_FOUND)
MESSAGE("OpenGL Correctly Found")
else (OPENGL_FOUND)
MESSAGE("OpenGL environment missing")
endif()
project(NoGameEngine)
include_directories( ${OPENGL_INCLUDE_DIRS} ${includeFiles-Core} ${includeFiles-Depend})
set( GLFW_BUILD_DOCS OFF CACHE BOOL "GLFW lib only" )
set( GLFW_INSTALL OFF CACHE BOOL "GLFW lib only" )
add_subdirectory( Dependencies/GLFW )
add_executable(${PROJECT_NAME} ${SourceFiles-Core})
target_link_libraries( ${PROJECT_NAME} PRIVATE ${OPENGL_LIBRARIES} glfw)
target_link_libraries( ${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/Dependencies/glew32s.lib)
Directory Hierarchy:
Root:
- build
- Dependencies
- GLFW
- include
- GL
- glew32s.lib
- NoGameEngine-core
- include
- src
- CMakeLists.txt