tags:

views:

86

answers:

1

I am trying to run a boost example but I am getting the following error:

g++ bimap.cpp -o bimap
bimap.cpp:1:28: error: boost/config.hpp: No such file or directory
bimap.cpp:8:27: error: boost/bimap.hpp: No such file or directory
bimap.cpp: In function 'int main()':
bimap.cpp:27: error: 'boost' has not been declared
bimap.cpp:27: error: expected initializer before '<' token
bimap.cpp:28: error: 'results_bimap' has not been declared
bimap.cpp:28: error: expected initializer before 'position'
bimap.cpp:30: error: 'results_bimap' was not declared in this scope
bimap.cpp:30: error: expected `;' before 'results'
bimap.cpp:31: error: 'results' was not declared in this scope
bimap.cpp:31: error: 'position' was not declared in this scope

But my environment variables are set as follows:

BOOST_HOME /apps/rhel5/boost_1_39_0 
BOOST_INCLUDE -I/apps/rhel5/boost_1_39_0/include/boost-1_39/ 
LINK_BOOST -L/apps/rhel5/boost_1_39_0/lib -Xlinker -rpath -Xlinker /apps/rhel5/boost_1_39_0/lib 

Am I supposed to provide any extra options while compiling?

+2  A: 

You must provide the paths to boost files to g++ itself.

Try this:

g++ bimap.cpp -I/apps/rhel5/boost_1_39_0/include/boost-1_39/ -L/apps/rhel5/boost_1_39_0/lib -Xlinker -rpath -Xlinker /apps/rhel5/boost_1_39_0/lib -o bimap

Or (solution by TokenMacGuy):

g++ bimap.cc $BOOST_INCLUDE $LINK_BOOST
Kyle Lutz
@Kyle Lutz: Wonderful! Thanks much... :) Works perfectly... Is there a way to actually use the env variables in that line?
Legend
OOOOOR, `g++ bimap.cc $BOOST_INCLUDE $LINK_BOOST`, since they're already in the environment...
TokenMacGuy
@TokenMacGuy: Works! Thanks a lot...
Legend