Linking GLFW to Eclipse CDT

Hi, I am new to Linux and I am having a hard time to figure out how to link the GLFW library to my Eclipse CDT project. I installed the library on my system and now I have the header file(glfw3.h) in the /usr/local/include/GLFW directory and I have the library(libglfw3.a) in the /usr/local/lib directory. Please not that I used the same names and paths specified below in my attempt to link them in Eclipse. So first I went into my Project->Properties->C++ build->Settings and under the GCC C++ Compiler->Includes tab I specified the include path(-I) and the name of the file(-include). I then went into the GCC C++ Linker->Libraries tab and I did the same thing for the .a file. I included the header file to my project and all went fine but I still have this weird error that prevents me from compiling. It says "unresolved inclusion: </home/UserName/Projects/C++_Projects/Test GLFW/Debug/glfw3>. I have been looking around to fix this error for days and this one is the most recurrent that I have witnesses in my multiple attempts. I am sorry if this question is silly but it is quite frustrating to have so much difficulties to do something I was doing just fine on Windows.

Thank you!
Last edited on
-include is the wrong option. The argument is a file name, and the contents of that file are injected before compilation as if a #include directive appeared on the first line of the TU's primary source file. You should instead use a preprocessor directive with a relative path to include the file.

You should not need to specify include (that's -I) or library paths (that's -L) unless you installed the library to a unconventional location. Instead, you should be able to use a relative path in the include statement and link with -lglfw3.
Last edited on
Hi there, thanks for your response! You were right, I did not need to specify include or library paths. I only included the header file using a preprocessor directive but I am still having an issue. I went into the settings and I only specified the name of the library file I want to use(that is glfw3) and did not specify any paths. I then tried to write a simple test code and when I tried to build it, I had a ton of 'undefined references' to glfw3 functions. Is there something I am missing here?

Thank you so much
Hi, I found a solution to my problem. GLFW being a a library for OpenGL, it obviously used some X11 functions and other libraries so I had to include the these to my project as well.

Thanks for your help!
Topic archived. No new replies allowed.