I'm trying to install boost in a custom dir. I did:
cd boost_dir./bootstrap.sh --prefix=/custom_dir./b2
Now what I want to do is tell CMake to point to that library. To that end, I added:
set(BOOST_ROOT "/custom_dir")FIND_PACKAGE(Boost COMPONENTS program_options REQUIRED)INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})TARGET_LINK_LIBRARIES(myProject ${Boost_LIBRARIES})
And CMake apparently found boost in that dir:
cmake . -- Found Boost: /custom_dir (found suitable version "1.66.0", minimum required is "1.66") found components: program_options -- Configuring done -- Generating done -- Build files have been written to: /my_project
However, when compiling, I still get:
undefined reference to `boost::program_options::options_description::options_description(std::string const&, unsigned int, unsigned int)'
A few answers have noted that boost must have been compiled with the same compiler as the program I'm using. However, I'm not sure if the steps I did above actually compiled boost or simply copies the uncompressed libs?
Also, does it use the path-resolved g++ or something in the system default /usr/bin? Reason is that I do not have root access and installed an updated GCC in a custom dir as well. I've pointed my PATH to the updated g++.