-
Notifications
You must be signed in to change notification settings - Fork 26
WindowsInstall
Installing HDBC-postgres on Windows requires very specific steps.
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:
- Run
pexports
onlibpq.dll
to create a DEF file:pexports "C:\Program Files (x86)\PostgreSQL\9.1\lib\libpq.dll" >libpq.def
- 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
- Copy
libpq.a
from the current directory toC:\Program Files (x86)\PostgreSQL\9.1\lib
. - 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
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:
-
pexports "C:\Program Files\PostgreSQL\9.1\lib\libpq.dll" >libpq.def
-
"C:\Program Files\Haskell Platform\2011.2.0.1\mingw\bin\dlltool.exe" -d libpq.def -l libpq.a
- Copy
libpq.a
from the current directory toC:\Program Files\PostgreSQL\9.1\lib
. - 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
The following information only applies to versions prior to 2.0
- 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, .
- 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
- 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".
- 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.
- 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.