Reputation: 23322
I'm using Visual Studio 2010 to build a program in C
that can operate on a PostgreSQL database.
Everything is fine in VS, no compile errors, everything looks good.
When I click to debug and run, the code compiles, but then I get a pop up that says:
The program can't start because libpq.dll is missing from your computer
I've installed PostgreSQL and added the folder containing all the necessary files to my include
and linker
paths, but to no avail.
I cannot figure out why I am still getting this message?
Any suggestions?
Upvotes: 15
Views: 44383
Reputation: 73
The selected answer is in the right direction, but didn't work for me. I would have just commented on it, but I don't have the XP to do that. For me, I had to add:
C:\Program Files\PostgreSQL\16\bin
and
C:\Program Files\PostgreSQL\16\include
to the PATH variable to get it to work (based on hours of going in circles and stumbling across this suggestion elsewhere).
TBH - I'm not totally sure which one got it to work, I didn't remove either to find out. But the Libraries certainly didn't work for me and somewhere in my research I saw a note about each of these using the same logic as above.
Upvotes: 1
Reputation: 13
Using the latest PostgreSQL 16 client installation, you need to copy the following additional libraries to successfully load libpq.dll:
libssl-3-x64.dll
libcrypto-3-x64.dll
libintl-9.dll
libiconv-2.dll
libwinpthread-1.dll
Note that the last two dependencies seem to be dynamically loaded and do not show in dumpbin.exe inspection. You can temporarily use psql.exe to receive feedback on the missing libraries though.
Upvotes: 0
Reputation: 1619
I have Win10 64 bit and this worked for me.
Get portable version of HeidiSQL and copy libpg.dll from the archive to the HeidiSQL installation folder on your computer.
Works like a charm.
Upvotes: 2
Reputation: 416
The answer's surprisingly simple.
The issue you're seeing comes from the compiled application not being able to find the PostgreSQL libraries. The libpq.lib is used to compile the application, and it links to the DLL at run-time. You can either add it to your system wide path, or bundle the DLL with your application. (I'd add it on the development machine, and bundle the redistributable for a installer package.)
To include it in your path try:
If the Path variable has "C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem" in it, you would add ";C:\Program Files\PostgreSQL\libraries" to make it look like "C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files\PostgreSQL\libraries".
Be aware that your path will be really long in most cases. Just add it to the end.
Good luck!
Upvotes: 20