Compile step (x86 version)
1. Download and install Postgresql and click Enter . The download interface is as follows:
Currently the latest version is 9.5.1, I downloaded the latest version of Win x86-32 . The post-installation directory is as follows:
2. Download and unzip the libpqxx and click Enter. the download interface is as follows:
currently the latest version is 4.0.1, I downloaded the libpqxx-4.0.1.tar.gz compression package . The following directories are extracted:
3. Prepare the environment for compilation. (the installation or decompression path is subject to actual, the path of this document is for reference only )
- go to Libpqxx's decompression path D:\Program Files (x86) \libpqxx-4.0.1\win32 , save the Common-sample file under the path as a common file
- Open and delete the original contents of the above common file, and then copy the following code into the common file and save it.
* Note : After copying, please change the value of line 53rd pgsqlsrc to the root directory where you actually installed Postgresql. Double quotes at both ends of the root directory cannot be omitted!
# Common options for Visual C + + makefiles to build libpqxx and it regression# test.# the ORIGINAL of this FILE is called Common-sample; DON ' T EDIT the ORIGINAL or# 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 backslashes as path separators (for example,# "C:\src\libpqxx") whereas others like MinGW Want the conventional# slashes (as in "C:/src/libpqxx"). * Standard library namespace.# There is only a reas ONS 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 are not likely to be good enough to# compile libpqxx.## 2. You is using a Third-party standard library implementation such as# STLport, which Lives in another namespace to avoid clashes with the# implementation this came with the compiler.## on the latter case, P GSTD must is set to the namespace used by your preferred# implementation. In all other cases, just leave this set to "Std". std= "Std" # If you were using a 3rd-party STL like STLport, remember to check your path# and was 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;%i nclude%##. 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 AL L PostgreSQL include# Directories, DLLs and LIB files can be found.## If your built PostgreSQL from source, this is PROBABL Y the only line you# would 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,# is found. pgsqlinc=$ (PGSQLSRC) \include# 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) \i nterfaces\libpqlibpqinc=$ (PGSQLSRC) \include# This is the directory where the release build of the LIBPQ dll# and its Corre Sponding LIB file is found, as well as the names of# those II files.## If you installed PostgreSQL using the one Click I Nstaller from enterprisedb,# comment out the next three lines and uncomment the following three: #LIBPQPATH =$ (PGSQLSRC) \int erfaces\libpq\release#libpqdll=libpq.dll#libpqlib=libpqdll.liblibpqpath=$ (PGSQLSRC) \libLIBPQDLL=libpq.dlllibpqlib=libpq.lib# the directory where the debug build of the LIBPQ dll# and its corresponding lib file ar E found, as well as the names of# those and files.## note:if you don ' t has access to a debug build of LIBPQ, just# provi De the same information as above here. The debug builds of# libpqxx would reference the release version of LIBPQ, which will# only limit your ability to debug lib PQ sources but otherwise should# work just fine.## If you installed PostgreSQL using the one Click Installer from Enterpri sedb,# comment out the next three lines and uncomment the following three. #LIBPQDPATH =$ (PGSQLSRC) \interfaces\libpq\debug# libpqddll=libpqd.dll#libpqdlib=libpqddll.liblibpqdpath=$ (PGSQLSRC) \liblibpqddll=libpq.dlllibpqdlib=libpq.lib
- Go to Libpqxx's decompression path D:\Program Files (x86) \libpqxx-4.0.1\config\sample-headers\compiler\visualstudio2010\pqxx , copy all the header files under the path to the directory D:\Program files (x86) \libpqxx-4.0.1\include\pqxx
- Enter the Libpqxx decompression path D:\Program Files (x86) \libpqxx-4.0.1\config\sample-headers\libpq\9.0\pqxx , Copy all header files under this path to the directory D:\Program files (x86) \libpqxx-4.0.1\include\pqxx
- Enter libpqxx decompression path D:\Program files (x86) \libpqxx-4.0.1\src, open Largeobject.cxx source file, add header file in line 34th # include < Algorithm>
4. Start compiling. ( the installation or decompression path is subject to actual, the path of this document is for reference only )
- In the Start menu, select the Developer Command prompt tool for Visual Studio 2013, run as administrator, and then run the command directly: Vcvars32.bat
- Locate the command prompt tool to the decompression path of libpqxx: D:\Program Files (x86) \libpqxx-4.0.1
- Finally, run the command directly in the command prompt tool: nmake/f Win32/vc-libpqxx.mak all, you can start compiling.
- After successful compilation, the generated static library and the dynamic library, including the debug version and release version, are all in the following directory:
Common compilation Errors
Check to see if the value of PGSQLSRC in the common file has been modified to actually install the root of PostgreSQL and make sure that you have copied all the required header files as described above.
- Similar errors: Error U1077: ' Copy ': Return code ' 0x1 '.
Check to see if the value of PGSQLSRC in the common file has been modified to actually install the root directory of PostgreSQL and ensure that double quotes exist at both ends of the root directory.
- Similar errors are suggested: Min () or Max () is not a standard function of Std.
Make sure that line 34th of the Largeobject.cxx source file has been added to the header file #include <algorithm>.
- Prompts a heap of unresolved external functions.
If you are compiling a x86 version of Libpqxx, make sure that the PostgreSQL you installed is also a x86 version, and the same x64 version.
For
more compilation options and compilation instructions for LIBPGXX, refer to Common,install under libpqxx decompression path Win32 directory. TXT and Vc-libpgxx.mak files.
Graphical description of Visual Studio 2013 compiling libpqxx Steps and common compilation errors