title: Undefined reference to GLEW functions when linking GLEW's static binary with CMake
body: <h1>Problem </h1>
  <p><code>glew32s.lib</code> 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 <code>glewInit()</code>.</p>
  <blockquote>
  <p>CMakeFiles\NoGameEngine.dir/objects.a(window.cpp.obj):window.cpp:(.text+0x15d): undefined reference to `glewInit'</p>
  </blockquote>
  <p>However in my top-level <code>CMakeLists.txt</code> I have linked the <code>glew32s.lib</code> through:</p>
  <pre><code>target_link_libraries( ${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/Dependencies/glew32s.lib)
  </code></pre>
  <p>I am completely clueless to why I am getting this undefined reference error. Note I have also declared the compile option <code>-DGLEW_STATIC</code>.</p>
  <h1>What I have tried </h1>
  <p>Using another way to link the library:</p>
  <pre><code>target_link_directories( ${PROJECT_NAME} PRIVATE Dependencies)
  target_link_libraries( ${PROJECT_NAME} PRIVATE glew32s.lib)
  </code></pre>
  <p>However I get the following errors:</p>
  <blockquote>
  <p>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</p>
  </blockquote>
  <h1>Resources</h1>
  <p>CMakeLists.txt:</p>
  <pre><code>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(&quot;OpenGL Correctly Found&quot;)
  else (OPENGL_FOUND)
    MESSAGE(&quot;OpenGL environment missing&quot;)
  endif()
  
  project(NoGameEngine)
  
  
  include_directories( ${OPENGL_INCLUDE_DIRS} ${includeFiles-Core} ${includeFiles-Depend})
  
  set( GLFW_BUILD_DOCS OFF CACHE BOOL  &quot;GLFW lib only&quot; )
  set( GLFW_INSTALL OFF CACHE BOOL  &quot;GLFW lib only&quot; )
  
  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)
  </code></pre>
  <p>Directory Hierarchy:</p>
  <p>Root:</p>
  <ul>
  <li>build</li>
  <li>Dependencies
  <ul>
  <li>GLFW</li>
  <li>include
  <ul>
  <li>GL</li>
  </ul>
  </li>
  <li>glew32s.lib</li>
  </ul>
  </li>
  <li>NoGameEngine-core
  <ul>
  <li>include</li>
  <li>src</li>
  </ul>
  </li>
  <li>CMakeLists.txt</li>
  </ul>