[Linux] How compile basic example with GLFW 3.2.1?

Hi, I’m new to GLFW and plan to write some code including Vulkan. I’m using Linux Mint 18.1 as OS. In standard repository there is only version 3.1.2 (why not current version? is there a repository which contains it?).
For some sample code:
https://vulkan-tutorial.com/code/base_code.cpp
I need at least version 3.2. GLFW_NO_API, GLFW_FALSE and Vulkan support introduced there. If I exchange those constants with numbers, I can compile it with:
g++ ./main.cpp -lglfw -std=c++11

For further examples I need version 3.2 or higher, so I downloaded http://www.glfw.org/download.html and did cmake. Without known errors, I can run all programs in folder tests (including vulkan) and examples.

But how can I build the example code from above? In the downloaded and cmaked GLFW folder there are some header files but can’t find any libraries. Do I need to build them first? Where? How?. Which folder need to be included? How can I install it at the system?
What would be the correct way to compile the example?
g++ ./main.cpp -lglfw3 -std=c++11 -L??? -l?? -I??

At http://www.glfw.org/docs/latest/compile_guide.html#compile_compile there is some section “Compiling the library” but don’t know what to do with “Go ahead and compile the actual GLFW library with these files,”. (Also could not figure out to run cmake GUI. Havn’t used cmake that often.)

Thanks for reading

Hi, first off this will be a short reply as I’m v.busy today.

The version installed with Linux Mint is the version Linux Mint installs, the GLFW team have no control over that.

If you can run the tests and examples it looks like you’ve been able to build glfw with cmake, so have a compiled library of the most recent version.

For building applications with GLFW see the build guide, which is different from the compiling GLFW guide.

If you’re still stuck, a simple approach to making progress is to alter the vulkan.c test and then use the same steps you used with cmake to rebuild the vulkan test code.

If you’re still stuck come back here and I’ll try to help further.

Hi, thanks for response. I meant the version in repository you can download with sudo apt-get install libglfw3.

I already looked in build guide but there is only the information “Link with the right libraries” but not where or how. Also did some look at cmake files but without effort.

But it was a good idea to look at a specific program, thanks for that hint. The make file in tests folder redirects to build.make in tests/CMakeFiles/vulkan.dir folder. Which redirects again to link.txt in same folder. There is the information I searched for:
/usr/bin/cc CMakeFiles/vulkan.dir/vulkan.c.o -o vulkan -rdynamic …/src/libglfw3.a -lvulkan -lrt -lm -ldl -lX11 -lpthread -lXrandr -lXinerama -lXxf86vm -lXcursor
So library files seems to be in source folder and need to be linked with rdynamic.
In build.make it also redirect to flags.make which include:
-I/home/username/Downloads/glfw-3.2.1/deps -I/home/username/Downloads/glfw-3.2.1/include
So all together for vulkan example from vulkan tutorial:
g++ ./main.cpp -std=c++11 -rdynamic /home/username/Downloads/glfw-3.2.1/src/libglfw3.a -lvulkan -lrt -lm -ldl -lX11 -lpthread -lXrandr -lXinerama -lXxf86vm -lXcursor -I/home/username/Downloads/glfw-3.2.1/deps -I/home/username/Downloads/glfw-3.2.1/include
Some not needed (for me):
g++ ./main.cpp -std=c++11 -rdynamic /home/username/Downloads/glfw-3.2.1/src/libglfw3.a -lvulkan -ldl -lX11 -lpthread -lXrandr -lXinerama -lXxf86vm -lXcursor -I/home/username/Downloads/glfw-3.2.1/include
works as well.

I’m sure that is not the best way to build a program but it’s working (at least for this example).

Edit: To install to system, after downloading doing cmake and make. I need to do sudo make install to install it at my system (did not knew about that). After this I can do:
g++ -std=c++11 main.cpp `pkg-config --static --libs glfw3` -lvulkan
as well