I'm building my c++ program with cmake on a Mac. The compiler gives me following Error:
error: boost/filesystem.hpp: No such file or directory
The line that triggers the error is the following:
#include "boost/filesystem.hpp"
or
#include <boost/filesystem.hpp>
Which of the above I use doesn't changed the Error
But in my CMakeLists.txt I include the boost headers in the following way:
FIND_PACKAGE(Boost)
MESSAGE("Boost information:")
MESSAGE(" Boost_INCLUDE_DIRS: ${Boost_INCLUDE_DIRS}")
MESSAGE(" Boost_LIBRARIES: ${Boost_LIBRARIES}")
MESSAGE(" Boost_LIBRARY_DIRS: ${Boost_LIBRARY_DIRS}")
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
Boost include dirs is filled with "/opt/local/include/" during the cmake process and this folder contains a folder boost which contains the filesystem.hpp
Boost gives the following messages while generating the Makefile, I only copied the boost part:
-- Boost version: 1.38.0
-- Found the following Boost libraries:
Boost information:
Boost_INCLUDE_DIRS: /opt/local/include
Boost_LIBRARIES:
Boost_LIBRARY_DIRS: /opt/local/lib
-- Configuring done
While running make VERBOSE=1 This line contains the error:
cd /Users/janusz/Documents/workspace/ImageMarker/Debug/src && /usr/bin/c++ -O3 -Wall -Wno-deprecated -g -verbose -I/Users/janusz/Documents/workspace/ImageMarker/src/. -o CMakeFiles/ImageMarker.dir/FaceRecognizer.cpp.o -c /Users/janusz/Documents/workspace/ImageMarker/src/FaceRecognizer.cpp /Users/janusz/Documents/workspace/ImageMarker/src/FaceRecognizer.cpp:8:32: error: boost/filesystem.hpp: No such file or directory make[2]: *** [src/CMakeFiles/ImageMarker.dir/FaceRecognizer.cpp.o] Error 1
Do you understand why the compiler isn't picking the /opt/local/include directory?
If you need more information I'm happy to provide it
First of all use
rather than
This way cmake will give you a nice error message if it doesn't find it, long before any compilations are started. If it fails set the environment variable BOOST_ROOT to /opt/local (which is the install prefix). Additionally you will have to link in the filesystem library, so you want
for later use of
Enter
at the shell to get the docs for the Boost find module in your cmake installation.
PS: An example
The CMakeLists.txt
main.cpp
I solved a similar problem by adding some lines in my CMakeLists.txt.
Have you tried including filesystem.hpp without the "boost/" part?