Reputation: 1177
I installed boost v.1.51.0 and the directory "boost_1_51_0" is sitting under "/home/user1/boost/". To install, i merely unzipped the tar file in "/home/user1/boost/". I'm using the C++ compiler on MinGW.
Now, i'm trying to include the libraries in the code. so far i tried
#include </home/user1/boost/boost_1_51_0/libs/unordered/test/objects/test.hpp>
#include </home/user1/boost/boost_1_51_0/test.hpp>
#include </home/user1/boost/test.hpp>
#include <boost/test.hpp>
along with some others. I even tried adding the windows location of "/home/user1/boost/" to the path.
I'm missing something.
Upvotes: 3
Views: 6605
Reputation: 171253
#include </home/user1/boost/boost_1_51_0/libs/unordered/test/objects/test.hpp>
This is not going to work. That file might be found, but then it will try to include other files such as <boost/config.hpp>
which can't be found in your include path.
#include </home/user1/boost/boost_1_51_0/test.hpp>
^^^^^^^^
This is not going to work because the file isn't at that location! if you run ls /home/user1/boost/boost_1_51_0/test.hpp
you'll get an error because that file doesn't exist.
#include </home/user1/boost/test.hpp>
^^^^^^^^
Same problem here.
It's usually a bad idea to put absolute paths in #include
directives anyway, so all the above attempts are wrong. Instead you should include the file as its intended to be used:
#include <boost/test.hpp>
For this to work you need to tell the compiler where to look, so you set the include path with -I dir
which in your case needs to be -I /home/user1/boost/boost_1_51_0/
so the compiler looks for boost/test.hpp
in /home/user1/boost/boost_1_51_0/
and finds /home/user1/boost/boost_1_51_0/boost/test.hpp
and when that includes boost/config.hpp
it will find /home/user1/boost/boost_1_51_0/boost/config.hpp
as intended.
However, now this will find /home/user1/boost/boost_1_51_0/boost.test.hpp
but you seem to want to include a header used by one of the Boost.Undordered unit tests ... I'm not sure why you think you want that. Usually you only want to include Boost headers under boost
not under libs
Upvotes: 3
Reputation: 14619
Use the inclusions specified in the boost
documentation (typically along the lines of your <boost/test.hpp>
example above). But set your CPPPATH
/CXXFLAGS
(build environment) appropriately. For MinGW
, you'll want to add -I/home/user1/boost/boost_1_51_0/
.
Upvotes: 3
Reputation: 179392
You need to provide the include directory to your compiler using a command-line argument, e.g. -I/home/user1/boost/boost_1_51_0
.
You may also want to actually install boost to a system directory; see http://www.boost.org/doc/libs/1_51_0/doc/html/bbv2/installation.html for details.
Upvotes: 3