# How compile GLFW in Linux?

**URL:** <https://discourse.glfw.org/t/how-compile-glfw-in-linux/1123>\
**Category:** support\
**Created:** [May 21, 2018, 11:27pm UTC](https://discourse.glfw.org/t/how-compile-glfw-in-linux/1123 "2018-05-21T23:27:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![GateJkin](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/gatejkin/32/183_2.png) [@GateJkin](https://discourse.glfw.org/u/GateJkin)\
**Post date:** [May 21, 2018, 11:27pm UTC](https://discourse.glfw.org/t/how-compile-glfw-in-linux/1123/1 "2018-05-21T23:27:29Z")

</div>

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](http://www.glfw.org/docs/latest/compile_guide.html#compile_compile))

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [May 22, 2018, 11:28am UTC](https://discourse.glfw.org/t/how-compile-glfw-in-linux/1123/2 "2018-05-22T11:28:08Z")

</div>

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](http://www.glfw.org/docs/latest/build_guide.html).

If you use cmake for your project you can then output a Code::Blocks project, see [GLFW + Code::Blocks + Ubuntu](http://discourse.glfw.org/t/glfw-code-blocks-ubuntu/792/2)

The [Code::Blocks wiki has a section on GLFW](http://wiki.codeblocks.org/index.php/Using_GLFW_with_Code::Blocks) 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](https://bbs.archlinux.org/viewtopic.php?id=177036)

You might also want to ask this question on the [Code::Blocks forum](http://forums.codeblocks.org/) as it’s more about how to use Code::Blocks than about GLFW.

---

<div class="post-metadata">

**Author:** ![GateJkin](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/gatejkin/32/183_2.png) [@GateJkin](https://discourse.glfw.org/u/GateJkin)\
**Post date:** [May 22, 2018, 9:44pm UTC](https://discourse.glfw.org/t/how-compile-glfw-in-linux/1123/3 "2018-05-22T21:44:07Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [May 23, 2018, 10:05am UTC](https://discourse.glfw.org/t/how-compile-glfw-in-linux/1123/4 "2018-05-23T10:05:39Z")

</div>

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](http://www.glfw.org/docs/latest/build_guide.html).

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.
