图文说明Visual Studio 2013编译libpqxx步骤以及常见编译错误

编译步骤(x86版本)

1.下载并安装postgresql,点击进入下载地址。下载界面如下:

目前最新版本是9.5.1,我下载了 Win x86-32 的最新版本。安装后目录如下:

2.下载并解压缩libpqxx,点击进入下载地址下载界面如下:

目前最新版本是4.0.1,我下载了libpqxx-4.0.1.tar.gz
压缩包。解压后目录如下:

3.编译环境准备。(安装或解压路径请以实际的为准,本文路径仅供参考)

  • 进入libpqxx的解压路径 D:\Program Files (x86)\libpqxx-4.0.1\win32 ,将该路径下的common-sample文件另存为common文件

  • 打开并删除上述common文件原有全部内容,然后将以下代码复制到common文件中并保存。

*注意:复制后请将第53行
PGSQLSRC 的值修改为你实际安装postgresql的根目录,同时根目录两端的双引号不能省略!

# Common options for Visual C++ makefiles to build libpqxx and its regression
# test.
# THE ORIGINAL OF THIS FILE IS CALLED common-sample; DON'T EDIT THE ORIGINAL or
# you may lose your changes when you upgrade your libpqxx sources.
# Instead, copy "common-sample" to "common" and edit just the file "common".

# Caution: on Windows, some environments, such as the "make" that comes with
# Visual C++, expect you to use backslashes as path separators (for example,
# "C:\src\libpqxx") whereas others like MinGW want you to use more conventional
# slashes (as in "C:/src/libpqxx").

# Standard library namespace.
# There are only two reasons why you might want to change this:
#
# 1. Your compiler doesn't define the standard library in the "std" namespace
# but in the global namespace, in which case PGSTD should be the empty string.
# However, a compiler with that problem is not likely to be good enough to
# compile libpqxx.
#
# 2. You are using a third-party standard library implementation such as
# STLport, which lives in another namespace to avoid clashes with the
# implementation that came with the compiler.
#
# In the latter case, PGSTD must be set to the namespace used by your preferred
# implementation.  In all other cases, just leave this set to "std".

STD="std"

# If you are using a 3rd-party STL like STLport, remember to check your path
# and be sure the STLport is included before the MSVC includes. VCVARS32.BAT
# doesn't know anything about the directories as defined in the IDE. I use
#
# set INCLUDE=\Utility\Code\STLport-4.5\stlport;%INCLUDE%
#
# ...and set STD to "_STL".

# Depending on your STL library min/max need to be defined.  Using STLport
# there is no need for libpqxx to redefine these for me.

# The next line gives us the directory under which all PostgreSQL include
# directories, DLLs and LIB files can be found.
#
# If you built PostgreSQL from source, this is probably the only line you
# will need to change.
#
# If you installed PostgreSQL using the One Click Installer from EnterpriseDB,
# comment out the following line and uncomment the line after it.
#
# Edit the appropriate line to match your specific installation.

#PGSQLSRC="C:\Sources\postgresql-9.1.1\src"

PGSQLSRC="D:\Program Files (x86)\PostgreSQL\9.5"

# This is the directory where the Postgres header files, e.g. postgres_ext.h,
# are found.

PGSQLINC=$(PGSQLSRC)\include

# This is the directory where the libpq header files, e.g. libpq-fe.h,
# are found.  If you used the One Click Installer, comment out the next line
# and uncomment the one following it:

#LIBPQINC=$(PGSQLSRC)\interfaces\libpq

LIBPQINC=$(PGSQLSRC)\include

# This is the directory where the release build of the libpq DLL
# and its corresponding LIB file are found, as well as the names of
# those two files.
#
# If you installed PostgreSQL using the One Click Installer from EnterpriseDB,
# comment out the next three lines and uncomment the following three:

#LIBPQPATH=$(PGSQLSRC)\interfaces\libpq\Release
#LIBPQDLL=libpq.dll
#LIBPQLIB=libpqdll.lib

LIBPQPATH=$(PGSQLSRC)\lib
LIBPQDLL=libpq.dll
LIBPQLIB=libpq.lib

# This is the directory where the debug build of the libpq DLL
# and its corresponding LIB file are found, as well as the names of
# those two files.
#
# NOTE: If you don't have access to a debug build of libpq, just
# provide the same information as above here. The debug builds of
# libpqxx will reference the release version of libpq, which will
# only limit your ability to debug libpq sources but otherwise should
# work just fine.
#
# If you installed PostgreSQL using the One Click Installer from EnterpriseDB,
# comment out the next three lines and uncomment the following three.

#LIBPQDPATH=$(PGSQLSRC)\interfaces\libpq\Debug
#LIBPQDDLL=libpqd.dll
#LIBPQDLIB=libpqddll.lib

LIBPQDPATH=$(PGSQLSRC)\lib
LIBPQDDLL=libpq.dll
LIBPQDLIB=libpq.lib
  • 进入libpqxx的解压路径 D:\Program Files (x86)\libpqxx-4.0.1\config\sample-headers\compiler\VisualStudio2010\pqxx ,将该路径下的全部头文件拷贝到目录 D:\Program
    Files (x86)\libpqxx-4.0.1\include\pqxx中
  • 进入libpqxx的解压路径 D:\Program Files (x86)\libpqxx-4.0.1\config\sample-headers\libpq\9.0\pqxx ,将该路径下的全部头文件拷贝到目录
    D:\Program Files (x86)\libpqxx-4.0.1\include\pqxx中
  • 进入libpqxx的解压路径 D:\Program Files (x86)\libpqxx-4.0.1\src ,打开 largeobject.cxx 源文件,在第34行加入头文件#include <algorithm>

4.开始编译。(安装或解压路径请以实际的为准,本文路径仅供参考)

  • 在开始菜单选择Visual Studio 2013的开发人员命令提示工具,并以管理员方式运行,然后直接运行命令:vcvars32.bat

  • 将命令提示工具定位到 libpqxx 的解压路径: D:\Program Files (x86)\libpqxx-4.0.1

  • 最后在命令提示工具中直接运行命令:nmake /f win32/vc-libpqxx.mak ALL,即可开始编译。

  • 编译成功后,所生成的静态库以及动态库,包括DEBUG版本和RELEASE版本,全部都在如下目录中:

常见编译错误

  • 提示缺少头文件。

请查看common文件中的 PGSQLSRC 的值是否已经修改为你实际安装postgresql的根目录,并确保已经按照上述步骤拷贝全部所需头文件。

  • 提示类似错误:error U1077: ‘copy‘ : return code ‘0x1‘。

请查看common文件中的 PGSQLSRC 的值是否已经修改为你实际安装postgresql的根目录,并确保根目录两端的双引号存在。

  • 提示类似错误: min() 或者 max() 不是std 的标准函数。

请确保 largeobject.cxx 源文件第34行已经加入头文件 #include <algorithm>。

  • 提示一堆无法解析的外部函数。

如果编译的是 x86 版本的 libpqxx ,请确保安装的 postgresql 也是 x86 版本的;同样 x64 版本的也是一个道理。

关于 libpgxx 更多的编译选项及编译说明,请参照 libpqxx 解压路径 Win32 目录下的common,INSTALL.TXT 以及 vc-libpgxx.mak 等文件。

时间: 2024-08-24 09:32:09

图文说明Visual Studio 2013编译libpqxx步骤以及常见编译错误的相关文章

Visual Studio 2013执行项目报错:HTTP 错误 500.22

转至:http://www.codingwhy.com/410.html 具体报错 HTTP 错误 500.22 - Internal Server Error 检测到在集成的托管管道模式下不适用的 ASP.NET 设置. 解决方法 1.选中项目,注意右下角的属性 2.把属性中的“托管管道模式”改为“经典” 3.ctrl+s保存,重新启动项目,项目就正常运行了

Type Script在Visual Studio 2013中的问题汇总(持续更新…)

◆ TypeScript在vs2012下的问题 TypeScript对VS2012支持度比较低,建议升级为VS2013版本. ◆ 在VS2013中无法创建TypeScript项目 VS2013默认不支持TypeScript. 需要在[工具]-[扩展和更新]中安装TypeScript,目前为止(2015年9月16日)for VS2013的最新版TS为1.5版本,但是实测有一些问题,建议安装比较稳定的1.4版本 ◆ 编译提示“TypeScript\1.4\1.4\tsc.exe 无效”的问题 解决方

Type Script在Visual Studio 2013中的一些问题

◆ TypeScript在vs2012下的问题 TypeScript对VS2012支持度比较低,建议升级为VS2013版本. ◆ 在VS2013中无法创建TypeScript项目 VS2013默认不支持TypeScript. 需要在[工具]-[扩展和更新]中安装TypeScript,目前为止(2015年9月16日)for VS2013的最新版TS为1.5版本,但是实测有一些问题,建议安装比较稳定的1.4版本 ◆ 编译提示“TypeScript\1.4\1.4\tsc.exe 无效”的问题 解决方

Visual Studio 2013 编译CEF步骤

If you'd like to build the Chromium Embedded Framework (a wrapper for Chromium, for creating browser-based applications) using Visual Studio 2013, you can do so by following the below steps. 1. Get Visual Studio 2013 (I use the Community Edition beca

InstallShield Limited Edition for Visual Studio 2013 图文教程(教你如何打包.NET程序)

原文:InstallShield Limited Edition for Visual Studio 2013 图文教程(教你如何打包.NET程序) InstallShield Limited Edition for Visual Studio 2013 图文教程(教你如何打包.NET Framework进去) 本文转自“吾乐吧软件站”,原文链接:http://www.wuleba.com/?p=23892 从Visual Studio 2012开始,微软就把自家原来的安装与部署工具彻底废掉了,

在visual studio 2013中编译Lua5.3.1

注:以下是基于 别人的教程或笔记来操作并按照自己的操作记录的纯文字版编译和hello lua过程. 原图文版链接: 原文链接 1.创建空的解决方案: 文件->新建->项目->其他项目类型->Visual Studio解决方案->空白解决方案 名称:lua53 位置:.. 接下来在这个解决方案中创建3个项目:分别为Luz_lib.Lua和Luac Lua和Luac项目中会生成最终我们需要的执行文件.Lua_lib会生成静态库文件, Lua和Luac项目的编译需要这个库文件.所以

在Visual Studio 2013/2015上使用C#开发Android/IOS安装包和操作步骤

原文:在Visual Studio 2013/2015上使用C#开发Android/IOS安装包和操作步骤 Xamarin 配置手册和离线包下载 http://pan.baidu.com/s/1eQ3qw8a 具体操作: 安装前提条件 1. 安装Visual Studio 2013,安装过程省略,我这里安装的windows10 + vs2013 with update 4. 2. 安装Java SDK,按照Next一步步安装,此处省略,如下图: 3. 安装Android SDK:因为在线安装的访

在visual studio 2013中编译语音识别库kaldi

在visual studio 2013中编译kaldi的主要困难的地方在于正确编译kaldi的依赖库,主要是:openfst,ATLAS, pthreadVC2,其中又属ATLAS最难编译,因此,为求整个编译逻辑清晰简洁,在此将忽略kaldi所有依赖库的编译,如果有时间,我会直接提供其所依赖的库. 编译环境: 操作系统:windows8 (推荐) 编译工具:visual studio2013 其他:要安装完整的CygWin环境 编译步骤: 新建解决方案:打开visual studio 2013,

Visual Studio 2013 的 curl winbuild 编译和配置

这是我的第一篇博客. curl官网:http://curl.haxx.se/ 百度百科:curl是利用URL语法在命令行方式下工作的开源文件传输工具 在网上有很多关于curl的编译方案,如: windows平台下编译curl支持https 在Windows上编译最新的CURL,含有zlib,openssl 这里介绍的是我认为最简单的winbuild方法的编译,不涉及https. 平台: win7 64位,Visual Studio 2013 工具: 1.curl-7.41.0.zip源码包:ht