当前位置:首页 » 编程软件 » windows下boost怎么编译

windows下boost怎么编译

发布时间: 2022-09-06 07:39:04

① windows 怎么安装boost

先从官网(www.boost.org)下载最新版的BOOST源码,如图所示

我这里下的是zip的那个
第2步:
编译源代码(放心.这里是傻瓜式的操作,很容易操作)
(1)先把源代码放在E盘,例如 E:oost_1_53_0
(2)在源代码中找到一个批处理bootstrap.bat,运行即可
此时会弹出Building Boost.Jam之类,过一会之后,源代码中新增了1个文件bjam.exe
(3)运行bjame.exe即能编译了(花费时间很长,大概20分

② windows boost库要编译多久

vc的话有编译好的,mingw的话也有,不过不是最新版的,自己编译找教程吧,大概是先编译一个bjam的文件出来,然后用它编译boost,挺快的,其实没有某些教程说的几个小时,我的i5-460M大概是编译了大半个小时,boost1.56

③ VS2012+Windows下使用Boost的thread库编译报错

同问,我也遇到了,有解决办法吗?

boost库编译成动态链接库就可以了。boost库有3种编译状态,看哪种和调用程序匹配。

④ 如何用Visual Studio 2010编译boost1.42库

64位windows平台,编译环境是VS2005,进入Visual Studio 2005 x64 Win64 Command Prompt(单纯的cmd也不一定不行,我没试)。把bjam.exe放在boost根目录下,进入根目录,执行:
bjam --toolset=msvc address-model=64 --with-thread stage
bjam --toolset=msvc address-model=64 --with-date_time stage
关键选项:“address-model=64 ”
64位linux平台,使用gcc编译。进入boost根目录,执行:
./bjam --toolset=gcc --with-thread stage
./bjam --toolset=gcc --with-date_time stage
linux平台下倒是简单,不过网上有篇文章介绍用如下命令编译,不知道是多此一举,还是适用于某些情况(非64位linux主机?)。
./bjam --toolset=gcc "-sBUILD=release <cxxflags>-m64" --with-thread stage
./bjam --toolset=gcc "-sBUILD=release <cxxflags>-m64" --with-date_time stage

唉。命令都很简单,可浪费了我不少时间。usage根本没写,去看boost build的嘛,页数n多不说,看完之后能否找到答案还是未知数。网上相关资料很少而且大多南辕北辙,只好一直搜索+尝试。其实我只是想要个64位版本的库而已,这应该不是啥稀罕的需求吧?
在windows平台下,编译出来的是否是64位类库,只有link 64位程序的时候才能发现。如果不是,link程序无法找到类库中定义的函数或者类。linux不知道,因为我整出来直接就是64位了,我也懒得再找一台32位linux主机折腾了。
在1.37之后的boost,如果想要使用boost::thread库,必须有boost::date_time库。当然这件事情又一如既往很酷地没有出现在容易看到的地方。而是让你链接错误后再去玩抓虫游戏。

⑤ windows怎么在控制台编译boost程序

Boost库是一个功能强大、构造精巧、跨平台、开源并且完全免费的C++程序库
要使用Boost库,首先确认一下你使用的开发环境是否支持编译boost库(http://www.boost.org/users/history/version_1_46_1.html)
以windows的msvc编译器为例,支持编译boost库是Visual C++: 7.1, 8.0, 9.0 10.0
如果你还在用VC++ 6.0的话,只能抱歉了。VC6编译器由于不支持模板偏特化等许多新特性,所以有的Boost库会缺少功能甚至不能使用。
安装Boost库的方法:
1、从Boost网站(www.boost.org)下载压缩包,解压到本地硬盘任意位置。
本文以boost_1_46_1版本为例,解压位置为 D:\boost_1_16_1\
2、进入目录D:\boost_1_16_1\,运行bootstrap.bat,获得bjam.exe 程序
3、命令行方式执行: bjam stage --toolset=msvc-7.1 --build-type=complete --layout=versioned
其中,
stage 选项指定boost使用本地构建,当前目录下会创建一个stage目录,编译后的lib库会在其中。
toolset 选项指定编译器,对于使用visual studio 开发工具的程序员来说,需要正确填写msvc的版本号:
vs2003 : msvc-7.1
vs2005 : msvc-8.0
vs2008 : msvc-9.0
vs2010 : msvc-10.0
build-type 选项指定编译类型,
layout 选项指定需要编译的库名及头文件的地址目录名的生成策略。默认Windows下为versioned

接下来你可以关上显示屏去做别的事了,因为Boost库的完整编译会耗费大量的时间(本人在pc上花了约1个小时时间)。
完整编译后,需要在visual studio IDE 中设置包含目录和库目录。

Windows Visual Studio 200x IDE 通用配置
=======================================
在菜单中选择:
1. Tools (工具)
2. Options (选项)
3. Project and Solutions (项目)
4. VC++ Directories (VC++ 目录)
5. Show directories for (显示以下内容的目录): Include Files (包含文件) 增加 D:\boost_1_46_1
6. Show directories for (显示以下内容的目录): Library Files (库文件) 增加 D:\boost_1_46_1\stage\lib

如果是Visual Studio 2010,不再是从tools->options->project and solutions->VC++ directories 中配置库目录和包含目录,而是对自己的项目单独配置。
先添加/导入自己的项目,在窗体左侧项目的属性管理器中
1.单击第一个按钮(属性),弹出项目属性页
2.选择配置属性->VC++目录
3.包含目录中增加 D:\boost_1_46_1
4.库目录中增加 D:\boost_1_46_1\stage\lib

OK,一切准备就绪。可以开始使用Boost库了。下面的一个小程序可以测试一下boost库是否安装正确。
#include <boost/thread/thread.hpp>
#include <iostream>
void hello() {
std::cout << "Hello world, I'm a thread!" << std::endl;
}
int main(int argc, char* argv[]) {
boost::thread thrd(&hello);
thrd.join();
return 0;
}
正确安装的话,会在控制台输出一行"Hello world, I'm a thread!"的信息。

完整编译Boost库费时费力,而且也不一定在开发中都用到,所以也可以自行选择要编译的库。
只要在运行bjam的命令中,添加--with-<库名> 选项就可以了,或--without-<库名>关闭某个库的编译。
bjam还有许多选项,可参考bjam的文档以获得更多信息。

⑥ 在Windows平台下怎么编译boost 1.57 for android

这里是使用NDK进行编译boost的但肯定对我有用吧。。经过一番折腾终于编译成功,,高兴,呵呵! 转载

下面将主要的过程记录下来:

1、下载boost 源码:

Boost for Android

Boost for android is a set of tools to compile the main part of the Boost C++ Libraries for the Android platform.

Currently supported boost versions are 1.45.0, 1.48.0 and 1.49.0.

因此下载最新的 1.49 版本,下载完成后进行打补丁

2、下载补丁代码

boost-1_49_0

3、打补丁代码

boost_1_49_0.tar.bz2 放在android的 external 下解压:

tar -xjvf external/boost_1_49_0.tar.bz2

将boost-1_49_0.patch放在external\boost_1_49_0下面根目录执行:

patch -Np1 -d external/boost_1_49_0 < external/boost_1_49_0/boost-1_49_0.patch

4、编写boost的makefile文件,即Android.mk

LOCAL_PATH:= $(call my-dir)

common_SRC_FILES := \
libs/thread/src/pthread/thread.cpp \
libs/thread/src/pthread/once.cpp \

common_SRC_FILES += \
libs/filesystem/v3/src/codecvt_error_category.cpp \
libs/filesystem/v3/src/operations.cpp \
libs/filesystem/v3/src/path.cpp \
libs/filesystem/v3/src/path_traits.cpp \
libs/filesystem/v3/src/portability.cpp \
libs/filesystem/v3/src/utf8_codecvt_facet.cpp \
libs/system/src/error_code.cpp \
libs/system/src/local_free_on_destruction \

include $(CLEAR_VARS)
LOCAL_MODULE:= libboost
LOCAL_SRC_FILES := $(common_SRC_FILES)

prebuilt_stdcxx_PATH := prebuilts/ndk/current/sources/cxx-stl/gnu-libstdc++

LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/boost \
$(prebuilt_stdcxx_PATH)/include \
$(prebuilt_stdcxx_PATH)/libs/$(TARGET_CPU_ABI)/include/ \

LOCAL_C_INCLUDES += \
$(prebuilt_stdcxx_PATH)/include \
$(prebuilt_stdcxx_PATH)/libs/$(TARGET_CPU_ABI)/include/ \
$(prebuilt_supccxx_PATH)/include

LOCAL_CFLAGS += -fvisibility=hidden -lpthread
LOCAL_CPPFLAGS += -fexceptions -frtti

LOCAL_SHARED_LIBRARIES := libc libstdc++ libstlport

LOCAL_LDFLAGS += -L$(prebuilt_stdcxx_PATH)/libs/$(TARGET_CPU_ABI) -lgnustl_static -lsupc++

LOCAL_MODULE_TAGS := optional
include $(BUILD_SHARED_LIBRARY)
比较重要的是上面 红色 部分文字

最后编译生成:

target thumb C++: libboost <= external/boost_1_49_0/libs/thread/src/pthread/thread.cpp
target thumb C++: libboost <= external/boost_1_49_0/libs/thread/src/pthread/once.cpp
target thumb C++: libboost <= external/boost_1_49_0/libs/filesystem/v3/src/codecvt_error_category.cpp
target thumb C++: libboost <= external/boost_1_49_0/libs/filesystem/v3/src/operations.cpp
target thumb C++: libboost <= external/boost_1_49_0/libs/filesystem/v3/src/path.cpp
target thumb C++: libboost <= external/boost_1_49_0/libs/filesystem/v3/src/path_traits.cpp
target thumb C++: libboost <= external/boost_1_49_0/libs/filesystem/v3/src/portability.cpp
target thumb C++: libboost <= external/boost_1_49_0/libs/filesystem/v3/src/utf8_codecvt_facet.cpp
target thumb C++: libboost <= external/boost_1_49_0/libs/system/src/error_code.cpp
target SharedLib: libboost (out/target/proct/godbox/obj/SHARED_LIBRARIES/libboost_intermediates/LINKED/libboost.so)
target Symbolic: libboost (out/target/proct/godbox/symbols/system/lib/libboost.so)
target Strip: libboost (out/target/proct/godbox/obj/lib/libboost.so)
Install: out/target/proct/godbox/system/lib/libboost.so

成功生成 libboost.so 库

⑦ 如何编译libboost

您好,这样的:
1、当前boost最新版本为1.55,下载地址http://sourceforge.net/projects/boost/files/boost/1.55.0/
或者从官网(www.boost.org)下载最新版的BOOST源码,经过测试,2012和2013步骤相同,这里以2012为例。
2、打开VS2012 Native Tools Command,可以从开始--Microsoft Visual Studio 2012找到:将下载的 boost_1_55_0.zip 解压在F盘,例如 F:\boost_1_53_0,执行bootstrap.bat。
3、编译,可以简单的使用b2 install,也可以指定存放目录,或者寻找网上其它帮助文章。
查看帮助可以输入:.\b2 --help
比如要开启多线程编译:b2 install threading=multi
设置生成的是debug或者release
备注:如果是使用VS2013,请指定输出库类型,否则会缺一个lib文件:
"无法打开文件 libboost_thread_vc120_mt_sgd-1_55.lib"。
在2013时,我是使用下面的语句进行编译:
// 如果要获取动态库:
bjam install stage --toolset=msvc-12.0 --stagedir="C:\Boost\boost_vc_120" link=shared runtime-link=shared threading=multi debug release
// 如果是要获取静态库:

bjam install stage --toolset=msvc-12.0 --stagedir="C:\Boost\boost_vc_120" link=static runtime-link=static threading=multi debug release

其中,注意修改--toolset=msvc-12.0,将12.0修改成对应的vs版本号,12.0是VS2013的版本号。

目标地址也要修改成你所需的。

注意,不要漏了install,它会帮你把头文件集合到一个文件夹中。
编译过程有一个复制过程,编译需要的时间比较长,本次编译过程中,会在C盘根目录下生成一个boost文件夹,然后包含include和lib文件夹,这就是我们将要使用的头文件和库文件。

4、编译完了我们就使用编译在C盘中的文件。我将它们拷贝到了F盘,
需要简单的配置两个地方:这里使用绝对路径,也可以配置环境来使用。
5、然后建立了一个工程测试。 在BoostTest中新建一个控制台应用程序,下图三个文件分别是:
1) 将要使用的boost头文件和库文件。 2) 解压出的boost文件夹,就是使用这个文件夹来进行 1 -- 3步骤的。 3)BoostTest 测试工程。
#include <iostream>

#include <boost/thread/thread.hpp>
void hello()
{
std::cout << "Hello world, I'm a thread!" << std::endl;
}
int main()
{
boost::thread thrd(&hello);
thrd.join();
}
编译测试工程, 并运行,开始boost之旅吧。

⑧ window32位下安装boost库怎么运行 bootstrap.bat

1.模块/工具简介
Boost库是一个跨平台,开源并且完全免费的C++库,内容涵盖字符串处理、正则表达式、容器与数据结构、并发编程、函数式编程、泛型编程、设计模式实现等许多领域,使得实际的开发更加灵活和高效。(

2.系统要求

Windows xp以上

3.部署步骤
(1)选择下载Boost库Windows版的安装包,解压至硬盘任意目录(建议硬盘根目录),下面用$BOOSTDIR表示boost的存放目录
(2)在解压的文件夹中找到bootstrap.bat并运行,生成bjam的可执行程序,运行即可
(3)编译完成后会生成bin.v2和stage子目录,里面包含了生成的*.lib库文件

(4)配置vs环境,创建测试项目test,工具栏项目->右键->test属性->配置属性->C/C++->常规->附加包含目录中添加$BOOSTDIR路径(C:\boost_1_54_0;),在链接器->常规->附加库目录中添加$BOOSTDIR\stage\libs(C:\boost_1_54_0\stage\lib\*.lib),应用并确定,boost库在win32环境下就部署成功了!

4.可能遇到的问题
(1)LINK : fatal error LNK1104: cannot open file 'libboost_thread-vc100-mt-s-1_52.lib'
到库文件去看,只存在libboost_thread-vc100-mt-1_52.lib,两者有什么差别呢
-s

⑨ 安装了多个版本vs怎么编译boost

boost有些库是不用安装的,仅需包含头文件库就行了。
但是有些很爽的库(thread,regex)需要根据不同的系统做不同的调整,所以必须编译。
编译的流程很简单,如果是windows操作系统,首先找到那个booststrap.bat的东西,然后在控制台下运行它,它会生成bjam.exe,然后就可以通过bjam来编译boost库了,在命令行下输入bjam --help看选项。

如果嫌麻烦,可以一次将boost库需要编译的全部编译了,bjam --build-type=complete,生成库全在stage目录下。

⑩ windows下boost怎样安装与使用说明

一、 下载boost

boost_1_51_0.zip 下载并解压到C盘根文件夹
二、编译boost
1、生成生命行程序
执行bootstrap.bat
2、编译
执行b2.exe,完成后显示:
The Boost C++ Libraries were successfully built!
The following directory should be added to compiler include paths:
C:/boost_1_51_0
The following directory should be added to linker library paths:
C:\boost_1_51_0\stage\lib
三、使用boost
1、创建一个win32 console
2、引用bootst
C/C++ -> Additional Include Directories: C:\boost_1_51_0
Linker-> Additional Library Directories: C:\boost_1_51_0\stage\lib
Linker->Input->Additional Dependencies :libboost_signals-vc110-mt-gd-1_51.lib;libboost_regex-vc110-mt-gd-1_51.lib;
3、Code如下:

#include "stdafx.h"
#include <boost/regex.hpp>
#include <boost/signals.hpp>
#include <boost/lambda/lambda.hpp>

#include <iostream>
#include <cassert>

struct print_sum {
void operator()(int x, int y) const { std::cout << x+y << std::endl; }
};

struct print_proct {

void operator()(int x, int y) const { std::cout << x*y << std::endl; }

};

int _tmain(int argc, _TCHAR* argv[])
{
boost::signal2<void, int, int, boost::last_value<void>, std::string> sig;
sig.connect(print_sum());
sig.connect(print_proct());
sig(3, 5);
std::string line;
boost::regex pat( "^Subject: (Re: |Aw: )*(.*)" );
while (std::cin)
{
std::getline(std::cin, line);
boost::smatch matches;
if (boost::regex_match(line, matches, pat))
std::cout << matches[2] << std::endl;
}
return 0;
}


示例程序在vs2012下通过,输出:
8
15

热点内容
python字节转字符串 发布:2025-05-14 07:06:35 浏览:420
subplotpython 发布:2025-05-14 06:53:51 浏览:661
竖屏大屏导航工厂密码一般是多少 发布:2025-05-14 06:49:29 浏览:806
如何在手机里设置无线网密码 发布:2025-05-14 06:47:54 浏览:120
动态ip文件服务器 发布:2025-05-14 06:44:22 浏览:891
文字分行的脚本有什么 发布:2025-05-14 06:33:10 浏览:288
svn小乌龟怎么配置 发布:2025-05-14 06:31:43 浏览:393
视频播放器android 发布:2025-05-14 06:31:43 浏览:720
android工作室 发布:2025-05-14 06:26:00 浏览:658
汽车官方配置表如何下载 发布:2025-05-14 06:21:41 浏览:800