Mike Glaz
Mike Glaz

Reputation: 5392

Compiling OpenGL program with GLFW3

I installed GLFW3 and am trying to compile my OpenGL program with the following:

g++ -std=c++11 main.cpp -lGL -lGLEW -lglfw3 

But here's the library error I get:

/usr/bin/ld: cannot find -lglfw3
collect2: error: ld returned 1 exit status

I also tried with pkg-config:

g++ `pkg-config --cflags glfw3 glew` -o myprog main.cpp `pkg-config --static --libs glfw3 glew`

it compiles but when I run myprog it says it can't find libglfw.so.3

But it is located in /usr/local/lib

Upvotes: 3

Views: 2743

Answers (2)

SeveneduS
SeveneduS

Reputation: 21

I had the same problem. In my case was usefull following steps:

  1. Download glfw source code
  2. unzip it
  3. cd glfw_folder
  4. cmake . (with dot)
  5. make
  6. sudo make install

To check, copy and paste following command in your console "whereis libglfw3". you should have output like this one: "libglfw3: /usr/local/lib/libglfw3.a" (or another path after ":").

My config: VAIO Pro 13/Ubuntu 16.04 LTS/ Intel HD4000.

P.S.: Yes, I'd tryed "sudo apt-get install libglfw3" and all dependenses.

Upvotes: 2

Mike Glaz
Mike Glaz

Reputation: 5392

http://www.brandonfoltz.com/2012/12/compile-glfw-on-ubuntu-and-fix-libglfw-so-cannot-open-error/

Ubuntu installs libglfw.so.3 in /usr/local/lib so you have to add this line to /etc/ld.so.conf

Upvotes: 2

Related Questions