在Windows 10上从Visual Studio 2015链接libpqxx [英] Linking libpqxx from Visual Studio 2015 on Windows 10

查看:992
本文介绍了在Windows 10上从Visual Studio 2015链接libpqxx的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近决定尝试使用PostgreSQL作为我正在开发的一些C ++开发的数据库平台。我决定使用libpqxx作为我的项目的连接库,很快发现这将是一个艰难的战斗,从VS 2015在Windows 10机器上。

I've recently decided to try out PostgreSQL as the database platform for some C++ development I'm working on. I decided to use libpqxx as the connection library for my project, and quickly found out this would be an uphill battle to do from VS 2015 on a Windows 10 machine.

After我已经得到libpqxx在Windows 10上编译。
这让我有以下目录结构

After much teeth-gnashing and nail-biting, I have gotten libpqxx to compile on Windows 10. This leaves me with the following directory structure

根据libpqxx的文档,我还在我项目的可执行文件目录中放了一个libpq.dll的副本。请注意:我已经为调试和发布版本做了这个,试图建立两个,并得到相同的结果。

Per libpqxx's documentation, I also placed a copy of libpq.dll in my project's executable directory. Please note: I have done this for both debug and release builds, tried to build both, and ended up with the same result.

我看到的所有教程以指示该库可以在链接它和简单地使用#include pqxx / pqxx之后使用,所以我设置了一个小项目来做到这一点。我收到错误:

All the tutorials I've seen seem to indicate that the library can be used after linking it and simply #including pqxx/pqxx, so I set up a small project to do just that. I receive the error:


致命错误C1083:无法打开包含文件:'pqxx / pqxx':没有此类文件或目录

fatal error C1083: Cannot open include file: 'pqxx/pqxx': No such file or directory

尝试构建项目时。我也试过这个将调试和发布版本,无济于事。

When attempting to build the project. I have also tried this will both debug and release builds, to no avail.

这里是一个截图我的链接器设置。

Here is a screenshot of my linker settings.

有没有人有任何建议,如何我可以链接和从Visual Studio 2015中使用这个库?

Does anyone have any suggestions for how I might be able to link and use this library from Visual Studio 2015?

推荐答案

正如Sami Kuhmonen指出的,这不是一个链接器错误,错误。我需要包括一个实际的头,Visual Studio需要能够找到。在添加正确的文件夹(在我的情况下,C:\libpqxx\include)到Visual Studio的附加包含目录设置在C \ C ++ - > General per drescherjm的建议,该程序编译就好了。

As Sami Kuhmonen pointed out, this was not actually a linker error, but a compiler error. I needed to include an actual header, which Visual Studio needed to be able to find. After adding the correct folder (C:\libpqxx\include in my case) to Visual Studio's "additional include directories" setting under C\C++ -> General per drescherjm's suggestion, the program compiles just fine.

以后参考:
在解决初始问题后,我也遇到了未解决的外部链接器错误。这是因为你需要确保还链接到ws2_32.lib和libpq.lib。您还需要将libpq还依赖的一些其他DLL文件复制到libpqxx lib文件夹中。在我的系统上,我相信这些是ssleay32.dll,libeay32.dll和libintl-8.dll。这些文件驻留在PostgreSQL安装的根目录下。 DLL步骤在libpqxx的INSTALL.txt文件中提到,但我相信它说的DLL位于一个文件夹下,我实际发现它们。

For future reference: I did also run into unresolved external linker errors after solving the initial issue. This is because you need to make sure to also link to ws2_32.lib and libpq.lib. You also need to copy some other DLL files that libpq also relies on into your libpqxx lib folder. On my system, I believe these were ssleay32.dll, libeay32.dll, and libintl-8.dll. These files reside under the root of the PostgreSQL install. The DLL step is mentioned under libpqxx's INSTALL.txt file, however I believe it stated that the DLLs resided one folder under where I actually found them.

这篇关于在Windows 10上从Visual Studio 2015链接libpqxx的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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