Last night, I started a C++ project intending to use GLFW. However, I quickly noticed a great lacking in setup documentation. So much so that I had to bring in a college with more C++ experience to teach me a few things about linking libraries to C++ projects. The process isn't overly complicated, but if you haven't done it before, it can be quite daunting. So, for the benefit of developers seeking how to setup GLFW in Visual Studio 2010(will most likely be the same for VS2008), I made a 4 step guide to setting up and linking GLFW to your Visual Studio 2010 C++ projects.
Step 1: Download the latest binary archive of GLFW for Windows.
-It is important to acquire the binary, and not the source download for a quick and easy instillation. The binary release is pre-compiled and ready to go.
-http://www.glfw.org/download.html
Step 2: Start a new Empty Project in Visual Studio 2010
Step 3: Add GLFW files to your system. This process involves copying and pasting 2 files into your Visual Studio instillation, and 1 file into you System32 folder. Be sure to double check yourself on this step as it is the most important.
-GLFW_Download/include/GL/glfw.h
-Move to: path/to/MSVS10/VC/include
-GLFW_Download/lib-msvc100/release/GLFW.lib
-Move to: path/to/MSVS10/VC/lib
-GLFW_Download/lib-msvc100/release/GLFW.dll
-Move to: C:/Windows/System32
Users of your applications will not need any of these files. Only machines developing applications with GLFW need them. Once step 3 is complete, we must now link GLFW to your newly created project.
Step 4: With your new project opened in visual studio, go to:
Project->ProjectName Properties->Configuration Properties->Linker->Input
-Under Additional Dependencies, ensure the 4 following properties are added
-GLFW.lib;
-opengl32.lib;
-kernel32.lib;
-user32.lib;
-glu32.lib; (You will thank me later for including this)
You will at least have to type in GLFW.lib;, I personally had to also type in opengl32.lib; as my instillation of Visual Studio was new. Once you ensure that all for libraries are added to Additional Dependencies, you can click the "Ok" button. GLFW should now be linked to your project. Follow the examples in the great documentation(minus a setup guide) GLFW provides, and you should be developing a game engine in no time. I hope this guide has helped some developers out there!
33
Thank you very much! From what I can tell so far, this seems to have worked as opposed to most other vague tutorials there are about GLFW.
ReplyDeleteYeah, I ran into the same issues when I began deving with GLFW. It seems to be a recurring issue that software technologies are completely under documented. I would never release a product like this without thorough documentation. Anyway, glad I could help.
DeleteThank you, seems to be working now, I can finally start coding instead of setting up!
ReplyDeletehah! glad I could help!
DeleteYOU ARE MY HERO
ReplyDeleteHaha. You guys are making me want to continue my C++ engine! Glad I can help!
DeleteVery nice. Thanks
ReplyDeleteHaha, damn, took me about 3 hours of googling until I found this, thanks a lot man! Pretty much the same in VS2012 also, just be sure to add the right .lib and .dll : )
ReplyDeleteApparently I am the one retard that does not get it on the first try.
ReplyDelete"unresolved external symbol _glfwGetWindowParam referenced in function _mai"
Could it be that I don't have opengl.lib? If I don't do I need to download both a .dll and a .lib?
Did you ever figure this out?
DeleteThis comment has been removed by the author.
DeleteI had the same problem and solved it as follows:
Delete1. Downloaded the 32-bit binaries.
2. Copied "GLFW" folder under "include" to "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include". (I'm using VS2013 Ultimate)
3. Copied "glfw3.lib" and "glfw3dll.lib" under "lib-msvc110" to "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\lib"
4. Copied "glfw3.dll" under "lib-msvc110" to "C:\Windows\System32"
5. Created a blank C++ project in Visual Studio
6. Under Project->ProjectName Properties->Configuration Properties->Linker->Input, I added "glfw3.lib" and "glfw3dll.lib" to "Additional Dependencies"
7. Added the following lines at the top of my source file:
#include
#define GLFW_DLL
#include
First include will have GL\glew.h and the second will have GLFW\glfw3.h between < and >
DeleteHi, I'm still getting the same "unresolved external symbol' error when I try to call glfwInit(); I've followed your example exactly the same, and tried it with the 32-bit and 64 bit binaries. I can't think of anything else that could be wrong. I'm sure i've got all the .dll and .lib files in the right place and have included the correct folder.
DeletePlease help! I've been stuck on this for hours...it seems like a simple fix but I've looked everywhere for solutions and nothing has told me anything that I haven't already done.
Actually nevermind...I used your steps with the 32-bit binaries and it worked. I'm confused about this though. I'm running on 64-bit system, why would I need the 32-bit binary for it work?
DeleteRegardless thanks Shawn for the awesome guide and thanks fbuyukkececi for your help! Glad to be able to get started.
WOW. Nice guide. Very helpful.
ReplyDeleteThank You so much!!!
You are my hero! Words can't describe it.
ReplyDeleteI spend a whole day looking how to set up GLFW.
Now I can finally start coding.
Thanks, pal!
haha! Glad I could help!
DeleteU came at d right time
ReplyDeleteGetting several 'undeclared identifer' and 'identifier not found' errors all related to glfw constants and functions. I downloaded the most recent 32 bit binaries which include glfw3.h, glfw3native.h, glfw3.lib, glfw3dll.lib and glfw3.dll.
ReplyDeleteI put the header file glfw3.h in the Windows SDKs/.../include/gl folder. I put the lib files in the lib folder and the .dll in the System32 folder. In my linker dependencies, I have glfw3.lib and the other .libs you suggest.
I have no idea what is wrong. The CMake process has been a huge waste of time, which is why I'm using the binaries as you suggest.
Got an answer for this. The problem is the tutorial code I am following was using GLFW version 2 identifiers, which have been changed for version 3. So my project settings were right, I just needed to change the old identifiers and a few function call parameters because some signatures have changed.
DeleteGlad you got your answer :)
DeleteHi, nice 4 steps of Setting Up GLFW in Visual Studio 2010.Thanks for your support....
ReplyDelete-Aparna
Theosoft
hi
ReplyDeletehi :D
DeleteI followed your tutorial and half of my glfw commands aren't working :( Please help me mysterious coding god!!!
ReplyDeleteHah! You have Visual Studio 2010 and the recommended C++ distro correct? If your glfw commands aren't working, then a few things could be wrong. You may have missed a step or have a typo in one of the steps. I've done that one before. You also may be making the calls incorrectly. Check the API docs and ensure everything is correct. If all fails, start over and go through the process with a fine toothed comb. You will find the issue :)
DeleteThanks for the help. I have been looking for this since last night.
ReplyDeleteThank you so much!!!! For once, someone giving a straightforward answer. When I asked this question from other people, I usually got a condescending response like I was stupid or something. Now I can actually start coding instead of wasting any more time on setting up!
ReplyDeleteVery glad I found this article of yours, helped me get things set up fairly quick. Next time you see that colleague of yours, give him a high five!
ReplyDeleteHi! I have been able to link all the libraries (I am putting these libraries in a separate folder in my project folder only). However, I am still getting two unresolved symbols:
ReplyDeleteError 2 error LNK2019: unresolved external symbol __dtoul3 referenced in function __glfwPlatformSetTime D:\Dropbox\HI'\Projects\TCS\Demosaicing\OpenGLLearning\Shaders\Shaders\glfw3.lib(win32_time.obj) Shaders
Error 3 error LNK2019: unresolved external symbol __ultod3 referenced in function __glfwInitTimer D:\Dropbox\HI'\Projects\TCS\Demosaicing\OpenGLLearning\Shaders\Shaders\glfw3.lib(win32_time.obj) Shaders
Error 4 error LNK1120: 2 unresolved externals D:\Dropbox\HI'\Projects\TCS\Demosaicing\OpenGLLearning\Shaders\Debug\Shaders.exe 1 1 Shaders
Can you please help.
Thanks and regards
Gaurav
This comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDelete