Compiling test program for Linux x86

The following worked for me.

I have the directory structure as before but with a new directory for the example code.

/home/doug/projects/glfw/
/home/doug/projects/glfw_build/
/home/doug/projects/glfw_example/

My example code is:

#include <iostream>
#include <GLFW/glfw3.h>

int main()
{
    if (!glfwInit())
        std::cout << "Failed" << std::endl;
    else
        std::cout << "Success" << std::endl;

    return 0;
}

In a file called main.cpp

To compile this from a cmd prompty opened in glfw_example directory I used:

g++ test.cpp -o test -I../glfw/include -L../glfw_build/src -lglfw3 -ldl -lX11 -lpthread

This was on Ubuntu but I think you should have the same requirements on Mint. For OpenGL use just add -lGL to link to OpenGL. With that I was able to edit test.cpp to add the code from https://www.glfw.org/documentation.html and compile, link and run the test code getting a black window as expected.

2 Likes