Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gcc cannot find -lglfw3

Tags:

c

gcc

glfw

I'm on a linux system (arch linux specifically) and I'm trying to compile the introduction project from the official glfw page but I cannot seem to get gcc to compile it. If anyone doesn't know what I'm talking about it's this.

Also this is how I'm trying to compile it:

gcc -Iinclude test.c -o test -lglfw3 -lm -lGL -lGLU

and it gives me the following errors:

/usr/bin/ld: cannot find -lglfw3

collect2: error: ld returned 1 exit status
like image 850
zee Avatar asked May 10 '17 05:05

zee


2 Answers

I completely forgot about this question until I got a notification for it. For me the solution was to not use -lglfw3 but rather use -lglfw

like image 147
zee Avatar answered Sep 26 '22 14:09

zee


If you've installed pkg-config, and glfw3.pc is in the search path, try:

gcc -Iinclude test.c -o test `pkg-config --libs glfw3` -lm -lGL -lGLU

If you only have the static build, use: pkg-config --static --libs glfw3, which will add the dependencies that libglfw3.a requires.

like image 40
Brett Hale Avatar answered Sep 26 '22 14:09

Brett Hale