在win7 + vs express for desktop中安装stlport和boost库
2015-06-28 22:16
471 查看
一、安装stlport
stlport是将sgi的stl库平移到各个平台上。sgi的这个库的特点就是效率非常高。boost在这个库上面运行要比vs自带的stl库效率高。所以我们首选安装stlport。
下载stlport:http://sourceforge.net/projects/stlport/ 最新版本是5.2.1
放到C盘根目录下面,解压。进入”vs2012 x86 native tools command prompt”。(注意:用cmd不行)
进入“C:\STLPort”目录,运行命令“configure msvc9”。msvc9应该对应的是vs2008。现在stlport没有支持更高的vs版本。所以,就按msvc9来configure了。
“cd C:\STLport\lib”,运行“nmake -f msvc.mak clean install”。
这个时候会出现错误,如下:
*C:\STLport\stlport\stl/_cstdlib.h(158): error C2084: function ‘__int64 abs(__int64)’ already has a body
C:\Program Files\Microsoft Visual Studio 10.0\VC\INCLUDE../include/stdlib.h(471) : see previous definition of ‘abs’
NMAKE : fatal error U1077: ‘“C:\ProgramFiles\Microsoft Visual Studio 10.0\VC\BIN\cl.EXE”’ : return code ‘0x2’*
解决方法是找到“C:\STLport\stlport\stl_cstdlib.h”文件,在158行中,由
改成:
不出意外的话,等待二十分钟,应该就会编译完成。
删除“STLport\build\lib\obj”目录中的中间文件(大约300M),节省磁盘工件
设置vs,优先使用stlport的头文件和lib库
首先需要打开一个project
选择 菜单“project–>xx properties…”
在顶部下拉菜单中选择“configuration: All configurations”,否则每次创建新的project都要设置一次,烦死~
找到“configuration properties –> vc++ directories”
修改三个目录:“include directories”,加入“C:\STLPort\stlport”;“library directories”加入“C:\STLPort\lib”;“excutable directories”加入“C:\STLPort\bin”
找到“configuration properties –> General–>Character Set”,设置为“Not Set”
找到“configuration properties –>Preprocessor–> Preprocessor Definitions”,加入“_STLP_DEBUG”和“__STL_DEBUG”,这样在debug的时候,就能够动态链接到stlport的debug版本的库了,能够深入debug进去。
找到“configuration properties –>Preprocessor–> Code Generation–> Runtime Library”,设置成“Multi Thread”。*要注意区分debug版本和release版本,分别对应不同的编译target。
二、安装boost库
boost提供一些stl没有的功能,如:多线程、正则表达式、函数式编程、等等。据说boost要被收录进stl成为标准。
下载boost库:http://www.boost.org/ 现在的最新版本是1.58.0
放到C盘根目录下解压,得到“C:\boost”(改了目录名字,去除了版本号)
用”vs2012 x86 native tools command prompt”进入上面目录,运行批处理文件:“bootstrap.bat”,在“C:\boost”目录下生成b2.exe,bjam.exe,和project-config.jam
用文本编辑器打开project-config.jam文件,并修改,增加一行“using stlport : STLport : C:/STLport/stlport : C:/STLport/lib ;”以便使用stlport作为底层库进行编译。注意:路径之间用冒号分隔,而不是分号或者空格;上面增加的两个路径分别是头文件路径和lib库路径。
键入命令“bjam threading=multi link=shared,static runtime-link=shared stdlib=stlport –stagedir=./stage”进行编译……漫长的等待
编译完成。在我的机器上,failed updated 658 targets, skipped 808 targets, updated 813 targets……
继续设置project以便能够利用boost库中的文件和编译出来的结果
首先需要打开一个project
选择 菜单“project–>xx properties…”
在顶部下拉菜单中选择“configuration: All configurations”
找到“configuration properties –> C/C++->General->Additional Include Directories”,设置boost头文件路径,“C:\boost\boost”
找到“configuration properties –> C/C++->linker->Additional library Directories”,设置boost库文件路径,“C:\boost\stage\lib”。之前老版本,需要从编译好的路径里面copy&paste出来这些库,不过现在貌似都生成在stage目录下了。
三、尝试
从网上找一段代码如下:
运行结果如下:
四、参考链接
http://blog.sina.com.cn/s/blog_6f62c9510101svk7.html
/article/7913551.html
/article/6996195.html
http://www.xuebuyuan.com/608176.html
五、后记
用stlport的库的确可能比较快,不过在vs中调试stlport的对象不太方便。其中一个典型的例子是vector。用vs自带的vector,在调试窗口可以直接看到vector中每个元素的值。如果用stlport的话,就必须在窗口中写上“vt._M_non_dbg_impl._M_start[2]”,才能看到vector vt中的第三个元素的值。
我在上面的configure中去掉stlport的头文件和库文件的引用,默认用vs自带的stl来编译“四”中的程序,也能编译通过,且运行通过。
完。
stlport是将sgi的stl库平移到各个平台上。sgi的这个库的特点就是效率非常高。boost在这个库上面运行要比vs自带的stl库效率高。所以我们首选安装stlport。
下载stlport:http://sourceforge.net/projects/stlport/ 最新版本是5.2.1
放到C盘根目录下面,解压。进入”vs2012 x86 native tools command prompt”。(注意:用cmd不行)
进入“C:\STLPort”目录,运行命令“configure msvc9”。msvc9应该对应的是vs2008。现在stlport没有支持更高的vs版本。所以,就按msvc9来configure了。
“cd C:\STLport\lib”,运行“nmake -f msvc.mak clean install”。
这个时候会出现错误,如下:
*C:\STLport\stlport\stl/_cstdlib.h(158): error C2084: function ‘__int64 abs(__int64)’ already has a body
C:\Program Files\Microsoft Visual Studio 10.0\VC\INCLUDE../include/stdlib.h(471) : see previous definition of ‘abs’
NMAKE : fatal error U1077: ‘“C:\ProgramFiles\Microsoft Visual Studio 10.0\VC\BIN\cl.EXE”’ : return code ‘0x2’*
解决方法是找到“C:\STLport\stlport\stl_cstdlib.h”文件,在158行中,由
inline _STLP_LONG_LONG abs(_STLP_LONG_LONG __x) { return __x < 0 ? -__x : __x; }
改成:
# if !defined(_STLP_MSVC) || (_STLP_MSVC < 1600) inline _STLP_LONG_LONG abs(_STLP_LONG_LONG __x) { return __x < 0 ? -__x : __x; } # endif
不出意外的话,等待二十分钟,应该就会编译完成。
删除“STLport\build\lib\obj”目录中的中间文件(大约300M),节省磁盘工件
设置vs,优先使用stlport的头文件和lib库
首先需要打开一个project
选择 菜单“project–>xx properties…”
在顶部下拉菜单中选择“configuration: All configurations”,否则每次创建新的project都要设置一次,烦死~
找到“configuration properties –> vc++ directories”
修改三个目录:“include directories”,加入“C:\STLPort\stlport”;“library directories”加入“C:\STLPort\lib”;“excutable directories”加入“C:\STLPort\bin”
找到“configuration properties –> General–>Character Set”,设置为“Not Set”
找到“configuration properties –>Preprocessor–> Preprocessor Definitions”,加入“_STLP_DEBUG”和“__STL_DEBUG”,这样在debug的时候,就能够动态链接到stlport的debug版本的库了,能够深入debug进去。
找到“configuration properties –>Preprocessor–> Code Generation–> Runtime Library”,设置成“Multi Thread”。*要注意区分debug版本和release版本,分别对应不同的编译target。
二、安装boost库
boost提供一些stl没有的功能,如:多线程、正则表达式、函数式编程、等等。据说boost要被收录进stl成为标准。
下载boost库:http://www.boost.org/ 现在的最新版本是1.58.0
放到C盘根目录下解压,得到“C:\boost”(改了目录名字,去除了版本号)
用”vs2012 x86 native tools command prompt”进入上面目录,运行批处理文件:“bootstrap.bat”,在“C:\boost”目录下生成b2.exe,bjam.exe,和project-config.jam
用文本编辑器打开project-config.jam文件,并修改,增加一行“using stlport : STLport : C:/STLport/stlport : C:/STLport/lib ;”以便使用stlport作为底层库进行编译。注意:路径之间用冒号分隔,而不是分号或者空格;上面增加的两个路径分别是头文件路径和lib库路径。
键入命令“bjam threading=multi link=shared,static runtime-link=shared stdlib=stlport –stagedir=./stage”进行编译……漫长的等待
编译完成。在我的机器上,failed updated 658 targets, skipped 808 targets, updated 813 targets……
继续设置project以便能够利用boost库中的文件和编译出来的结果
首先需要打开一个project
选择 菜单“project–>xx properties…”
在顶部下拉菜单中选择“configuration: All configurations”
找到“configuration properties –> C/C++->General->Additional Include Directories”,设置boost头文件路径,“C:\boost\boost”
找到“configuration properties –> C/C++->linker->Additional library Directories”,设置boost库文件路径,“C:\boost\stage\lib”。之前老版本,需要从编译好的路径里面copy&paste出来这些库,不过现在貌似都生成在stage目录下了。
三、尝试
从网上找一段代码如下:
#include <iostream> #include <vector> #include <boost/timer.hpp> using namespace std; using namespace boost; int main() { std::vector<int> vt; //STLport的vector! timer t; //构造一个计时器对象 cout<<"max timespan:"<<t.elapsed_max()/3600<<"h"<<endl; //定时器最大计时 cout<<"min timespan:"<<t.elapsed_min()<<"s"<<endl; //定时器最小计时(分辨率) cout<<"now time elapsed:"<<t.elapsed()<<"s"<<endl; //从计时器对象构建至今过了多长时间 system( "pause" ); return 0; }
运行结果如下:
max timespan:596.523h min timespan:0.001s now time elapsed:0.011s Press any key to continue . . .
四、参考链接
http://blog.sina.com.cn/s/blog_6f62c9510101svk7.html
/article/7913551.html
/article/6996195.html
http://www.xuebuyuan.com/608176.html
五、后记
用stlport的库的确可能比较快,不过在vs中调试stlport的对象不太方便。其中一个典型的例子是vector。用vs自带的vector,在调试窗口可以直接看到vector中每个元素的值。如果用stlport的话,就必须在窗口中写上“vt._M_non_dbg_impl._M_start[2]”,才能看到vector vt中的第三个元素的值。
我在上面的configure中去掉stlport的头文件和库文件的引用,默认用vs自带的stl来编译“四”中的程序,也能编译通过,且运行通过。
完。
相关文章推荐
- Linux-FLASH驱动设计一
- mic openmp 求dijkstra
- 利用Openssl生成证书
- 关于CRT连接虚拟机Linux系统的攻略
- CentOS Linux服务器安全设置
- linux下修改双系统默认启动级别
- OpenGL - obj文件的导入
- ecshop商品批量上传之EC助理1.28支持ECshop2.7.3方法
- Linux流量监控工具 - iftop (最全面的iftop教程)
- 跟我一起hadoop(1)-hadoop2.6安装与使用
- opencv 数字图像处理-图像错切
- Linux 手动编译PHP 5.6
- cJSON(Linux C)
- linux文件空洞
- 基于OpenCV的摄像机标定-翻译
- linux程序设计——make命令和makefile文件(第九章)
- 安全测试外包 简单搞定网站安全问题
- shell十三问(转)
- dev-ops
- Play HEVC/H.265 Videos and Embed HEVC Streams into MP4 and TS Files with openHEVC and GPAC