Navigation

    蓝鲸ROS机器人论坛

    • Register
    • Login
    • Search
    • Categories
    • Tags
    • Popular
    ROS交流群
    ROS Group
    产品服务
    Product Service
    开源代码库
    Github
    官网
    Official website
    技术交流
    Technological exchanges
    激光雷达
    LIDAR
    ROS教程
    ROS Tourials
    深度学习
    Deep Learning
    机器视觉
    Computer Vision

    在Windows上编译安装boost库

    技术交流
    1
    1
    1615
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • weijiz
      weijiz last edited by

      boost是一个C++的库,用途很广。

      下载源码

      从sourceforge上下载源码

      编译安装

      下载后解压进入源码目录
      打开一个命令行程序,cd 到源码目录。注意要以管理员权限执行。

      9fffdc6f-7c48-4d80-9faf-d9ab9b6d9e9d-image.png

      执行 .\bootstrap.bat 文件,输出入下图(注意要下载新版本的,老版本的执行会出错)

      0a82a175-108a-464a-8f5f-cb679828014d-image.png

      根据提示执行b2.exe程序。根据我们不同的需求可以给b2.exe增加很多参数。下面是常用的几个参数

      安装参数

      toolset 编译器类别,可以是gcc,或者是msvc
      target-os 目标操作系统,可以是Windows,Linux
      variant 生成类型,可以是 debug或者release
      threadapi 线程API的实现,可以是win32或者pthread,在windows上编译就用win32
      link 链接库类型,可以是静态的,也可以是shared,对应windows上的库就是.lib或者是dll
      prefix 安装路径
      user-config 用户自定义配置文件,在cross compile的时候可以用来配置编译工具链
      address-model 生成32位还是64位库文件
      architecture=x86  cpu架构,一般台式机位x86,嵌入式平台位arm
      

      比如我们想要在windows上编译安装64位的Release版的静态链接库到C:\boost路径下就可以执行下面的指令

      .\b2.exe variant=release threading=multi threadapi=win32 link=static runtime-link=shared --prefix=C:\boost address-model=64 architecture=x86 install -j8
      

      最后我们加了-j8参数。这个代表8线程同时编译,可以提高编译安装的速度。

      如果我们想要安装Mingw-w64版本的boost就可以用下面的指令

      .\b2.exe toolset=gcc variant=release threading=multi threadapi=win32 link=static runtime-link=shared --prefix=C:\boost address-model=64 architecture=x86 install -j8
      

      当然前提是已经安装了mingw-w64程序。

      编译完成后可以在C:\boost文件夹内看到include和lib文件夹。这里就是编译好的boost文件。

      1 Reply Last reply Reply Quote 0
      • 1 / 1
      • First post
        Last post
      Copyright © 2015-2023 BlueWhale community