0

I am trying to set up a stack project that uses the postgresql-simple package among others. When trying to stack build, all of the dependencies for postgresql-simple installed without issue, but stack is having trouble installing postgresql-simple itself. I get the following error:

C:project> stack build --extra-include-dirs="C:\PostgreSQL\8.4\include" --extra-lib-dirs="C:\PostgreSQL\8.4\lib"

... omitted ...

*****************
--extra-include-dirs=C:\PostgreSQL\8.4\include
*****************
--extra-include-dirs=C:\Users\User\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw32\include 
--extra-include-dirs=C:\Users\User\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include 
*****************
--extra-lib-dirs=C:\PostgreSQL\8.4\lib
***************************** 
--extra-lib-dirs=C:\Users\User\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw32\lib 
--extra-lib-dirs=C:\Users\User\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\lib
Process exited with code: ExitFailure 1
Logs have been written to: C:\Users\User\Desktop\draftkings\NFAccuracy\.stack-work\logs\postgresql-libpq-0.9.1.1.log

Configuring postgresql-libpq-0.9.1.1...
Setup.hs: Missing dependency on a foreign library:
* Missing C library: pq
This problem can usually be solved by installing the system package that
provides this library (you may need the "-dev" version). If the library is
already installed but in a non-standard location then you can use the flags
--extra-include-dirs= and --extra-lib-dirs= to specify where it is.

I've tried also specifying the paths in my stack.yaml file, same error.

I've tried manually copying the library and include files from my postgres installation to the mentioned ...\mingw64\lib and ...\mingw64\include folders. Same error.

I have the files libpq.dll and libpq.lib in my C:\PostgreSQL\8.4\lib folder.

I feel like I'm missing something obvious but I can't get this to work and I'm not sure what I'm doing wrong. Any help is appreciated.

Update

I forgot to mention two important details.

First, I have added C:\PostgreSQL\8.4\bin to my PATH. As far as I know, this works as expected, because I got past an error about pg_config missing, to the error I currently have.

Second, I also tried adding the lib and include directories to my PATH, but this did not change the error.

I should also mention my Postgres installation works fine on its own.

parker.sikand
  • 1,371
  • 2
  • 15
  • 32

2 Answers2

1

I know that the Snowdrift project uses PostgreSQL and builds with Stack on Windows. They have a build guide on their site. It looks like one difference is that they mention:

Add the PostgreSQL bin directory to the path C:\Program Files (x86)\PostgreSQL\9.4\bin

Can you try adding that to the PATH and see if that fixes it?

Michael Snoyman
  • 31,100
  • 3
  • 48
  • 77
  • Thanks for your response. I forgot to mention I had already done that. See updated question. I will look at the build guide to see if there is something else I missed. – parker.sikand Oct 15 '15 at 11:31
  • Using Postgres 9.4 seemed to work. I was trying 8.4 because it matched my remote server. Still investigating. – parker.sikand Oct 15 '15 at 12:04
  • Using Postgres 9.4 as my 'client' has made my haskell code work fine, even when communicating with a remote Postgres 8.4 database. It seems that the version requirements for the Postgres client libraries are undocumented. For me, everything is good now. Thank you for your attention Michael. – parker.sikand Oct 23 '15 at 06:04
1

There was some kind of version mismatch.

Installing Postgres 9.4 instead of 8.4 allowed the postgresql-simple package to be built in the manner I was attempting.

My stack project, without intervention by me, defaulted to using resolver: 'lts-3.7' This provided version 0.4.10.0 of the postgresql-simple package to my project. I wish I had a more detailed answer, but all I can tell is that this version of postgresql-simple (which is fairly recent) works fine with PostgreSQL 9.4 (which is also recent).

And thankfully, using haskell and postgresql-simple built against Postgres 9.4 libraries is having no issue communicating with my 'remote' (virtualbox) database which is Postgres 8.4.

I'm tempted to flag my question as not constructive unless others find this useful info.

parker.sikand
  • 1,371
  • 2
  • 15
  • 32