Search code examples
openglcompiler-errorsheader-filesglfwubuntu-20.04

Problems including GLFW header in c++ program


I need to include GLFW header in my c++ program. The installation was fine and the GLFW folder exists in my usr\include folder and g++ does look for header files in that folder. Despite that it throws an error telling me that the GLFW directory doesnt exist.

I am using sublime text as my editor and IDE and my system is Ubuntu-20.04

FOllowing is the code, the terminal command i used to compile and the error message i encountered:

#include <GLFW\glfw3native.h>
#include <iostream>

int main(int argc, char const *argv[])
{
    std::cout << "All DOne!!" << std::endl; 
    return 0;
}
g++ -g -o bin/debug/main src/*.cpp -x64 -std=c++17 -Wall -I -include -lglfw3 -lGL -lm -lXrandr -lXi -lX11 -lXxf86vm -lpthread && ./bin/debug.main
src/main.cpp:1:10: fatal error: GLFW\glfw3.h: No such file or directory
    1 | #include <GLFW\glfw3.h>
      |          ^~~~~~~~~~~~~~
compilation terminated.

I cannot tell where the problem lies. please help.


Solution

  • and my system is Ubuntu-20.04

    On Linux, the path delimiter is /, not \, so

    #include <GLFW/glfw3native.h>
    

    Note that while windows primarily uses backslash, it also accepts the forwad slash, so always using / is also the best option for cross-platform programming.