﻿<?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++博客-Muponder-文章分类-【OpenSource】</title><link>http://www.cppblog.com/deajosha/category/21045.html</link><description>为者常成，行者常至。</description><language>zh-cn</language><lastBuildDate>Sun, 05 Jul 2015 21:37:20 GMT</lastBuildDate><pubDate>Sun, 05 Jul 2015 21:37:20 GMT</pubDate><ttl>60</ttl><item><title>Windows 8.1 Visual studio 2013编译libpqxx4.0.1</title><link>http://www.cppblog.com/deajosha/articles/211146.html</link><dc:creator>盛源博</dc:creator><author>盛源博</author><pubDate>Sat, 04 Jul 2015 15:03:00 GMT</pubDate><guid>http://www.cppblog.com/deajosha/articles/211146.html</guid><wfw:comment>http://www.cppblog.com/deajosha/comments/211146.html</wfw:comment><comments>http://www.cppblog.com/deajosha/articles/211146.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/deajosha/comments/commentRss/211146.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/deajosha/services/trackbacks/211146.html</trackback:ping><description><![CDATA[1. 下载PostgreSql和libpgxx<br />&nbsp; &nbsp; PostgreSql下载地址：http://www.postgresql.org/download/ 选择windows版本下的PostgreSql安装包（x86和x64）。<br />&nbsp; &nbsp; libpgxx下载地址：https://github.com/dreamsxin/libpqxx<br />&nbsp; &nbsp; libpgxx官网资料地址：http://pqxx.org/devprojects/libpqxx/doc/4.0/html/Reference/<br />&nbsp; &nbsp; libpgxx tutorial地址：&nbsp;http://pqxx.org/devprojects/libpqxx/doc/4.0/html/Tutorial/<br /><br />2. 安装PostgreSql<br />&nbsp; &nbsp;点击安装postgreSql安装包，如: PDK-9.4.0.298593-windows-64.exe。如果要编译32位的libpgxx,请下载32位的PostgreSql安装程序，<br />&nbsp; &nbsp;如postgresql-9.3.9-1-windows.exe，一键安装到即可。<br /><br />3. 编译libpgxx4.0.1<br />&nbsp; &nbsp;3.1 解压libpqxx4.0.1压缩包，把win32\common-sample另存为win32\common, &nbsp;使用ue编译器打开win32\common文件，<br />&nbsp; &nbsp; &nbsp; &nbsp; 修改PGSQLSRC的值为PostgreSql安装的根目录，如C:\Program Files\postgresql\9.3。<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; 把LIBPQINC=$(PGSQLSRC)\interfaces\libpq注释掉，<br />&nbsp; &nbsp; &nbsp; &nbsp; 取消<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;LIBPQINC=$(PGSQLSRC)\include的注释。<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; 把LIBPQPATH=$(PGSQLSRC)\interfaces\libpq\Release<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;LIBPQDLL=libpq.dll</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;LIBPQLIB=libpqdll.lib 注释掉，<br />&nbsp; &nbsp; &nbsp; &nbsp;取消<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;LIBPQDPATH=$(PGSQLSRC)\lib<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;LIBPQDDLL=libpq.dll</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;LIBPQDLIB=libpq.lib 注释。</div>&nbsp; &nbsp; &nbsp; &nbsp; 把LIBPQDPATH=$(PGSQLSRC)\interfaces\libpq\Debug</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;LIBPQDDLL=libpqd.dll</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;LIBPQDLIB=libpqddll.lib 注释掉，<br />&nbsp; &nbsp; &nbsp; &nbsp; 取消 <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;LIBPQDPATH=$(PGSQLSRC)\lib<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;LIBPQDDLL=libpq.dll</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;LIBPQDLIB=libpq.lib 注释。</div></div>&nbsp; &nbsp;3.2&nbsp;将config\ample-headers\compile\VisualStudio2010\pqxx\目录下的所有头文件拷贝到include\pqxx目录下<span style="font-size: 12px;">；</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;将 config\sample-headers\libpq\9.0\pqxx\目录下的所有头文件拷贝到include\pqxx目录下。<br /><br />&nbsp; &nbsp;3.3 如果是编译64位的libpqxx, 请使用ue编译打开win32\vc-libpqxx.mak 文件，将<br />&nbsp; &nbsp; &nbsp; &nbsp; LINK_FLAGS_BASE=kernel32.lib ws2_32.lib advapi32.lib /nologo /dll /machine:I386 shell32.lib secur32.lib wldap32.lib<br />&nbsp; &nbsp; &nbsp; &nbsp; 修改为<br />&nbsp; &nbsp; &nbsp; &nbsp; LINK_FLAGS_BASE=kernel32.lib ws2_32.lib advapi32.lib /nologo /dll /machine:x64 shell32.lib secur32.lib wldap32.lib<br /><br />&nbsp; &nbsp;3.4 选择Visual Studio 2013下的Visual Studio Tools下的命令提示行工具，并以管理员方式运行；<br />&nbsp; &nbsp; &nbsp; &nbsp;编译x86库时，直接运行命令：vcvars32.bat,<br />&nbsp; &nbsp; &nbsp; &nbsp;编译x64库时，请运行命令：<br />&nbsp; &nbsp; &nbsp; &nbsp;&#8221;C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\amd64\vcvars64.bat"。<br /><br />&nbsp; &nbsp; &nbsp; &nbsp;定位到libpgxx根目录下，如xx\libpqxx-4.0.1\libpqxx-4.0.1\，<br />&nbsp; &nbsp; &nbsp; &nbsp;编译x86库时，运行命令：nmake /f win32/vc-libpqxx.mak ALL；<br />&nbsp; &nbsp; &nbsp; &nbsp;编译x64库时，运行命令：<br />&nbsp; &nbsp; &nbsp; &nbsp;"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\amd64\nmake.exe" /f&nbsp;&nbsp;win32/vc-libpqxx.mak ALL.<br /><br />&nbsp; &nbsp; &nbsp; &nbsp;编译成功后，会将编译输出的静态链接库的debug/release及动态链接库的debug/release文件放到lib目录下如：<img src="http://www.cppblog.com/images/cppblog_com/deajosha/QQ截图20150704225934.png" border="0" alt="" width="915" height="363" /><br />&nbsp; <br />3.5 更多的编译选项及编译说明，请参照win32目录下的common文件，INSTALL.TXT 及vc-libpgxx.mak。本文如有说明得不对的，望指正。<br /><br />&nbsp; &nbsp; &nbsp;<img src ="http://www.cppblog.com/deajosha/aggbug/211146.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/deajosha/" target="_blank">盛源博</a> 2015-07-04 23:03 <a href="http://www.cppblog.com/deajosha/articles/211146.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Visual Studio 2013 编译STLport</title><link>http://www.cppblog.com/deajosha/articles/209618.html</link><dc:creator>盛源博</dc:creator><author>盛源博</author><pubDate>Sun, 10 May 2015 08:51:00 GMT</pubDate><guid>http://www.cppblog.com/deajosha/articles/209618.html</guid><wfw:comment>http://www.cppblog.com/deajosha/comments/209618.html</wfw:comment><comments>http://www.cppblog.com/deajosha/articles/209618.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/deajosha/comments/commentRss/209618.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/deajosha/services/trackbacks/209618.html</trackback:ping><description><![CDATA[<p style="line-height: 28px; margin: 0px 0px 10px; padding: 0px; color: #959595; font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px; text-indent: 2em;"><span style="font-family: verdana, 'courier new'; font-size: 10pt; line-height: 21px; color: #000000;">STL是一个标准、各个商家根据这个标准开发了各自的STL版本，而在这形形色色的STL版本中，SGI STL无疑是最引人瞩目的一个。这当然是因为这个STl产品系出名门，其设计和编写者名单中，Alexander Stepanov和Man Austern赫然在内，有两位大师坐镇，其代码水平自然有了最高保证。SGI STL不但在效率上一直名列前茅，而且完全依照ISO C++之规范设计，使用者尽可放心。此外，SGI STL做到了thread-safe,还体贴地名用户增设数种组件，如hash,hash-table,hash-multimap,slist和rope容器等等。因此无论在学习或者实用上，SGI STL应是首选。<br /></span><span style="font-size: 10pt; font-family: verdana, 'courier new'; line-height: 21px;">&nbsp; &nbsp; &nbsp;</span><span style="font-size: 10pt; font-family: verdana, 'courier new'; line-height: 21px;"> </span><span style="font-size: 10pt; font-family: verdana, 'courier new'; line-height: 21px; color: #000033;">无奈，SGI STL本质上是为了配合SGI公司自身的UNIX变体IRIX而量身定做，其它平台上的C++编译器想使用SGI STL, 都需要一番周折。著名的GNU C++虽然也使用了SGI STL，但在发行前已经调试整合，一般用户，特别是Windows平台上的BCB/VC用户要想使自己的C++编译器与SGI STL共同工作，可还是一件容易的事情。俄国人Boris Fomitchev注意到这个问题之后，建立一个免费提供服务的项目，称为STLport，旨在将SGI STL的基本代码移植到各主流编译环境中，使各个编译器的用户都能够享受到SGI STL带来的先进机能。STLport发展过程中曾接受Matt Austern的指导，发展到今天，已经比较成熟。最新的STLport 4.0，可以从www.stlport.org免费下载，zip文件体积约1.2M，可支持各主流C++编译环境的移植。BCB及VC当然是主流编译环境，所以当然也得到了STLport的关照。</span></p><span style="font-size: 10pt;">1. 登录www.stlport.org，下载最新的STLport版本，</span><span style="font-size: 13.3333330154419px;">解压到自己喜欢的位置。</span><br /><span style="font-size: 10pt;">&nbsp; &nbsp; 最新版本STLPort5.2.1是2013.5.13发布的，由于此版本中对c++11的一些特性支持还不是特别友好，在使用时需要慎重考虑这一问题。根据soureforge中提到，新版本5.3还在开发进行中。</span><br /><span style="font-size: 10pt;">2. 打开开始菜单下Visual Studio 2013下的Visual Studio Tools下面的命令环境编译工具-Visual Studio Command Prompt(2013).</span><br /><span style="font-size: 10pt;">&nbsp; &nbsp; 进入解压目录，依次运行</span><br /><span style="font-size: 10pt;">&nbsp; &nbsp; cd &nbsp;\STLPort-2.5.1<br /></span>&nbsp; &nbsp; 查看confibure.bat配置文件，其支持visual studio编译器最高版本为visual studio 2008,即msvc9,默认的编译操作平台是windows xp, 这里我们就选择默认的(我的操作系统是windows8.1)，如果要查看更多的编译选项，可查看configure.bat文件。<br />&nbsp; &nbsp; 如果使用错误的编译器版本，会出现如下错误：<br /><img src="http://www.cppblog.com/images/cppblog_com/deajosha/QQ截图20150510153921.png" border="0" alt="" /><br /><span style="font-size: 10pt;">&nbsp; &nbsp; configure.bat msvc9</span><br /><span style="font-size: 10pt;">&nbsp; &nbsp; cd build/lib</span><br /><span style="font-size: 10pt;">&nbsp; &nbsp; nmake -f msvc.mak clean install</span><br /><span style="font-size: 10pt;">&nbsp; &nbsp; 但编译会出现错误：<br /><img src="http://www.cppblog.com/images/cppblog_com/deajosha/QQ截图20150510154014.png" border="0" alt="" /></span><br /><code string"="" style="font-size: 12px; white-space: pre-wrap; line-height: 1.8em !important; margin: 0px !important; padding: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; outline: 0px !important; overflow: visible !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; min-height: inherit !important; background-image: none !important; background-attachment: initial !important; background-size: initial !important; background-origin: initial !important; background-clip: initial !important; background-position: initial !important; background-repeat: initial !important;"><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 19.1399993896484px; white-space: normal; background-color: #ffffff;"><br />&nbsp; &nbsp; 打开文件stlport\stl\_cstdlib.h，定位到第158行代码，并添加如下语句：<br /></span><span style="color: #808080; font-size: 10pt; background-color: #f4f4f4;">   #if !defined(_STLP_MSVC) || (_STLP_MSVC &lt; 1600)<br /></span><code keyword=""  bold"="" style="line-height: 1.8em !important; margin: 0px !important; padding: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; outline: 0px !important; overflow: visible !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; min-height: inherit !important; color: #0000ff !important; background-image: none !important; background-attachment: initial !important; background-size: initial !important; background-origin: initial !important; background-clip: initial !important; background-position: initial !important; background-repeat: initial !important;"><span style="font-size: 10pt;">   inline</span></code><span style="white-space: normal; background-color: #ffffff;">&nbsp;</span><code plain"="" style="line-height: 1.8em !important; margin: 0px !important; padding: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; outline: 0px !important; overflow: visible !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; min-height: inherit !important; background-image: none !important; background-attachment: initial !important; background-size: initial !important; background-origin: initial !important; background-clip: initial !important; background-position: initial !important; background-repeat: initial !important;"><span style="font-size: 10pt;">_STLP_LONG_LONG </span></code><code functions=""  bold"="" style="line-height: 1.8em !important; margin: 0px !important; padding: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; outline: 0px !important; overflow: visible !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-weight: bold !important; min-height: inherit !important; color: #ff1493 !important; background-image: none !important; background-attachment: initial !important; background-size: initial !important; background-origin: initial !important; background-clip: initial !important; background-position: initial !important; background-repeat: initial !important;"><span style="font-size: 10pt;">abs</span></code><code plain"="" style="line-height: 1.8em !important; margin: 0px !important; padding: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; outline: 0px !important; overflow: visible !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; min-height: inherit !important; background-image: none !important; background-attachment: initial !important; background-size: initial !important; background-origin: initial !important; background-clip: initial !important; background-position: initial !important; background-repeat: initial !important;"><span style="font-size: 10pt;">(_STLP_LONG_LONG __x) { </span></code><code keyword=""  bold"="" style="line-height: 1.8em !important; margin: 0px !important; padding: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; outline: 0px !important; overflow: visible !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; min-height: inherit !important; color: #0000ff !important; background-image: none !important; background-attachment: initial !important; background-size: initial !important; background-origin: initial !important; background-clip: initial !important; background-position: initial !important; background-repeat: initial !important;"><span style="font-size: 10pt;">return</span></code><span style="white-space: normal; background-color: #ffffff;">&nbsp;</span><code plain"="" style="line-height: 1.8em !important; margin: 0px !important; padding: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; outline: 0px !important; overflow: visible !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; min-height: inherit !important; background-image: none !important; background-attachment: initial !important; background-size: initial !important; background-origin: initial !important; background-clip: initial !important; background-position: initial !important; background-repeat: initial !important;"><span style="font-size: 10pt;">__x &lt; 0 ? -__x : __x; }</span><br /></code><span style="color: #808080; font-size: 10pt; background-color: #f4f4f4;">   #endif<br /></span></code><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 19.1399993896484px; background-color: #ffffff;">&nbsp; &nbsp; 注意_STLP_MSVC 和 _MSC_VER 是一个东东，就是VC的版本号。<br /></span>&nbsp; &nbsp;在visual studio2013下，这样编译结束后，在项目中引用，会提示如下错误：<br /><br /><img src="http://www.cppblog.com/images/cppblog_com/deajosha/QQ截图20150510204252.png" border="0" alt="" /><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 19.1399993896484px; background-color: #ffffff;"><br />&nbsp; &nbsp;<br />解决办法是：<br />&nbsp; &nbsp; 打开stlport\stl\_cmath.h，找到hypot函数定义处，删除如下代码即可，如下所示：<br /><br /><img src="http://www.cppblog.com/images/cppblog_com/deajosha/QQ截图20150510222403.png" border="0" alt="" /><br /><br /></span><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 19.1399993896484px; background-color: #ffffff;">&nbsp; &nbsp; 这个过程编译时间稍长，大约需要数分钟。编译完成后会自动将编译出的*.dll和*.lib复制到STLport\lib和STLport\bin目录下，其中包括静态库和动态库，之后可将STLport\build\lib\obj目录删除以节省硬盘空间。</span><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 19.139999389648438px; background-color: #ffffff;">把stlport的lib,include目录添加到visual studio编译器中,&nbsp;</span><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 19.1399993896484px; background-color: #ffffff;">STLport就可以使用了。<br /></span><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 19.139999389648438px; background-color: #ffffff;">4. 在使用STLport过程中，可以使用不同的宏在决定使用动态链接或是静态链接STL,<br /></span><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 19.139999389648438px; background-color: #ffffff;">&nbsp; &nbsp; #define _STLP_USE_BOOST_SUPPORT &nbsp;// stlport与boost配合使用<br /></span><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 19.139999389648438px; background-color: #ffffff;">&nbsp; &nbsp; #define _STLP_USE_STATIC_LIB &nbsp;// 静态链接stlport<br /></span><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 19.139999389648438px; background-color: #ffffff;">&nbsp; &nbsp; #define _STL_USER_DYNAMIC_LIB // 动态链接stlport<br /></span><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 19.1399993896484px; background-color: #ffffff;">&nbsp; &nbsp; #define _STL_DEBUG // debug调试模式<br /><br /></span><img src ="http://www.cppblog.com/deajosha/aggbug/209618.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/deajosha/" target="_blank">盛源博</a> 2015-05-10 16:51 <a href="http://www.cppblog.com/deajosha/articles/209618.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>