Christina-hshi/SH-assembly

Allowing boost in non-standard directory

Closed this issue · 1 comments

Hi,

I could not compile your code with the error that it did not find the boost libraries, which happened because they are not in the default path.

Adding the following to CMakeLists.txt fixed it for me:

# Add boost
find_package(Boost 1.48.0 REQUIRED system thread iostreams program_options timer chrono)
include_directories(${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS})
# Fix FindBoost issue with not giving ${Boost_LIBRARY_DIRS}
if(NOT $ENV{BOOST_ROOT} STREQUAL "")
        link_directories("$ENV{BOOST_ROOT}/lib/")
endif()
if(NOT $ENV{BOOST_LIBRARYDIR} STREQUAL "")
        link_directories($ENV{BOOST_LIBRARYDIR})
endif()

Thanks! Schmeing!
An alternative solution is that we can set related environment variables for the libraries not installed in the system's default path, such that the compiler and linker can still find them. For more details, please refer to https://www.linuxtopia.org/online_books/an_introduction_to_gcc/gccintro_23.html
Schmeing's solution is more preferable since it asks CMAKE to find these libraries, so we don't need to set the environment variables. I will update my CMAKE file! Thank you!