How compile GLFW in Linux?


#1

I’m trying to build GLFW 3.2.1 on my Linux (Fedora) to use in the CodeBlocks IDE. The steps I’m following are: 1- In the extracted folder, I execute the “cmake -DBUILD_SHARED_LIBS=ON .” Command. 2- In the same folder, I execute the command “sudo make install”.

I do not know if that’s the right method. Now I need to show CodeBlocks where the GLFW is. I can not get past this part. Can someone help me? (I’m following the tutorial to compile from this site: http://www.glfw.org/docs/latest/compile_guide.html#compile_compile)


#2

I don’t know Code::Blocks well enough to give a full answer, but perhaps the following will help:

First off the tutorial you’ve read is for compiling GLFW itself, you should now move on to reading how to build an application with GLFW.

If you use cmake for your project you can then output a Code::Blocks project, see GLFW + Code::Blocks + Ubuntu

The Code::Blocks wiki has a section on GLFW however it’s a little confusing.

It appears there the Code::Blocks ‘template’ for GLFW might be out of date, see https://bbs.archlinux.org/viewtopic.php?id=177036

You might also want to ask this question on the Code::Blocks forum as it’s more about how to use Code::Blocks than about GLFW.


#3

I used the following steps to compile glfw on my machine:
1- Unzipped the zip file I downloaded from the site
2- In the folder generated by the decompression I executed the command “cmake.”
3- in the same folder I ran the command “make”
4 - lastly I ran the command “sudo make install”

Is this the right way to compile GLFW?


#4

If you used the commands as per your first post:

cmake -DBUILD_SHARED_LIBS=ON .
make

Then you have should have compiled glfw, if cmake or make didn’t report any errors. After the cmake command you should have seen something like:

-- build files have been written to: a/path/somewhere

Note that GLFW cmake will output a few -- Could NOT find X which is fine as some dependencies are not always required (for example Vulkan and Doxygen). After running make you should see lots of output without errors.

You should be able to see a folder src with some files called libglfw.so* (some are links to the real file). If you have these created you can proceed to building your application.

The command sudo make install is only needed to install the library to your system so you can more easily use it to compile multiple programs.