最近编译POCO 库和 Boost库的笔记

最近在编译POCO库和BOOST库

先讲一下编译POCO库,我编译的是1.9.0,过程相当曲折,要OPENSSL修改版本的,个OPENSSL在这里下载,如果你用一般未修改的OPENSSL 是编译不了,会出现大量错的

https://github.com/pocoproject/openssl

编译好后还要下载一个MYSQL 开发版本,一般是ZIP包,300多M的,要注意,如果你要编译32位POCO,就要下载MYSQL 32位,如果编译64位POCO,就要64位的MYSQL

然后修改 buildwin.cmd

主要修改下面两个地方

rem Change OPENSSL_DIR to match your setup
set OPENSSL_DIR=D:\opensourcelibrary\CPP\openssl-develop\VS_150
set OPENSSL_INCLUDE=%OPENSSL_DIR%\include
set OPENSSL_LIB=%OPENSSL_DIR%\win32\lib\debug;%OPENSSL_DIR%\win32\lib\release;%OPENSSL_DIR%\win32\bin\debug;%OPENSSL_DIR%\win32\bin\release;
set INCLUDE=%INCLUDE%;%OPENSSL_INCLUDE%
set LIB=%LIB%;%OPENSSL_LIB%

rem Change MYSQL_DIR to match your setup
set MYSQL_DIR=D:\mysql
set MYSQL_INCLUDE=%MYSQL_DIR%\include
set MYSQL_LIB=%MYSQL_DIR%\lib\;%MYSQL_DIR%\lib\debug
set INCLUDE=%INCLUDE%;%MYSQL_INCLUDE%
set LIB=%LIB%;%MYSQL_LIB%
 
修改完按照自己的VS版本进行执行,比如我是VS 2017 是 VC 150 版本,我就执行build_vs150.cmd,如无意外就编译成功
 
再讲一下编译boost 库,要编译winXP可以用的,我就这样做
 
先下载一个boost_1_68_0.zip
然后解压
 
然后再执行如下
注意,我测试过,好像VS2015或者以上的版本都不能编译XP下面可以用的版本,测试过在VS2013正常地编译了一份XP下面可以用的BOOST库
执行前要先执行这几条语句
set INCLUDE=%ProgramFiles(x86)%\Microsoft SDKs\Windows\7.1A\Include;%INCLUDE%
set PATH=%ProgramFiles(x86)%\Microsoft SDKs\Windows\7.1A\Bin;%PATH%
set LIB=%ProgramFiles(x86)%\Microsoft SDKs\Windows\7.1A\Lib;%LIB%
 
网上有说还要执行以下
set CL=/D_USING_V110_SDK71_;%CL%
set LINK=/SUBSYSTEM:CONSOLE,5.01 %LINK%
 
但我试过,执行以后执行bootstrap.bat会出错的,不建议执行上面两条语句
出错会如下
 

d:\boost_1_68_0\tools\build\src\engine>if exist bootstrap rd /S /Q bootstrap

d:\boost_1_68_0\tools\build\src\engine>md bootstrap

d:\boost_1_68_0\tools\build\src\engine>cl /nologo /RTC1 /Zi /MTd /Fobootstrap/ /Fdbootstrap/ -DNT -DYYDEBUG -wd4996 kernel32.lib advapi32.lib user32.lib /Febootstrap\jam0 command.c compile.c constants.c debug.c execcmd.c execnt.c filent.c frames.c function.c glob.c hash.c hdrmacro.c headers.c jam.c jambase.c jamgram.c lists.c make.c make1.c object.c option.c output.c parse.c pathnt.c pathsys.c regexp.c rules.c scan.c search.c subst.c timestamp.c variable.c modules.c strings.c filesys.c builtins.c md5.c class.c cwd.c w32_getreg.c native.c modules/set.c modules/path.c modules/regex.c modules/property-set.c modules/sequence.c modules/order.c
command.c
cl : Command line error D8038 : invalid argument '_USING_V120_SDK71_;%CL%'

d:\boost_1_68_0\tools\build\src\engine>exit /b 2


d:\boost_1_68_0\tools\build\src\engine>if exist bootstrap rd /S /Q bootstrap

d:\boost_1_68_0\tools\build\src\engine>md bootstrap

d:\boost_1_68_0\tools\build\src\engine>cl /nologo /RTC1 /Zi /MTd /Fobootstrap/ /Fdbootstrap/ -DNT -DYYDEBUG -wd4996 kernel32.lib advapi32.lib user32.lib /Febootstrap\jam0 command.c compile.c constants.c debug.c execcmd.c execnt.c filent.c frames.c function.c glob.c hash.c hdrmacro.c headers.c jam.c jambase.c jamgram.c lists.c make.c make1.c object.c option.c output.c parse.c pathnt.c pathsys.c regexp.c rules.c scan.c search.c subst.c timestamp.c variable.c modules.c strings.c filesys.c builtins.c md5.c class.c cwd.c w32_getreg.c native.c modules/set.c modules/path.c modules/regex.c modules/property-set.c modules/sequence.c modules/order.c
command.c
cl : Command line error D8038 : invalid argument '_USING_V120_SDK71_;%CL%'

d:\boost_1_68_0\tools\build\src\engine>exit /b 2

 
 
接着执行bootstrap.bat
 
D:\opensourcelibrary\CPP\boost_1_68_0>bootstrap.bat 


Building Boost.Build engine
Bootstrapping is done. To build, run:
    .\b2
To adjust configuration, edit 'project-config.jam'.
Further information:
    - Command line help:
    .\b2 --help
    - Getting started guide:
    http://boost.org/more/getting_started/windows.html

    - Boost.Build documentation:
    http://www.boost.org/build/doc/html/index.html

D:\opensourcelibrary\CPP\boost_1_68_0>

如果你是VS2013 并且想编译WINDOWS XP下面可以用的32位库,运行下面语句
b2.exe toolset=msvc-12.0_xp link=static runtime-link=static,shared --build-dir=build/x86 address-model=32 -j5 install --includedir=D:\opensourcelibrary\CPP\boost_1_68_0\win32\include --libdir=D:\opensourcelibrary\CPP\boost_1_68_0\win32\lib\x86 define=BOOST_USE_WINAPI_VERSION=0x0501
最后的 define=BOOST_USE_WINAPI_VERSION=0x0501 是指明XP下面也可以用的,如果你不需要XP也可以把那个参数删除,默认是WIN7的
如果你是编译 32位,编译个WIN7下面的库,这里是VS 2017为例子,因为是ms-vc 14.1版本,根据自己的VS版本填入适当的参数,我这里用了b2的命令,网上也有用bjam的,等下再讲
 
b2.exe toolset=msvc-14.1 link=static runtime-link=static,shared --build-dir=build/x86 address-model=32 -j5 install --includedir=D:\opensourcelibrary\CPP\boost_1_68_0\win32\include --libdir=D:\opensourcelibrary\CPP\boost_1_68_0\win32\lib\x86 

如果你是编译64位,这个命令
b2.exe toolset=msvc-14.1 link=static runtime-link=static,shared --build-dir=build/x64 address-model=64 -j5 install --includedir=d:\opensourcelibrary\CPP\boost_1_68_0\win64\include --libdir=d:\opensourcelibrary\CPP\boost_1_68_0\win64\lib\x64

posted on 2018-10-27 18:45  redmondfans  阅读(1209)  评论(0编辑  收藏  举报