raylib»Forums
1 posts
Using raylib on Linux with codeblocks

Hi. I'm learning C programming language and trying to build an application based on raylib. In my course, we are using the codeblocks IDE. I've tried to configure my codeblocks for building and running my program based on raylib, but it is not working. I am using the ubuntu SO.

I've found this tutorial for configuring the codeblocks IDE, however, its target is windows. https://github.com/raysan5/raylib/wiki/Use-raylib-with-Code-Blocks

Could someone help me on this?

Simon Anciaux
1341 posts
Using raylib on Linux with codeblocks

You might get better help for that on the handmade network discord. I'll try to give you a direction here, but this is outside of my knowledge.

I don't know any details (I'm not on linux, not using raylib, not using codeblock), but I think you should follow Working on GNU Linux first to at least compile the lib into a static (.a) or dynamic library (.so). After that you can either install it (so that it's always available) or copy it into you project.

It's probably a good idea to try to compile the examples after to make sure it's working.

After that you can try to setup your codeblock makefile. You can have a look at the example folder makefile but if you're not familiar with make file it will not be easy to find out what you need (it's covering every OS, compiler options...).

In the tutorial you've linked, you'll need to at least change (I don't know about makefile, this will most likely not work):

  • the output to not be an .exe file;
  • c:/raylib/raylib/raylib_icon I assume this is to have some icon resource, so you need to have it point to the correct folder (doesn't seem to exist in the git repository so it might not be necessary);
  • -Ic:/raylib/raylib/src is to include (-I followed by the path) the raylib source directory in the include path, so you'll need to make that point to raylib's src directory. It's also possible that installing raylib adds that folder in the standard include directory making this unnecessary.
  • -Lc:/raylib/MinGW/bin and -Lc:/raylib/MinGW/include/GLFW are used to specify libraries folder path (-L followed by a the path) to be used by the linker. If you installed raylib those might not be necessary, otherwise you need to make them point to where you compiled the .a file. For the GLFW you might need to install GLFW3.
  • For the rest I'm not sure. You'll need -lraylib and -lglfw3. You probably need -lGL, -lX11 and -lopenal32. -lopengl32 -lgdi32 -lwinmm are windows lib so you wont need them. And you wont need subsystem,windows.