OpenGL on Fedora 33

2 minute read

Installation requirements:


Step 1: Install GLFW and GLAD

After installing GLFW,

  1. cd <source-directory>

  2. cmake -G "Unix Makefiles"

  3. sudo dnf install dnf-utils glfw

  4. make

  5. sudo make install

After installing GLAD,

  1. sudo ln -s <path/to/glad> /usr/local/include/glad
    
    # In my case,
    sudo ln -s ~/glad/include/glad /usr/local/include/glad
    
  2. You will need glad.c when compiling, so put it in the project directory or wherever you can remember.

Step 2: Compile

  1. Grab an example code from here and name it shaders.cpp.

  2. Compile shaders.cpp with:

    g++ -std=c++11 -c shaders.cpp <path/to/glad.c>
    
    # In my case,
    g++ -std=c++11 -c shaders.cpp ~/glad/src/glad.c
    
  3. Output an executable file with:

    g++ shaders.o glad.o -o shaders.exec -lGL -lglfw3 -lX11 -lpthread -ldl
    
  4. Finally execute with:

    ./shaders.exec
    

    And you should see something like this:

    triangle

Finally

If this didn't help, you should be missing more required packages and you want to google until you find an answer. I don't know anything about C/ C++, so it was kind of confusing to learn how to link stuff and whatnot, but eventually I found the answers I needed. :)

Good luck!