Here is a simple guide on how to connect to boost library in Cmake.
How to Connect boost Library to Cmake
Situation 1: Not installed in the default path use:
set(BOOST_ROOT /usr/include/boost)////Set your own path set(Boost_NO_SYSTEM_PATHS NO)////////Here is the system path for instructions. Generally, the default installation is in /usr/include/boost find_package (Boost COMPONENTS regex system REQUIRED) if(Boost_FOUND) include_directories(${Boost_INCLUDE_DIRS}) MESSAGE( STATUS "Boost_INCLUDE_DIRS = ${Boost_INCLUDE_DIRS}.") MESSAGE( STATUS "Boost_LIBRARIES = ${Boost_LIBRARIES}.") MESSAGE( STATUS "Boost_LIB_VERSION = ${Boost_LIB_VERSION}.") add_executable(main main.cpp) target_link_libraries (main ${Boost_LIBRARIES}) endif()
Situation 2: Install it in the default path and use it directly
find_package(Boost COMPONENTS regex system REQUIRED) if(Boost_FOUND) include_directories(${Boost_INCLUDE_DIRS}) MESSAGE( STATUS "Boost_INCLUDE_DIRS = ${Boost_INCLUDE_DIRS}.") MESSAGE( STATUS "Boost_LIBRARIES = ${Boost_LIBRARIES}.") MESSAGE( STATUS "Boost_LIB_VERSION = ${Boost_LIB_VERSION}.") add_executable(main main.cpp) target_link_libraries (main ${Boost_LIBRARIES}) endif()
Similar Posts:
- caffe35793;- 38382;- 39064;src/caffe/net. cpp:8 :18: fatal error: hdf5.h: No such file or directory compilation term…
- [Solved] Protobuf & cmake Low Version Error: Could not find a package configuration file provided by “Protobuf” with any of the following names: ProtobufConfig.cmake
- Mac: How to Solve Print: Entry, “:CFBundleIdentifier”, Does Not Exist
- [Solved] ERROR: HTTPSConnectionPool(host=’center.conan.io’, port=443):
- LIBRARY_ Path and LD_ LIBRARY_ The difference of path environment variable
- C Language: How to Search in Header File (Two Methods)
- [How to Use] System.getProperty(“user.dir”)
- [Solved] Linux Execute File Error: no such file or directory (bit mismatch)
- CMake: How to Complie Log4cplus
- [Solved] PyCharm Start Error: TypeError: unsupported operand type(s) for /: ‘str’ and ‘str’