Felyner
Felyner

Reputation: 133

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

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.

Upvotes: 12

Views: 26680

Answers (1)

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).

Upvotes: 18

Related Questions