13

While including boost headers, I am getting not found error like the following-

 fatal error: boost/config.hpp: No such file or directory
 #include <boost/config.hpp>

I am using Mac OS X 10.9, and installed boost through brew. I can see all the boost headers at /usr/local/include/boost folder. How can I solve this problem?

Thanks in advance.

Morison
  • 1,145
  • 3
  • 18
  • 35

3 Answers3

13

Assuming that /usr/local/include/boost/config.hpp exists, you need to add /usr/local/include to the compiler include search path; for gcc you can do this by adding -I /usr/local/include to the command line (or relevant part of the makefile).

What compiler are you using, and did you install it via homebrew?

Phil Lello
  • 8,377
  • 2
  • 25
  • 34
  • I installed GCC 4.9 using homebrew. Is there any way to check the include directories associated with GCC? Since /usr/local/include is the default location for homebrew header files, I thought GCC would automatically get the header files from there. – Morison Jan 27 '15 at 01:24
  • I just found ways to check include path(s) from http://stackoverflow.com/questions/19852199/view-default-include-path-of-c-headers-in-mac-os-x-by-gcc-v ... And /usr/local/include is there. – Morison Jan 27 '15 at 01:32
2
  • make sure to use the right compiler - just gcc gets the wrapper around Apple's clang, /usr/local/bin/gcc-4.9 is what you installed with brew
  • did you add an -I /usr/local/include to your compilation?
  • as already written, a full dump of the error message would be helpful
schroder
  • 181
  • 1
  • 3
1

Goto the following folder and find the installed boost library folder. I paste mine as an example folder path;

/usr/local/Cellar/boost/1.67.0_1

You need to find the most recent boost folder. If not there, you should install the boost library via brew

brew install boost

I'm assuming that you are using Xcode for your project. After the preceding steps, you need to add correct boost folder paths to your Xcode project. Open your Xcode project goto "Header Search Paths" and add the boost folder's parent folder path. Check the screenshot that I attached (ss-1 ss-1).

e.g. /usr/local/Cellar/boost/1.67.0_1/include/ for the Header Search Paths (ss-2 ss-2)

Also, you need to add Library Search Paths in your Xcode project. e.g. /usr/local/Cellar/boost/1.67.0_1/lib/ for the Library Search Paths (ss-3 ss-3)

alp tuğan
  • 26
  • 5