Boost 的编译(交叉)安装 & cmake find_package(Boost)
linux-dash
A beautiful web dashboard for Linux
项目地址:https://gitcode.com/gh_mirrors/li/linux-dash
免费下载资源
·
- 下载 boost 1.59的源码,执行:
./bootstrap.sh
-
编辑文件 project-config.jam,用 “using gcc : arm : arm-linux-gnueabihf-g+±4.8” 替换 “using gcc”, 行尾的分号前有个空格!
-
执行编译安装:
./bjam install toolset=gcc-arm --prefix=/path/to/install --disable-sNO_ZLIB=1 -sNO_BZIP2=1 --without-python
如果需要编译 Boost.Coroutine 和 Boost.Context (For Arm):
./bjam install toolset=gcc-arm architecture=arm address-model=32 abi=aapcs binary-format=elf --disable-sNO_ZLIB=1 -sNO_BZIP2=1 --without-python --prefix=/path/to/install
或者,修改project-config.jam后, 对4核cpu ( b2 比 bjam 新一点):
./b2 install toolset=gcc-arm --prefix=/path/to/install --disable-sNO_ZLIB=1 -sNO_BZIP2=1 --without-python -j 4
如果只需要编译某几个特定的库:
cd boost
./bootstrap.sh --with-libraries=coroutine,context,thread,system
./b2 -j4
// where `-j4 specifies a parallel build using 4 jobs.
// You may want to increase or decrease the number of parallel jobs,
// depending on the number of cores available on your system.
// If you prefer to build all Boost libraries, then leave out the --with-libraries option.
若使用cmake编译项目,编辑 FindBoost.cmake 文件
vi /usr/share/cmake-2.8/Modules/FindBoost.cmake
在前面添加:
SET(Boost_ADDITIONAL_VERSIONS "1.59" "1.59.0")
SET(BOOST_ROOT "/path/to/boost1.59.0")
这样 find_package 就可以找到新的boost库了。
或者直接在项目中添加,例如:
SET(Boost_ADDITIONAL_VERSIONS "1.59" "1.59.0")
SET(BOOST_ROOT "/usr/local/boost1.59.0")
# option
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost 1.59.0 COMPONENTS filesystem regex REQUIRED) # 最好是加上REQUIRED,否则找不到某些库也不会报错,链接会出问题
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
add_executable(progname file1.cxx file2.cxx)
target_link_libraries(progname ${Boost_LIBRARIES})
endif()
GitHub 加速计划 / li / linux-dash
10.39 K
1.2 K
下载
A beautiful web dashboard for Linux
最近提交(Master分支:2 个月前 )
186a802e
added ecosystem file for PM2 4 年前
5def40a3
Add host customization support for the NodeJS version 4 年前
更多推荐
已为社区贡献12条内容
所有评论(0)