GHC can't find library using "short" name
I wanted to build HDBC-postgresql 1.0.1 today, and ran into a problem where my test program would not load and instead gave this error:
can't load .so/.DLL for: pq (addDLL: unknown error)
I traced this to the 'extra-libraries' directive in the .cabal file. It read
When I changed it to
The error went away. Somehow "pq" is not enough to get "libpq.dll" loaded.
Note that building on Windows required some other changes.
This was using Cabal 1.1
To build on Windows, you must specify where the postgresql include and library files are. Follow these two steps:
- Ensure the files are NOT installed in a directory with spaces in the name (e.g. "C:\Program Files"). For example, install them in c:\pgsql.
- Assuming postgresql is installed in C:\pgsql, add the following information to the .cabal file:
include-dirs: C:\pgsql\include, C:\pgsql\include\server, . extra-lib-dirs: C:\pgsql\bin
Notice the "." at the end of include-dirs to ensure the current directory is also searched. Also notice "bin" directory is specified in "extra-lib-dirs." This is important in the next step.
- HDBC-postgresl depends on "libpa.dll" in the bin directory above. The .cabal file refers to the "pq", but that doesn't work on Windows. Change it to libpq like so: