I have been programming with C++ using notepad on Windows, and want to use GLFW. All the guides for setting up GLFW I have found use Visual Studio, is this the only way to set it up?
Visual Studio is certainly the easiest way to build C++ projects on Windows, but there are other options.
You can continue to use notepad to edit your source code, and if you use cmake you can even ignore the visual studio project entirely and build on the command line. However you’d be missing out on some of the more advanced debugging features Visual Studio has.
You can use the free Visual Studio Community version (see the notes on who can use it at the end, but it’s free for individuals and small companies).
I use GNU/Linux and FreeBSD, but I keep a Windows partition just to check for compatibility of my OpenGL / GLFW applications. I never used Visual Studio, not even on Windows, and you can certainly do the same as well. In fact, the editor / IDE you use is irrelevant. Visual Studio just “automates” the process making you think there is no GLFW (or other libraries) programming without it.
Now, what I do to work with OpenGL, GLFW, and other libraries on Windows is to install MinGW-w64 and set up my libraries accordingly. You can just download MinGW-w64 and the GLFW binary for Windows, extract them somewhere, then update your system %PATH%
permanently. I don’t like the last part of it. In my opinion, it is better to make your system be aware of the libraries only when you need them. The following batch file sets a main working directory where MinGW and libraries are located, then starts an editor / IDE to work with (in my case that’s Emacs but like I said in can be whatever):
@echo off
set WORKDIR=<path of your main working directory>
set MinGW=%WORKDIR%\mingw64
set USR_DIR=%WORKDIR%\usr
set PATH=%MINGW%\bin;%USR_DIR%\include;%USR_DIR%\lib;%USR_DIR%\bin;%PATH%
cd %WORKDIR%
echo MinGW-w64 DEVELOPER ENVIRONMENT
echo MinGW: %MINGW%
echo usr: %USR_DIR%
<path to your editor/IDE executable>
The main directory can be whatever you like. Under it, there is a mingw64
directory containing the extracted MinGW-w64 distribution, a usr/include
directory containing GLFW header files, and a usr/lib
directory containing GLFW’s *.dll
/ *.a
binaries (both extracted from the GLFW binaries for Windows).
If you want your system to always be aware of the libraries you installed, all you need to do is to set your %PATH%
instead. I am not sure that’s the best way to proceed, especially on Windows where most applications are usually statically linked, but that’s most people do I guess. Also, there are other compiler options instead of MinGW-w64 (TDM-GCC, for example, or even a more “unified” envioroment such as Msys2, which contains GLFW in its repository).