Installing libpqxx under PostgreSQl with an Visual Studio .net 2003 without Cygwin, MSYS etc ============================================================================================= Welcome to libpqxx, a C++ API to the PostgreSQL database management system. This File is based on INSTALL.txt in win32\ from source distribution of the great libpqxx Library by jtv. It reports the experience installing libpqxx 2.6.2 under PostgreSQl 8.1.2. under WinXP with an Visual Studio .net 2003 (both german) without Cygwin, MSYS etc. Following steps are adapted from the INSTALL.txt and modified if the hints doesn't work. To get started quickly on a Windows system, use the command line. I Make sure, that you have libpq.dll and libpqdll.lib interface libraries to PostgreSQL. 1) Usuallly if you've build up Postgres from source, it could be found in PostgreSQL\8.1\src\interfaces\libpq\Release. If you have PostgreSQL installed from binary via the graphical installer(msi), it was in my Case not sufficient to check Include and Library Files on. If you're unsure, search for it. If you've found libpqdll.lib, you can continue with II. 2) To get libpqdll.lib, you have to build it from source. Therefore download the source from http://www.postgresql.org/ftp/source/ an unzip it in the same directory as PostgreSQL is installed. Then the subdirectories src/ and bin/ should be adjoin each other. 3) Run VCVARS32.BAT to prepare the environment. (or klick VS.net Command Prompt) 4) Change working directory to the src\ of PostgreSQL and run win32 makefile: nmake.exe /f win32.mak This should be completed with the message: "All Win32 parts have been built!" You find the generated libraries in the src\interfaces\libpq\Release\ directory II Build libpqxx 1) Unzip all files of libpqxx-2.6.2.tar.gz into a Directory, e.g. C:\Programme\libpqxx\ (on german WindowsXP, otherwise C:\program files\ ...) 2) Edit the file win32/common to reflect the correct paths to your PostgreSQL includes and library files. In my case (installed in C:\Programme\PostgreSQL) this were: PGSQLSRC="C:/Programme/PostgreSQL/8.1" LIBPATH=/libpath:"C:/Programme/PostgreSQL/8.1/src/interfaces/libpq/Release/" 3) Create the configuration headers include/pqxx/config-*-*.h. by copying all from \config\sample-headers\compiler\VisualC++.NET-2003 and \config\sample-headers\libpq\8.0 into include/pqxx/. 4) If not open, run VCVARS32.BAT to prepare the environment. (VS.net Command Prompt) 5) Now change into win32\ of your lippqxx dir (C:\Programme\libpqxx\win32) and "nmake /f libpqxx.mak ALL" will compile all dynamic, static, debug and release libraries. You will find them in the win32/lib directory. Unfortunately nmake stops with th following message, but everything needed is in /win32/lib/ except.obj : warning LNK4217: Lokal definiertes Symbol ??_7internal_error@pqxx@@6B@ (const pqxx::internal_error::`vftable'), importiert in Funktion "public: __thiscall pqxx::internal_error::internal_error(class std::basic_string,class std::allocator > const & )" (??0internal_error@pqxx@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) #-@erase "lib\libpqxxD.pdb" Der Befehl "#-@erase" ist entweder falsch geschrieben oder konnte nicht gefunden werden. NMAKE : fatal error U1077: '#-@erase': R³ckgabe-Code '0x1' Stop. NMAKE : fatal error U1077: '"C:\Programme\VS.net 2003\VC7\BIN\nmake.exe"': R³ckgabe-Code '0x2' Stop. :-( After that, it is recommended that you compile and run the self-test programs included in the package. (from original INSTALL.txt) 6) "nmake /f test.mak ALL" will compile and link all the test files. It is currently set to use the DLL version of libpqxx. 7) Make sure a PostgreSQL database is running and accessible; set up the environment as described in README so that the test programs can access the database without passing a connection string. 8) Run each of the test programs in order. Some of them will generate lots of output, some won't produce any. Error messages that are expected in the course of a normal test run are prefixed with "(Expected)" to show that they are not harmful. All tests should complete successfully. In my case nmake stops with an error at test009, but at the moment this was enough at the first time. III Create a Visual Studio Project. 1) Create a new project, I first start with an empty console project. 2) Add a C++ file and put some sample code in it, e.g. by copying from the test001.cxx in ...\libpqxx\test 3) Edit Project Properties, C++: Additional Include-Dirs: C:\Programme\libpqxx\include 4) Edit Project Properties, Linker: Additional Lib-Dirs: C:\Programme\libpqxx\win32\lib;C:\Programme\PostgreSQL\8.1\src\interfaces\libpq\Release 5) Edit Project Properties, Linker: Additional Dependencies: libpqxx.lib 6) The Project should be successfully compiled. 7) Copy both comerr32.dll, krb5_32.dll from ...\PostgreSQL\8.1\bin\ and libpqxx.dll from C:\Programme\libpqxx\win32\lib\ simply into the project dir of your VS.net Project, otherwise your exe will not start with a message about this missing files. 8) Run Release Configuration (Strg+F5): works fine! 9) If you have a blank/ sparse connection string, don't forget to set PGDATABASE, PGHOST, PGPORT and PGUSER as described in ..\libpqxx\README Therefore you open a Command Prompt and for instance set PGDATABASE= testbase 10) To avoid this add a connection string (instead of connection C; ) e.g.: string sConnectParams = "dbname=testbase user=postgres password=no host=localhost"; connection C( sConnectParams ); Then program starts from IDE 11) Problems with Debug Configuration: Running the programm I get at start one in malloc.c and at the end four uncaught exceptions in free.c :-( But expect from this the Debugger works. Im using a german Windows XP pro, but this should work on other language Versions too, paths should start with C:\program files\... Sources: http://thaiopensource.org/development/libpqxx/ especially win32/INSTALL.txt in sources http://mailman.vex.net/pipermail/pygresql/2004-September/001346.html If you have any further hints & recommendations... hanft@iis.uni-hildesheim.de 2006-01-31