1
votes

I am using Visual Studio for C++. I have tried to link GLFW in Visual Studio. The steps I went through are as follows:

  1. Specify include directories under VC++ properties.
  2. Specify the library directories under VC++ properties.
  3. Add the .lib file in additional dependencies under Linker -> Input

Visual Studio recognises the header #include <GLFW/glfw3.h> and recognised glfwInit() but when glfwInit() is called it causes the build to fail. I get this build error:

LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library

I then also get some unresolved externals:

LNK2019 unresolved external symbol __imp__vsnprintf referenced in function __glfwInputError
LNK2001 unresolved external symbol __imp__vsnprintf
LNK2019 unresolved external symbol __imp__sscanf referenced in function _parseVersionString
LNK2001 unresolved external symbol __imp___vsnprintf
LNK1120 3 unresolved externals
1
The main solution is to use the same runtime library for everything.Cheers and hth. - Alf
I downloaded GLFW, ran cmake to generate Visual 2015 projects (which it did by default), opened the VS solution, built the GLFW library and two of the example programs. E.g. the "windows" example project uses "Multi-threaded Debug DLL (/MDd)" and "Multi-threaded DLL (/MD)" for respectively debug and release builds. Instead of adding lib file in project properties I think I'd just add a dependency on the GLFW project. I have no idea what the ZERO_CHECK project is (that's another dependency for example program). Probably some CMake thing?Cheers and hth. - Alf

1 Answers

3
votes

Sneaky... when I downloaded GLFW it had multiple lib folders (for the different releases) and only one include folder. I assumed that the include folder would work for all of the lib folders because there was only one. However that was not the case, the include folder only worked for the latest lib folder and I tried to use the 2013 GLFW instead of the latest 2015 GLFW lib folder with the include folder to no avail. I was using 2013 GLFW because that was the version the tutorial series I was watching used if you were wondering.