标签 C 下的文章

Boost_1_32_0版源代码编译

著名的C++准标准库boost在2004年末发布了1.32.0版本,作为C++的忠实Fans怎能“袖手旁观”,趁闲暇时download it and build it。[注]:由于没有公司Unix服务器的管理员权限,所以只能在自己的Windows平台上编译了。

1、前提
a) 下载Boost_1_32_0源码包(http://sourceforge.net/project/showfiles.php?group_id=7586 ),由于在Windows平台下编译,我们可以选择下载boost_1_32_0.exe文件;
b) 安装Windows下的GCC版本(这里我们使用开源的GCC作为编译工具,因为其Free),我选择了MinGW-3.2.0-rc-3(http://sourceforge.net/forum/forum.php?forum_id=438862 );
c) 下载Boost专用build工具bjam,在Windows平台下我们可以得到已经编译好的bjam.exe(http://sourceforge.net/project/showfiles.php?group_id=7586&package_id=72941 ),你可以  下载boost-jam-3.1.10-1-ntx86.zip文件。

2、目录结构
a) 运行下载后的boost_1_32_0.exe文件,选择解压缩到的目录即可。如D:\boost_1_32_0;
b) 将下载的bjam.exe拷贝到上述目录中。

3、设置环境变量
a) 由于默认情况下,MinGW会安装在C:\MinGW下,一旦你选择其他目录,你就需要自己设置Path。将%Your_MinGW_Install_Path%\bin加入到你的系统Path变量中。

4、Build
在命令行下进入到boost源码包存放的目录,如D:\boost_1_32_0,然后运行:
bjam “-sTOOLS=gcc” install

编译由此开始,如果你的系统没有装Python相关的东东,在编译的最开始会提示你一些warnings,无须理它,让它继续吧!默认的boost安装路径为C:\boost,我们这里采用默认路径。

5、Build结果
编译的过程是漫长的(一般配置的机器2小时左右),需要你耐心的等待。
编译后结果:在C:\Boost下生成两个文件夹include和lib,在D:\ boost_1_32_0中则多了一个bin目录。

6、应用boost
a) 设置boost库
如果你使用的IDE(比如Microsoft Visual Studio或者MinGW Developer Studio(http://petra.hos.u-szeged.hu/~aking/www.parinya.ca/download/MinGWStudioFullSetupPlus-2.05.exe )),你可以在IDE的include和lib路径中直接设置boost库的位置。如果你用的是命令行工具,对于复杂的项目构建估计你需要写你自己的Makefile了。
b) 使用boost的例子
//HelloBoost.cpp
#include
#include
#include
using namespace std;
using namespace boost;

int main()
{   
    string s = "Hello Boost,This is a test";
    tokenizer tok(s);
    for(tokenizer::iterator beg=tok.begin(); beg != tok.end(); ++beg)
    {
        cout << *beg << "\n";
    }
}
//Compile: g++ -o HelloBoost.exe HelloBoost.cpp -I"C:\Boost\include\boost-1_32"

//output:
Hello
Boost
This
is
a
test

现在你可以尽情去研究boost,体会它的无比强大了。

Advanced CVS

做了几个月的实际项目,感觉还是只用到CVS的皮毛,CVS中的高级功能比如create tag、create branch和merge等都未使用过。Dreamhead发过来一本”pragmatic version control-using CVS”,顺便do some practice and research on the advanced functions of CVS。

1、Tags、Branches and Tagging的概念理解
Tags分为Regular tag和Branch tag两种。
Regular tag其实就是我们一般理解中的tag,而Branch tag即是我们理解中的branch。
HEAD也是一个特殊的分支,the main branch,只是我们把它默认当作main trunk。

建立分支的必要性,举个简单的例子当我们的项目对外release1.0版本后,比如我们对整个project建立version为“Release_1_0”,但是这个版本肯定有bug存在,我们就这样提交给用户使用,相信不会等多久bug report就会feedback回来。所以我们得一边做下一个版本Release_2_0的开发一边fix bug,而我们fix bug时基于的版本只能使release1.0,这时我们就要考虑难道新版本的开发和fix bug的工作都要在main trunk 上么,这样可行么?回答是“也许可行,但是不用过多久你就会发现这样会造成太多的冲突,开发人员的抱怨声也越来越多”。Branch可以帮助我们解决这个难题。我们在建立version Release_1_0的同时建立一个branch,比如叫做“Release_1_0_Branch”,并同时建立一个regular tag ”Root_of_Releas_1_0_Branch”,这个regular tag的用途是为了以后branch 合并到main trunk时提供一个参考点。之后开发新版本的人员就基于main trunk工作,而fix bug的人员就基于Release_1_0_Branch工作。一旦在Release_1_0_Branch上将Release_1_0的bug修复了,我们就可以将Release_1_0_Branch合并到main trunk中来一次性remove the bugs。上面举的这个例子只是branch较简单的一个用法。有效的利用branch会给你的项目的开发带来很多便捷的。

下面的英文段落是从某书中摘录的关于version和branch的说明。
You can use CVS to maintain different branches of a project. Doing so is often
necessary if you release a version of your project to the public, such as version 1.0.
As you begin to work on adding new features for version 2.0, the code is not stable
enough for release; so, if any serious bugs are discovered in version 1.0, they must
be made to the original 1.0 code. CVS allows you to create a separate branch,
starting with the original 1.0 code, so you can maintain this code separately from
the new development continuing with the main branch, HEAD.
//…
Versions differ from branches. A version is a snapshot of a branch at a given
point in time—in other words, it’s a particular set of file revisions.
//….
Adding a version label to a project associates the revision number of each particular
file with a single project-level label.You should consider tagging a project with a version label at all significant development milestones, such as a beta or an official release, or before any drastic
change is undertaken.

2、Merge
理解了branch的概念后,那我们如何将一个Branch合并(Merge)到main trunk or another branch呢?下面我们使用Eclipse作为工具来说明如何将branch合并到其他branch中(main trunk is also a branch , a special branch)。

在你在CVS中创建branch后一段时间,你可能要将你在branch中的changes合并到其他branch中。要想将你的branch中的changes合并到其他branch中,你首先要知道“the name of your branch”and “the version from which your branch was created”。

知道上面的两样后,我们就可以实施我们的merge了。我们以branch merge到HEAD为例。具体步骤如下:

* 目标version加载
首先将目标version 加载到你的工作区,在这个例子里我们将HEAD version加载进来,具体方法是在你工作区(可能是“Navigator view”)中,Right click your project name, choose Replace With > Another Branch or Version from the context menu. Then select the HEAD to replace with your current version in your workplace。

* 选择branch
Select the project and choose Team > Merge.
在随后出现的对话框中,你首先选择“the version from which the branch was created.”,然后在下一步中选择你的Branch。

* Synchronize view中的操作
在第二步结束后,Synchronize view中将显示“all the differences between the branch and your workspace version(that is the HEAD version)”,你必须在Synchronize view中通过菜单中提供的“Update, Override and Update, or Mark as Merged”手工决定合并到你工作区的change。

* Commit the changes
在所有期望的changes都被merge到你的工作区后,你就可以“commit”the changes to the repository了。

注:Merge actions:
Update – Running this action will bring the changes into the file in the workspace. Any conflicts that are not auto-mergable will be skipped.

Override and Update – This action is enabled on files with conflicting changes. Running this action will discard any local changes you have and replace the file with the remote contents.

Mark as Merged – This action will remove the selected changes from the view. The changes will only reappear if the remote state of the resource changes and the CVS Merge Synchronization is refreshed.

如发现本站页面被黑,比如:挂载广告、挖矿等恶意代码,请朋友们及时联系我。十分感谢! Go语言第一课 Go语言进阶课 Go语言精进之路1 Go语言精进之路2 Go语言第一课 Go语言编程指南
商务合作请联系bigwhite.cn AT aliyun.com

欢迎使用邮件订阅我的博客

输入邮箱订阅本站,只要有新文章发布,就会第一时间发送邮件通知你哦!

这里是 Tony Bai的个人Blog,欢迎访问、订阅和留言! 订阅Feed请点击上面图片

如果您觉得这里的文章对您有帮助,请扫描上方二维码进行捐赠 ,加油后的Tony Bai将会为您呈现更多精彩的文章,谢谢!

如果您希望通过微信捐赠,请用微信客户端扫描下方赞赏码:

如果您希望通过比特币或以太币捐赠,可以扫描下方二维码:

比特币:

以太币:

如果您喜欢通过微信浏览本站内容,可以扫描下方二维码,订阅本站官方微信订阅号“iamtonybai”;点击二维码,可直达本人官方微博主页^_^:
本站Powered by Digital Ocean VPS。
选择Digital Ocean VPS主机,即可获得10美元现金充值,可 免费使用两个月哟! 著名主机提供商Linode 10$优惠码:linode10,在 这里注册即可免费获 得。阿里云推荐码: 1WFZ0V立享9折!


View Tony Bai's profile on LinkedIn
DigitalOcean Referral Badge

文章

评论

  • 正在加载...

分类

标签

归档



View My Stats