Search code examples
c++macosboostmakefilemacos-sierra

"fatal error: boost/regex.hpp: No such file or directory" when trying to compile C++ program using a makefile


I am trying to compile a piece of open source software called "SPECIES Identification of Taxonomic Mentions in Text". I am on MacOS.

I downloaded the source code (which can be found here), moved into the directory and used the command make to compile. This is the error returned:

g++ -fpic -pthread -Wall -O3 -o organisms organisms.cxx -lm -lboost_regex
In file included from batch_tagger.h:5:0,
                 from organisms.cxx:3:
tagger.h:7:27: fatal error: boost/regex.hpp: No such file or directory
compilation terminated.
make: *** [organisms] Error 1

I installed the C++ boost library using brew install boostand tried the above steps again (it did not work).

I tried dropping the boost directory into the directory containing the source code (it did not work).

Any suggestions/help?


Solution

  • You need to tell the compiler where to find boost headers.

    You need to use the include path option to specify where the boost headers can be find, use -I/path/to/boost/include.

    Then include the file using #include <boost/regex.hpp> from your code.