boost 编译,每次都找,麻烦。

本文详细介绍了Boost库的编译步骤及配置方法,包括不同编译器下的编译指令、参数说明,以及如何使用STLPort。适用于希望深入了解Boost库构建过程的开发者。

1、运行VS2003工具里的 “Visual Studio .NET 2003 命令提示"
2、在命令行模式下,cd 进入需要编译的Boost C++ Libraries 下面具体类库的Build目录
3、运行 nmake vc71.mak

例子:
cd D:/MyProject/ShareCode/boost_1_35_0/libs/regex/build
nmake vc71.mak
and install

boost库的编译其实很简单,关键是要自己尝试一下。

 

从网上的一些文章中摘录出其中最关键的步骤,再加上自己的实践,总结出如下文字,在此存档。

 

===================================================

boost编译步骤:

1.代码下载 - 官方网站:http://www.boost.org

在官方网站下载代码的压缩包,解压到本地目录。
比如boost_1_38_0.zip,解压到 "e:/boost_1_38_0"。   

2. 准备工作

下载boost 编译工具 boost-jam-3.1.17-1-ntx86.zip。
下载地址google一下吧。http://sourceforge.net/projects/boost

3. 编译

  1):打开“开始”菜单,选择“运行”,输入cmd,进入控制台窗口,进入boost安装源路径e:/boost_1_38_0。

 2):cmd中输入:

  bjam install --toolset=borland --prefix="E:/boost_1_38_0" debug --with-date_time --with-regex
 
    -- 是两个连续的减号,=前后均不能夹带空格,除路径之外,参数都是小写字母。
   --toolset 表示采用borland编译。如果用VC编译,则改为 --toolset=msvc
   debug表示编译“调试版”。
    --with 指定要编译的模块
  3):回车后,出现大量奇怪文字,最后能看到以下内容,就表示成功完成编译:
  ...failed updating 2 targets.
  ...skipped 31 targets...
  ...updated 341 targets...

 4). release版本

  bjam install --toolset=borland --prefix="E:/boost_1_38_0" release --with-date_time --with-regex

  改变的是“debug”更换为“release”。回车后开始release的boost库编译。

 
 5).有时不知道编译器到底需要什么版本的lib,可以完整编译boost:

  bjam install --toolset=borland --prefix="E:/boost_1_38_0" debug(或release)--build-type=complete

    这样会编译出所有debug和release的lib库。

 6). 库的使用
  编译完成后,E:/boost_1_38_0 目录下,可以看到两个子目录:"include"和"lib",前者保存着所有采用纯头文件形式提供的boost代码文件;后者则是所有编译出的库文件。.dll, .lib

 7). 结束
  打开C++Builder2007.
    Project-Default Options-C++Builder设置。在Include Path添加前面的"include/boost-1_38"所在的目录,在Library Path添加“lib”所在的目录。

  C++Options-Paths and Directories.同上设置。

      VC的设置众所周知,就不说了。


另附 bjam 参数   

--build-dir=<builddir>     编译的临时文件会放在builddir里(编译完就可删除)
--stagedir=<stagedir>     存放编译后库文件的路径,默认是stage
--build-type=complete     编译所有版本(确切地说是相当于:variant=release, threading=multi;link=shared|static;runtime-link=shared)
variant=debug|release     编译什么版本(Debug or Release?)
link=static|shared             使用静态库还是动态库。
threading=single|multi      单线程还是多线程库。
runtime-link=static|shared     决定是静态还是动态链接C/C++标准库。
--with-<library>     只编译指定的库,如输入--with-regex就只编译regex库了。
--show-libraries     显示需要编译的库名称
===============================================================

1、下载boost包
从boost网站下载boost_1_36_0.tar.gz

2、解压
假设解压到D:/,那么Boost根目录就是D:/boost_1_36_0

3、构建bjam
在“Boost根目录/tools/jam”下,运行build_dist.bat(Linux:build_dist.sh)
将stage/bin.bin.ntx86/bjam.exe(Linux:stage/bin.linuxx86_64/bjam)拷贝到Boost根目录,创建快捷方式,符号链接也可以

4、构建boost库
bjam -toolset=msvc --build-type=complete install
(Linux:./bjam -toolset=gcc --build-type=complete install)

其他配置
1、安装路径:--prefix=<PREFIX>
默认:C:/Boost(Linux:/usr/local)

2、库文件安装路径:--libdir=<DIR>
默认:<EPREFIX>/lib

3、头文件安装路径:--includedir=<HDRDIR>
默认:<PREFIX>/include

4、构建类型:--build-type=<type>
debug release shared static mutil

5、中间文件存放路径:--build-dir=DIR
默认:Boost根目录

6、指定编译器:--toolset=toolset

msvc Microsoft Visual Studio
gcc Linux

可以指定版本,如
msvc-7.1 Microsoft Visual Studio 2003
msvc-8.0 Microsoft Visual Studio 2005

7、只构建指定库:--with-<library>

8、不构建指定库:--without-<library>
=========================test==============================
bjam install --toolset=msvc --prefix="E:/__Library__/boost_1_39_0" debug mutil --with-date_time --with-regex
bjam --with-system --with-thread --with-date_time --with-regex --with-serialization stage
///////////////////////////////////////////////////////
bjam install --toolset=msvc-7.1 --prefix="E:/__Library__/boost_1_39_0" --build-type="debug <threading>multi <link>shared <link>static <runtime-link>shared" --with-system

bjam install --toolset=msvc-7.1 --prefix="E:/__Library__/boost_1_39_0" debug --build-type=complete --with-system --with-thread --with-date_time --with-regex --with-serialization stage
bjam install --toolset=msvc-7.1 --prefix="E:/__Library__/boost_1_39_0" release --build-type=complete --with-system --with-thread --with-date_time --with-regex --with-serialization stage
LinuX
make lib gcc43

./bjam install --toolset=gcc --prefix="/home/hjz/boost_1_39_0" debug --build-type=complete --with-system --with-thread --with-date_time --with-regex --with-serialization stage


make *.cpp.
c++ -I /home/hjz/boost_1_39_0 example.cpp -o example ~/boost_1_39_0/lib/libboost_regex-gcc43-mt-d-1_39.a

asio
c++ -I /home/hjz/boost_1_39_0 LinuX_HttpClient.cpp -o /
lhc ~/boost_1_39_0/lib/libboost_regex-gcc43-mt-d-1_39.a /
~/boost_1_39_0/lib/libboost_system-gcc43-mt-d-1_39.a /
~/boost_1_39_0/lib/libboost_thread-gcc43-mt-d-1_39.a /
~/boost_1_39_0/lib/libboost_date_time-gcc43-mt-d-1_39.a /
~/boost_1_39_0/lib/libboost_serialization-gcc43-mt-d-1_39.a /
~/boost_1_39_0/lib/libboost_wserialization-gcc43-mt-d-1_39.a


D:/__Library__/boost_1_42_0>bjam --toolset=intel-win32 --prefix="d:/__Library__/boost_1_42_0" debug --build-type=complete --with-thread stage

 

D:/boost_1_42_0>bjam "-sTools=vc-7_1-stlport" "-sSTLPORT_PATH=D:/STLport-5.2.1/STLport-5.2.1/stlport" "-sSTLPORT_VERSION=5.2.1" --prefix="E:/__Library__/boost_1_39_0" debug --build-type=complete --with-thread stage

 

 

1.  到 http://www.stlport.com/ 下载 ,最新的版本是STLport-5.1.3,并解压到
    C:/STLport-5.1.3
2.  解压后, 包含几个目录和文件, 如 doc, src, build 等:
3.  修改"C:/Program Files2/Microsoft Visual Studio .NET 2003/Common7
    /Tools/vsvars32.bat"文件,
    在@set INCLUDE=的后面添加“C:/STLport-5.1.3/stlport;”
    在@set LIB=的后面添加“D:/STLport-5.1.3/lib;”
4.  打开控制台窗口 cmd , 执行:
    cd C:/STLport-5.1.3/stlport
    "C:/Program Files2/Microsoft Visual Studio .NET 2003/Common7/Tools/vsvars32.bat"
    这样,就可以在该控制台窗口里运行 nmake.exe了。
5.  不要关闭控制台窗口,运行如下命令:
    cd  D:/STLport-5.1.3/build/lib            // 切换到make目录
    configure -c msvc71         // 指定编译器.  --help 可以看到其它选项
    nmake /fmsvc.mak      
    nmake /fmsvc.mak install
6.  打开vs2003,选择菜单“工具”-》“选项”,弹出对话框,选择左边列表框的
    “项目”-》“VC目录”:包含文件添加“D:/STLport-5.0-0125/stlport”,
    库文件添加“D:/STLport-5.0-0125/lib”,分别将它们移到最上一条。
    这样,就不必在以后的每个项目中显示指定包含路径和库路径.
7. 测试是否使用了STLPort.
    用 vs2003 新建一个项目. 使用 <vector> .
    确保 项目属性/C/C++代码生成/运行时库 = 单线程 或 单线程调试.
    然后 build 该项目, 会看到大量link错误: 类似
     无法解析的外部符号 "public: bool __thiscall stlpmtx_std::......
    若将 项目属性 改为多线程后, build 成功.
    这说明 STLPort 已经起作用.
    这同时说明, STLPort 库生成的时候只针对多线程. 因此使用 STLPort
    的项目必须使用多线程.
    当然, STLPort 库也可以生成针对单线程的. 在编译STLPort库前,
    查看 configure --help 可以找到答案.

 

using stlport : 5.2.1 : D://STLport-5.2.1//stlport : D://STLport-5.2.1//lib ;

bjam stdlib=stlport --toolset=msvc-7.1 --prefix="D:/boost_1_42_0" debug --build-type=complete --with-thread stage

 

FeatureAllowed valuesNotes
variantdebug,release 
linkshared,staticDetermines if Boost.Build creates shared or static libraries
threadingsingle,multiCause the produced binaries to be thread-safe. This requires proper support in the source code itself.
address-model32,64Explicitly request either 32-bit or 64-bit code generation. This typically requires that your compiler is appropriately configured. Please refer to the section called “C++ Compilers” and your compiler documentation in case of problems.
toolset(Depends on configuration)The C++ compiler to use. See the section called “C++ Compilers” for a detailed list.
include(Arbitrary string)Additional include paths for C and C++ compilers.
define(Arbitrary string)Additional macro definitions for C and C++ compilers. The string should be either SYMBOL or SYMBOL=VALUE
cxxflags(Arbitrary string)Custom options to pass to the C++ compiler.
cflags(Arbitrary string)Custom options to pass to the C compiler.
linkflags(Arbitrary string)Custom options to pass to the C++ linker.
runtime-linkshared,staticDetermines if shared or static version of C and C++ runtimes should be used.

06-22
### 得物技术栈及开发者文档分析 得物作为一家专注于潮流商品的电商平台,其技术栈和开发者文档主要围绕电商平台的核心需求展开。以下是对得物技术栈及相关开发资源的详细解析: #### 1. 技术栈概述 得物的技术栈通常会涵盖前端、后端、移动应用开发以及大数据处理等多个领域。以下是可能涉及的主要技术栈[^3]: - **前端开发**: 前端技术栈可能包括现代框架如 React 或 Vue.js,用于构建高效、响应式的用户界面。此外,还会使用 Webpack 等工具进行模块化打包和优化。 - **后端开发**: 后端技术栈可能采用 Java Spring Boot 或 Node.js,以支持高并发和分布式架构。数据库方面,MySQL 和 Redis 是常见的选择,分别用于关系型数据存储和缓存管理。 - **移动应用开发**: 得物的移动应用开发可能基于原生技术(如 Swift/Kotlin)或跨平台框架(如 Flutter)。这有助于确保移动端应用的性能和用户体验一致性。 - **大数据云计算**: 在大数据处理方面,得物可能会使用 Hadoop 或 Spark 进行数据挖掘和分析。同时,依托云服务提供商(如阿里云或腾讯云),实现弹性扩展和资源优化。 #### 2. 开发者文档分析 类似于引用中提到的 Adobe 开发者文档模板[^2],得物也可能提供一套完整的开发者文档体系,以支持内部团队协作和外部开发者接入。以下是开发者文档可能包含的内容: - **API 文档**: 提供 RESTful API 或 GraphQL 的详细说明,帮助开发者快速集成得物的功能模块,例如商品搜索、订单管理等。 - **SDK 集成指南**: 针对不同平台(如 iOS、Android 或 Web)提供 SDK 下载和集成教程,简化第三方应用的开发流程。 - **技术博客**: 分享得物在技术实践中的经验成果,例如如何优化图片加载速度、提升应用性能等。 - **开源项目**: 得物可能将部分技术成果开源,供社区开发者学习和贡献。这不仅有助于提升品牌形象,还能吸引更多优秀人才加入。 #### 3. 示例代码 以下是一个简单的示例代码,展示如何通过 RESTful API 调用得物的商品搜索功能(假设接口已存在): ```python import requests def search_items(keyword, page=1): url = "https://api.dewu.com/v1/items/search" headers = { "Authorization": "Bearer YOUR_ACCESS_TOKEN", "Content-Type": "application/json" } params = { "keyword": keyword, "page": page, "size": 10 } response = requests.get(url, headers=headers, params=params) if response.status_code == 200: return response.json() else: return {"error": "Failed to fetch data"} # 调用示例 result = search_items("Air Jordan", page=1) print(result) ``` 此代码片段展示了如何通过 Python 请求得物的 API,并获取指定关键词的商品列表。 --- ###
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值