Compile boost with MSVC90

boost C++库的绝大多数库并不需要编译,应用程序仅仅需要包含相应的头文件即可。但是部分boost库需要编译后使用。

编译环境:

  • Windows XP
  • Visual Studio 2008 SP1

目录清单:

  • BoostSrcDir,boost源代码的目录,放解压后的boost源代码及文档,例如D:\devroot\tools\boost\1_38_0
  • BoostInstallDir,boost编译后安装的目录,内含头文件和编译后的库文件(.lib和.dll),例如D:\devroot\tools\boost\1.38.0
  • BoostTempDir,boost编译中使用的临时目录,例如D:\devroot\tools\boost\temp

步骤:

  1. 下载boost 1.38.0的源代码包(sourceforge.net的链接)并解压到%BoostSrcDir%
  2. 编译boost的跨平台build工具bjam
    1. 启动VS2008控制台(启动菜单>Microsoft Visual Studio 2008>Visual Studio Tools>Visual Studio 2008 Command Prompt),运行
      cd %BoostSrcDir%\tools\jam
      build_dist.bat
    2. 然后得到%BoostSrcDir%\tools\jam\stage\bin.ntx86\bjam.exe
  3. 编译boost库
    1. 在VS2008控制台里,运行
      cd %BoostSrcDir%
      %BoostSrcDir%\tools\jam\stage\bin.ntx86\bjam.exe -q --build-type=complete --build-dir=%BoostTempDir% --without-graph --without-math --without-mpi --without-python --without-signals --without-wave --prefix=%BoostInstallDir% install

      其中,
      -q 使得编译如果有失败立刻结束
      --build-type=complete 使得编译生成所有各种静动态、运行时组合
      --without-xxx 让编译跳过我不使用的库(可以用bjam --show-libraries列出所有可以生成lib的库)
    2. 然后%BoostInstallDir%里得到了编译后头文件和库文件。大功告成,我们可以删除%BoostTempDir%,在使用boost 的项目里只要把%BoostInstallDir%\include\boost-1_38和%BoostInstallDir%\lib分别加到 include和lib的搜索路径里。
      ├─include
      │  └─boost-1_38
      │      └─boost
      │          ├─accumulators
      │          ├─algorithm
      │          ├─archive
      └─lib
posted @   frankbadpot  阅读(977)  评论(0编辑  收藏  举报
编辑推荐:
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· 展开说说关于C#中ORM框架的用法!
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
点击右上角即可分享
微信分享提示