prepare before compiling
1. Installing mingw
installation MinGW (either directly installed MinGW or the others as Code :: blocks supplied with installed MinGW ), enter: gcc-v can display the version information like, my version is Mingw32 4.9.2 .
2.installationPostgreSQL
PostgreSQL address under each version: http://www.enterprisedb.com/products-services-training/pgdownload#windows
Note: To download the MinGW The compiler corresponds to the version, if it is Mingw32 please download 32bit Install the package or compile the package; mingw64 , please download 64bit Install the package or compile the package.
Why to install PostgreSQL ?
Libpqxxis based onLIBPQof theC + +implementation,libpqxx LIBPQ good encapsulation Developers can save a lot of coding time when they use it. If you feel that you c level is good, you can go directly to use LIBPQ
LIBPQ method of compiling: https://www.postgresql.org/docs/9.5/static/install-windows-libpq.html " PostgreSQL the documentation is really full. "
3.libpqxxcompiling
Libpqxx : http://pqxx.org/download/software/libpqxx/
The downloaded version is:libpqxx-4.0.1
After extracting the downloaded file, go to directory libpqxx-4.0.1\win32, copy the common-sample file, modify the file name to Common.
Open The commonand modify the following (' # ' for the shield symbol):
#PGSQLSRC = "C:\Sources\postgresql-9.1.1\src"
Pgsqlsrc= "C:\Program Files (x86) \postgresql\9.5"
#LIBPQINC =$ (PGSQLSRC) \INTERFACES\LIBPQ
libpqinc=$ (PGSQLSRC) \include
#LIBPQPATH =$ (PGSQLSRC) \interfaces\libpq\release
#LIBPQDLL =libpq.dll
#LIBPQLIB =libpqdll.lib
libpqpath=$ (PGSQLSRC) \lib
Libpqdll=libpq.dll
Libpqlib=libpq.lib
#LIBPQDPATH =$ (PGSQLSRC) \interfaces\libpq\debug
#LIBPQDDLL =libpqd.dll
#LIBPQDLIB =libpqddll.lib
libpqdpath=$ (PGSQLSRC) \lib
Libpqddll=libpq.dll
Libpqdlib=libpq.lib
Save after the modification is complete.
will be libpqxx-4.0.1\config\sample-headers\compiler\mingw-3.4\pqxx\ All header files in the directory are copied to include\pqxx under the catalogue ;
will be libpqxx-4.0.1\config\sample-headers\libpq\9.0\pqxx\ All header files in the directory are copied to Include\pqxx directory.
Switch to libpqxx-4.0.1\ directory, run the command: mingw32-make-f Win32\mingw.mak All .
If you follow the above action, you should complete Libpqxx compile.
installation PostgreSQL Be sure to install the version corresponding to the compiler, otherwise it will be reported at compile time . DLL Reference Error
Access the PostgreSQL database using Libpqxx (MinGW compiled libpqxx)