Problems installing GLFW - Visual Studio 2015


Hi everyone!, I have spent hours trying to compile the following example.
Steps I followed with both flavours, 32 and 64 bits.

1- Downloaded pre compiled binaries, unzipped them in a GLFW folder.
2- I set the include directories pointin to the carpet that contains the .h
3- I set the library directory pointing to where the .dll are.
4 - linker - inputs: added the following libs: opengl32.lib, glfw3.lib, glfw3dll.lib.
5- I copy the library file to where my main.cpp file is (project folder) - glfw3.dll

#define GLFW_BUILD // I commented  this line, it doesn´t change anything

#include <GLFW/glfw3.h>

int main(void)
	GLFWwindow* window;

	/* Initialize the library */
	if (!glfwInit())
		return -1;

	/* Create a windowed mode window and its OpenGL context */
	window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);
	if (!window)
		return -1;

	/* Make the window's context current */

	/* Loop until the user closes the window */
	while (!glfwWindowShouldClose(window))
		/* Render here */

		///* Swap front and back buffers */

		///* Poll for and process events */

	return 0;

However I have these kind of messages:

  • cannot open source file “GLFW/glfw3.h” GLFW32b c:\Users\kovicic\Documents\Visual Studio 2015\Projects\GLFW32b\GLFW32b\main.cpp
  • identifier “GLFWwindow” is undefined GLFW32b c:\Users\kovicic\Documents\Visual Studio 2015\Projects\GLFW32b\GLFW32b\main.cpp 8
  • the same as the line above for every GLFW function.

I´ve been followed any tutorial I´ve seen. Nothing seems to help.
I compiled the source (CMake) and generate the libraries, no change though.

SO: Windows 7 Ultimate 64 bits

Any ideas? I appreciate too much any hint. Is frustrating spending more time trying to set up a library rather than trying to learning.
Thanks in advance.


This error means that you have not set include path to correct folder.
For example, If your glfw3.h file is in C:\MyFolder\GLFW\glfw3.h location, that means your include path must be set to C:\MyFolder. It can be also a relative path from folder where is your project file (vcxproj).

You don’t need to define GLFW_BUILD. It is used only internally in glfw when building it from source.
And you need only one of these libraries - glfw3.lib, glfw3dll.lib. Not both of them. One is for static linking, other is for dynamic.


Thanks for your reply @mmozeiko. Actually I set the directory as I stated in my previous post, I checked and it points to the right one.
For instance, in the example you mentioned, I “set” the include directory to:

The closer I´ve been is with the x64 version, it compiles, but it throws the following errors:

Unloaded 'C:\Windows\System32\xinput1_3.dll'
'GLFWTest.exe' (Win32): Unloaded 'C:\Windows\System32\dinput8.dll'
'GLFWTest.exe' (Win32): Unloaded 'C:\Windows\System32\hid.dll'
'GLFWTest.exe' (Win32): Unloaded 'C:\Windows\System32\winmm.dll'

However, I have these files twice under Windows, for the 32 and 64 version.
(Actually I commented out GLFW_BUILD, nothing changed).


For instance, by doing the same procedure I can run freeglut examples. So, I don´t tend to think is something related with the include/library directories. I am totally clueless actually.


Are you sure you have glfw3.h file in C:\MyFolder\GLFW\GLFW\glfw3.h location?
If it is in C:\MyFolder\GLFW\glfw3.h location you need to use C:\MyFolder and NOT C:\MyFolder\GLFW as include path. If you include path is X, and you say #include <a\b.h> then compiler will look for this file in “X\a\b.h” location.

Unloaded messages in output window are normal. On 64-bit Windows 64-bit dll files are inside C:\Windows\System32 folder.


@mmozeiko Thanks for your response. My bad I didn´t clarify things correctly.
If I add as the include library the C:\MyFolder\GLFW folder, then in my code I write without the folder prefix name:
#include <glfw3.h>

In case I put C:\MyFolder in the include library, my code is in this way:
#include <GLFW/glfw3.h>

I am sure I am pointing to the correct place since glfw3,h is under the C:\MyFolder\GLFW directory.
I tryed both ways, it doesn´t compile well for 32 bits, claiming it couldn´t find the .h files.

I am almost sure my error isn´t about .h locations, but I don´t know what else to try. I even updated visual c ++
common tools.

Step 2: I tryed the 64 bit precompiled libraries.
As for the messages about complaining that it couldn´t load some 32 bits files, amazes me, because all these files are there. Why they cannot be loaded?
(I come from linux, I didn´t know the 64 bit dll files were under System32…confusing to say the least).
I seemed it´s the cause for not to make the example work.