# Cross-platform GLFW build with CMake

I know this is probably a popular question and can be very vague, so I'm going to be as specific as possible. I don't really know how to even form this question to be able to search Google, so I came here.

I've been following the tutorials from learnopengl.com and they have been by far the best explanations I've found on modern OpenGL anywhere. After I'm done with the tutorials, I'll be making a game. I have already started working on the game engine and it works just fine on Ubuntu and Mac OS X. Building the project is done with CMake (I've found this to be the easiest). The project uses GLFW and Glad as used in the tutorial. I can post the GitHub repo if you want.

Today I started trying to figure out how to get the project to run on Windows, but don't even know where to start. Hence coming here. I plan on using Visual Studio but haven't used it since college. How do I even start making the project? I've tried building GLFW on the machine and the building the project using CMake, but I get build tool errors that I don't know how to troubleshoot. Where do I begin?

• I want to suggest to edit the question by adding what are the errors you are getting, and to avoid wording this as "What tools should I use?" and "Where do I begin?" which are off-topic. Between learnopengl and the khronos.org wiki you should have enough to get you started. You may also look for GitHub repos for refecence code. By the way, is it anything like this: OpenGL GLFW build errors OR linking errors? Edit: Also btw, khronos has good book selection. – Theraot May 5 '18 at 23:50
• That question you linked is similar. Not quite working for me right now though. I'll keep digging and post more relevant info here shortly – David May 6 '18 at 0:07
• Try it! learnopengl.com – Sveen May 6 '18 at 3:01
• @Sveen I have been haha. I just figured out how to get it working. It has taken me since I posted it until now to figure it out. I should have an update to the question with more specifics to questions I still don't know the answers to – David May 6 '18 at 3:07
• The title and the answer seem a bit far apart. You've only answered how to setup opengl. Could you edit the title/body so it's more fitting with the answer given? – Sidar May 6 '18 at 9:34

1. In order to run my project on windows, the first thing you have to do is download glfw straight from the glfw homepage. Move the resulting directory into the libraries directory in the project and rename it to win_glfw. You also need the glfw binaries in a later step.
2. Next, you need to build glfw with cmake (either the gui or the command line). The only thing you have to make sure is set correctly is the CMAKE_INSTALL_PREFIX. I set that to a folder in my directory. Others who have tried before failed if they didn't update this because it usually automatically defaults to somewhere in C:\Program Files which causes an access denied type of error.
4. Next, all you have to do is generate the CMake files for the project, open the generated .sln file, build it, and be on your way.