PostgreSQL 错误:程序无法启动,因为您的计算机缺少 libpq.dll [英] PostgreSQL Error: The program can't start because libpq.dll is missing from your computer

查看:105
本文介绍了PostgreSQL 错误:程序无法启动,因为您的计算机缺少 libpq.dll的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Visual Studio 2010 在 C 中构建一个可以在 PostgreSQL 数据库上运行的程序.

I'm using Visual Studio 2010 to build a program in C that can operate on a PostgreSQL database.

在 VS 中一切正常,没有编译错误,一切看起来都很好.

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:

程序无法启动,因为您的计算机缺少 libpq.dll

我已经安装了 PostgreSQL 并将包含所有必要文件的文件夹添加到了我的 includelinker 路径中,但无济于事.我不明白为什么我仍然收到这条消息?

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?

有什么建议吗?

推荐答案

答案出奇的简单.

您看到的问题来自于编译的应用程序无法找到 PostgreSQL 库.libpq.lib 用于编译应用程序,并在运行时链接到 DLL.您可以将其添加到系统范围的路径中,也可以将 DLL 与您的应用程序捆绑在一起.(我会将它添加到开发机器上,并为安装程序包捆绑可再发行组件.)

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. 右键单击我的电脑"并选择属性
  2. 然后点击高级系统设置".
  3. 点击对话框底部的环境变量"按钮.
  4. 它将弹出一个对话框,其中包含一个标记为系统变量"的组框.在列表框中找到变量名称为Path"的那个.
  5. 现在,将 PostgreSQL 库文件夹的路径添加到带有;"的路径中分隔器.
  6. 现在注销或重新启动.必须您至少要退出 Windows 并重新登录,以便 Visual Studio 调试器获取附加的可执行模块路径(即 Path 变量).理想情况下,重新启动会在启动时将新系统路径发送到系统中的所有应用程序.
  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.

如果 Path 变量中有 "C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem",你需要添加 ";C:\Program Files\PostgreSQL\libraries" 来使它看起来像C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files\PostgreSQL\libraries".

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.

祝你好运!

这篇关于PostgreSQL 错误:程序无法启动,因为您的计算机缺少 libpq.dll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆