当前位置:首页 » 编程软件 » boost库的编译

boost库的编译

发布时间: 2023-02-03 03:55:42

① 如何调用已经编译好的boost库

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

linux下G++怎么编译使用Boost库的程序

首先把Boost库的头文件存放到/usr/include/boost/路径下,再把Lib文件存放到/usr/local/lib/boost/路径下。修改/etc/profile文件,在此文件中增加如下2个环境变量:

BOOST_INCLUDE=/usr/include/boost
export BOOST_INCLUDE

BOOST_LIB=/usr/local/lib/boost
export BOOST_LIB

写一个如下所示的cpp文件。
//samlpe.cpp
#include <iostream>
#include <string>
#include <boost/thread.hpp>

using namespace std;

void threadRoutine(void)
{
boost::xtime time;
time.nsec = 0;
time.sec = 20;
cout << "线程函数做一些事情" << endl;
boost::thread::sleep(time);
}

int main(void)
{
string str;
cout << "输入任意字符开始创建一个线程..." << endl;
cin >> str;
boost::thread t(&threadRoutine);
t.join();
cout << "输入任意字符结束运行..." << endl;
cin >> str;
return 0;
}

保存。使用g++编译,命令如下所示:

g++ -o samlpe.out samlpe.cpp -I$BOOST_INCLUDE -L$BOOST_LIB -lboost_thread-gcc-mt

其中-I参数指定Boost头文件路径,-L参数指定Boost库文件路径,-l参数指定使用线程库名。在我使用的这个版本Boost里,到/usr /local/lib/boost路径下,可以看到有关Boost线程库文件,比如:libboost_thread-gcc-mt.a等。注意在用-l 参数指定库名时把磁盘文件名前面那个lib前缀去掉就可以了。

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

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

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

④ boost怎么编译

1、用它带的booststrap脚本生成b2、bjam
2、用b2、bjam生成lib

boost附带的文档一开始就是教你怎么安装编译boost。照着做就是了

⑤ 如何编译boost.1.60库

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库。当然这件事情又一如既往很酷地没有出现在容易看到的地方。而是让你链接错误后再去玩抓虫游戏。

⑥ 如何从Boost.python的静态编译库

编译前提是安装Python2.2以上: (1)将$(BOOST)\tools\jam\src\bin.ntx86下的bjam.exe拷贝至$(BOOST)目录下。 (2)编译:bjam –-toolset=msvc –-with-python –-build-type=complete stage。 (3)编译结果是生成dll和lib文件。

⑦ 如何移植boost库到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 库

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

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

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

⑨ VS2015使用boost库,在不用修改项目属性中include和library路径下,还能成功编译,如何设置

打开VS2015安装目录中这个文件文件D:ProgramFiles(x86)MicrosoftVisualStudio14.0VCVCWizardsdefault.vcxproj,其实是个XML文件,在default.vcxproj文件末尾的</Project>之前填加下列内容,保存即可大功告成:

<PropertyGroup>
<IncludePath>d:oost_1_60_0;$(IncludePath)</IncludePath>
<VC_LibraryPath_x86>d:oost_1_60_0VC2015_lib32;$(VC_LibraryPath_x86)</VC_LibraryPath_x86>
<VC_LibraryPath_x64>d:oost_1_60_0VC2015_lib64;$(VC_LibraryPath_x64)</VC_LibraryPath_x64>
</PropertyGroup>

其中d:oost_1_60_0是boost库解压路径,该文件夹下面有boost文件夹(是boost源文件)

d:oost_1_60_0VC2015_lib32是编译好的32位库目录

d:oost_1_60_0VC2015_lib64是编译好的64位库目录

热点内容
java返回this 发布:2025-10-20 08:28:16 浏览:750
制作脚本网站 发布:2025-10-20 08:17:34 浏览:1012
python中的init方法 发布:2025-10-20 08:17:33 浏览:719
图案密码什么意思 发布:2025-10-20 08:16:56 浏览:879
怎么清理微信视频缓存 发布:2025-10-20 08:12:37 浏览:774
c语言编译器怎么看执行过程 发布:2025-10-20 08:00:32 浏览:1127
邮箱如何填写发信服务器 发布:2025-10-20 07:45:27 浏览:351
shell脚本入门案例 发布:2025-10-20 07:44:45 浏览:229
怎么上传照片浏览上传 发布:2025-10-20 07:44:03 浏览:912
python股票数据获取 发布:2025-10-20 07:39:44 浏览:876