Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Including headers from /usr/local/include and libraries from /usr/local/lib

Tags:

c++

I have just installed GLFW on OS X 10.9. The headers were installed to /usr/local/include and the library was installed in /usr/local/lib.

I am wondering what else I would have to do to get my C++ program to include the headers like #include "GLFW/glfw3.h" rather than specifying the whole path like #include "usr/local/include/GLFW/glfw3.h".

Same thing goes for the library because as of now I can't even link the library using -lglfw3. Thanks in advance.

like image 990
Felyner Avatar asked Aug 28 '14 04:08

Felyner


1 Answers

You would pass -I /usr/local/include to the compiler as preprocessor flag, and -L /usr/local/lib to the compiler as linker flag. So to build a single source application small.cc compile it as

  g++ -Wall -I /usr/local/include -L /usr/local/lib \
      small.cc -o small -lglfw3

If building with make just have

  CXXFLAGS += -I/usr/local/include
  LDFLAGS += -L/usr/local/lib

in your Makefile

If using shared libraries, add once /usr/local/lib to /etc/ld.so.conf and run ldconfig (at least on Linux).

like image 115
Basile Starynkevitch Avatar answered Sep 18 '22 17:09

Basile Starynkevitch