Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PostgreSQL Error: The program can't start because libpq.dll is missing from your computer

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?

like image 550
CodyBugstein Avatar asked Dec 05 '13 22:12

CodyBugstein


People also ask

What is Libpq DLL?

dll, File description: PostgreSQL Access Library.

Can t find libpq DLL?

Method 1: Download Libpq.Copy the file to the program install directory after where it is missing the DLL file. Or move the DLL file to the directory of your System (C:\Windows\System32, and for a 64 bit in C:\Windows\SysWOW64\). Now you need to reboot the computer.


1 Answers

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:

  1. Right click on "My Computer" and select Properties
  2. Then Click on "Advanced System Settings".
  3. Click the "Environment Variables" button at the bottom of the dialog box.
  4. It will pop up a dialog with a group box labeled "System Variables". Find the one in the list box that has a Variable name of "Path".
  5. Now, add the path of the PostgreSQL library folder to the path with a ";" separator.
  6. Now logout or reboot. It's imperative that you at least log out of Windows and log back in for the Visual Studio debugger to pickup the additional executable module paths (that Path variable). Ideally, rebooting sends the new system path to all applications in the system at boot time.

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!

like image 122
Phorkus Maximus Avatar answered Oct 10 '22 19:10

Phorkus Maximus