Where do I get libpq source?

i've no idea about header file, but you can get the lipq from repo, if you're using debian :

sudo apt-get install libpq-dev


Libpq is included in the full PostgreSQL source code. You can use just libpq without the rest of PostgreSQL, but must download the full package.

You can download it from the PostgreSQL Downloads page.

Once you extract the full package it is inside src\interfaces\libpq.

The PostgreSQL installation guide details how to install only the client libraries in the Installation section, under Client-only installation.

Libpq documentation is also available.


In postgresql sources, src\interfaces\libpq.

And yes, it is possible to compile only the libpq.


I was also facing this issue but didn't got a clear answer:
This issue clearly states that while installing diesel-cli system is not able to locate libpq.lib

First of all you should have a Postgres installed on your machine.
Also diesel require visual c++, thus download and install it if not already, the size of setup will be ~5gb.
Once above installations are done you need to setup environment variables:

In my case path of Postgres installation is C:\Program Files\PostgreSQL thus add 2 environment variable path under User variables add new in Path where your libpq.lib is located in my case it is available in both C:\Program Files\PostgreSQL\12\lib and C:\Program Files\PostgreSQL\12\bin

Env variable

Once this is added create one more environment variable PQ_LIB_DIR and set path as shown below

enter image description here

Note: Once done re-trigger the installation command in a new cmd window
Source: pq-sys and github-solution