﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-c++ ghost-随笔分类-boost</title><link>http://www.cppblog.com/styushao/category/4563.html</link><description /><language>zh-cn</language><lastBuildDate>Mon, 26 May 2008 00:13:44 GMT</lastBuildDate><pubDate>Mon, 26 May 2008 00:13:44 GMT</pubDate><ttl>60</ttl><item><title>编译boost库</title><link>http://www.cppblog.com/styushao/archive/2007/05/06/23517.html</link><dc:creator>昱少</dc:creator><author>昱少</author><pubDate>Sun, 06 May 2007 07:43:00 GMT</pubDate><guid>http://www.cppblog.com/styushao/archive/2007/05/06/23517.html</guid><wfw:comment>http://www.cppblog.com/styushao/comments/23517.html</wfw:comment><comments>http://www.cppblog.com/styushao/archive/2007/05/06/23517.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/styushao/comments/commentRss/23517.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/styushao/services/trackbacks/23517.html</trackback:ping><description><![CDATA[<p><strong><font size=4>编译jam</font></strong> <br><strong><u>Windows</u></strong> <br>到$BOOSTDIR\tools\build\jam_src下执行build.bat对jam进行编译，编译结果将存放在$BOOSTDIR\ tools\build\jam_src\bin.ntx86下。如果你在执行该批处理程序过程中遇到问题，如报告无法找到编译器相关程序，请执行 X:\Program Files\Microsoft Visual Studio\VC98\Bin\VCVARS32.bat 以建立VC的基本环境变量。 <br><u><strong>Solaris 9</strong></u> <br>到$BOOSTDIR\tools\build\jam_src下执行./build.sh对jam进行编译，编译结果将存放在$BOOSTDIR\tools\build\jam_src\bin.solarisx86下。 <br><font size=4><strong>设置环境变量</strong></font> <br><strong><u>Windows</u></strong><br>我的电脑点右键-&gt;属性-&gt;高级-&gt;环境变量-&gt;user variable或system variable中：<br>PATH最后添加bjam存放目录，如：<br><font color=#ff0000>$BOOSTDIR\tools\build\jam_src\bin.ntx86</font><br>新建环境变量MSVCDIR，并在变量值一栏中填入VC安装目录，如：<br>X:\Program Files\Microsoft Visual Studio\VC98<br>新建环境变量：<br><font color=#ff0000>PYTHON_ROOT=X:\Program Files\Python2.3.4<br>PYTHON_VERSION=2.3</font><br><strong><u>Solaris 9</u></strong> <br>在.profile中PATH后添加编译后的jam的存放目录。<br>并增加<br><font color=#ff0000>PYTHON_VERSION=2.3<br>export PYTHON_VERSION</font><br>注意，无需设置PYTHON_ROOT，Solaris下jam会自动处理。<br><font size=4><strong>编译Boost</strong></font> <br><strong><u>Windows</u></strong> <br>命令： <br><br><font color=#0080ff>bjam -sBOOST_ROOT=. -sTOOLS=msvc "-sBUILD=debug release &lt;runtime-link&gt;static/dynamic"</font> <br><br>以上命令解释如下： <br><br>-s 即set，设置环境变量； <br><br>BOOST_ROOT boost的存放目录 <br><br>TOOLS 你选择的toolset，如gcc、msvc（即vc6）、vc7.1，此外还有gcc-stlport、msvc-stlport、vc7.1- stlport，表示同时使用stlport。具体支持何种toolset，大家可以自行到$BOOSTDIR\tools\build\v1看个究竟。 BUILD 编译类型，上述选项表示编译出支持static和dynamic链接的debug和release版本（4个版本）。 <br><br>编译后的lib、dll将被copy到$BOOSTDIR\bin\boost\libs目录下，但是这些lib、dll分散在不同的目录下，为了便于使用，可以在上述目录下分别查找*.lib和*.dll找出这些文件，然后将他们分别全部copy到VC的lib目录和Windows的System32目录，也可以自己建立一个专门用于存放boost的lib文件的目录，然后 依次选择Tools-&gt;Options-&gt;Directories-&gt;Library files，将上述目录路径添加到VC的环境设置中。 <br><strong><u>Solaris 9</u></strong> <br><br>到$BOOSTDIR下执行以下命令： <br><br><font color=#0080ff>bjam&nbsp;-sBOOST_ROOT=. -sTOOLS=gcc "-sBUILD=debug release &lt;runtime-link&gt;static/dynamic"</font> <br><br>但建议用如下命令： <br><br><font color=#0080ff>bjam&nbsp;-sBOOST_ROOT=. -sTOOLS=gcc "-sBUILD=release &lt;runtime-link&gt;dynamic speed"</font> <br><br>这样可以极大加快编译的速度，同时，个人认为像boost这样大的库，最好还是采用动态链接以减小目标程序的size，就像libstdc++，还没有见过有人去静态链接libstdc++.a，虽然系统中提供了这个静态库<br><br><br><font size=3><em><u>本文所有内容都是网上资源汇总 感谢所有计算机从业者的集体智慧</u></em></font></p>
<img src ="http://www.cppblog.com/styushao/aggbug/23517.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/styushao/" target="_blank">昱少</a> 2007-05-06 15:43 <a href="http://www.cppblog.com/styushao/archive/2007/05/06/23517.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>