Friday, August 14, 2015

Building GLEW and GLFW libraries for static linking in Visual Studio

It seems the prebuilt binaries for GLEW and GLFW are not really suitable for static linking when using static (i.e. the non-DLL versions) of the VC++ runtime libraries.

Here's a short how-to for compiling GLEW and GLFW for this usage scenario:

1.) Building GLEW

  • download and extract GLEW source code package from http://glew.sourceforge.net/
  • goto /build/vc10 (or vc12)
  • open glew.sln
  • select desired build configuration (debug or release)
  • select glew_static project
  • set C/C++ Code Generation options for glew_static project: Select correct runtime library
  • Build project
  • Result: glew32s(d).lib
2.) Building GLFW
  • download and extract GLFW source code package from http://www.glfw.org/download.html
  • download and extract CMake win .zip from http://www.cmake.org/download/
  • run CMake GUI (i.e. bin/cmake-gui.exe)
  • select GLFW source root directory
  • choose output directory ("Where to build the binaries"), can be same as above
  • click "Configure"
  • select compiler
  • deselect "USE_MSVC_RUNTIME_LIBRARY_DLL" option
  • make sure "BUILD_SHARED_LIBS" is also disabled
  • click "Configure" again
  • click "Generate"
  • open generated GLFW.sln (located in output directory as specified above)
  • select desired build configuration (debug or release)
  • set C/C++ Code Generation options for glfw project: Select correct runtime library
  • Build project
  • Result: glfw3.lib


No comments:

Post a Comment