Skip to content

WindowsInstall

dtrebbien edited this page Nov 3, 2012 · 2 revisions
Clone this wiki locally

Installing HDBC-postgres on Windows requires very specific steps.

Using cabal install

64-bit Windows

The following steps were written for 64-bit Windows 7 Home Premium, 32-bit PostgreSQL 9.1.1, and Haskell Platform 2011.2.0.1.

The 32-bit PostgreSQL 9.1.1 installer for Windows does not install the MinGW import library (A archive) for libpq.dll to the lib directory. However, it is possible to create an import library using the instructions at HOWTO Create an Import Library for a DLL using MinGW.

In a temporary directory:

  1. Run pexports on libpq.dll to create a DEF file:
    pexports "C:\Program Files (x86)\PostgreSQL\9.1\lib\libpq.dll" >libpq.def
    
  2. Use Haskell Platform's mingw's dlltool to produce an import library from the DEF file:
    "C:\Program Files (x86)\Haskell Platform\2011.2.0.1\mingw\bin\dlltool.exe" -d libpq.def -l libpq.a
    
  3. Copy libpq.a from the current directory to C:\Program Files (x86)\PostgreSQL\9.1\lib.
  4. Delete the DEF file, libpq.def, as it is no longer needed.

Now run cabal install with:

cabal install HDBC-postgresql --extra-include-dirs=C:\Progra~2\PostgreSQL\9.1\include --extra-lib-dirs=C:\Progra~2\PostgreSQL\9.1\lib

32-bit Windows

The steps for 32-bit Windows are similar to the steps above for 64-bit Windows, except that C:\Program Files (x86) is replaced with C:\Program Files and C:\Progra~2 is replaced with C:\Progra~1:

In a temporary directory:

  1. pexports "C:\Program Files\PostgreSQL\9.1\lib\libpq.dll" >libpq.def
    
  2. "C:\Program Files\Haskell Platform\2011.2.0.1\mingw\bin\dlltool.exe" -d libpq.def -l libpq.a
    
  3. Copy libpq.a from the current directory to C:\Program Files\PostgreSQL\9.1\lib.
  4. Delete the DEF file, libpq.def, as it is no longer needed.

Now run cabal install with:

cabal install HDBC-postgresql --extra-include-dirs=C:\Progra~1\PostgreSQL\9.1\include --extra-lib-dirs=C:\Progra~1\PostgreSQL\9.1\lib

Prior to version 2.0

The following information only applies to versions prior to 2.0

  1. In HDBC-postgresql.cabal, update include-dirs to point to your PostgreSQL installation. Make sure there are no spaces in the pathname. That is, if you've installed to "C:\Program Files" you're going to have trouble. Move your PostgreSQL installation to something like "C:\pgsql". Using that directory, your include-dirs should look like:
    include-dirs: c:\pgsql\include, c:\pgsql\include\server, .
    
  2. Update extra-lib-dirs to point to the directory containing libpq.a. If you've installed PostgreSQL to "c:\pgsql", then this would be "c:\pgsql\lib". E.g.:
    extra-lib-dirs: c:\pgsql\lib
    
  3. Add the directory containing libpq.DLL (not .a) to your path. This will be necessary for any program built using this library to run properly. Using the directory above, this would would "c:\pgsql\bin".
  4. In the same directory as step 3, copy "libpq.dll" to "pq.dll". This is not strictly necessary, but is required if you want to use this library in GHCi.
  5. That's it - you are ready to run the setup steps above!

If, when building programs using the library, you ever see the message

Info: resolving _PQntuples by linking to +imp+PQntuples (auto-import)

Then one of the steps above was skipped. Your executables will not run if this message appears.

Note that these instructions were developed against GHC 6.6.1, HDBC-postgresql 1.0.1.0 and PostgreSQL 8.2.5.

Something went wrong with that request. Please try again.