<tfoot id='juimx'></tfoot>
      1. <legend id='juimx'><style id='juimx'><dir id='juimx'><q id='juimx'></q></dir></style></legend>
      2. <small id='juimx'></small><noframes id='juimx'>

          <bdo id='juimx'></bdo><ul id='juimx'></ul>
      3. <i id='juimx'><tr id='juimx'><dt id='juimx'><q id='juimx'><span id='juimx'><b id='juimx'><form id='juimx'><ins id='juimx'></ins><ul id='juimx'></ul><sub id='juimx'></sub></form><legend id='juimx'></legend><bdo id='juimx'><pre id='juimx'><center id='juimx'></center></pre></bdo></b><th id='juimx'></th></span></q></dt></tr></i><div id='juimx'><tfoot id='juimx'></tfoot><dl id='juimx'><fieldset id='juimx'></fieldset></dl></div>

        使用 Visual Studio 链接到第 3 方库

        时间:2023-08-28

              <tbody id='dd3z2'></tbody>

            <i id='dd3z2'><tr id='dd3z2'><dt id='dd3z2'><q id='dd3z2'><span id='dd3z2'><b id='dd3z2'><form id='dd3z2'><ins id='dd3z2'></ins><ul id='dd3z2'></ul><sub id='dd3z2'></sub></form><legend id='dd3z2'></legend><bdo id='dd3z2'><pre id='dd3z2'><center id='dd3z2'></center></pre></bdo></b><th id='dd3z2'></th></span></q></dt></tr></i><div id='dd3z2'><tfoot id='dd3z2'></tfoot><dl id='dd3z2'><fieldset id='dd3z2'></fieldset></dl></div>
            • <tfoot id='dd3z2'></tfoot>

              <legend id='dd3z2'><style id='dd3z2'><dir id='dd3z2'><q id='dd3z2'></q></dir></style></legend>

              <small id='dd3z2'></small><noframes id='dd3z2'>

                • <bdo id='dd3z2'></bdo><ul id='dd3z2'></ul>
                • 本文介绍了使用 Visual Studio 链接到第 3 方库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试使用 Visual Studios 2013 创建一个 .dll.该项目包括 libpq 功能.

                  I'm trying to create a .dll with Visual Studios 2013. The project includes libpq functionality.

                  根据我在 Internet 上找到的其他 stackoverflow 帖子和其他来源,我(据我所知)已正确地将 postgres 库和包含目录添加到项目中.但是,当我开始构建项目时,它会返回许多未解析的外部符号"错误.

                  Per other stackoverflow posts, and other sources I've found on the internet, I've (as far as I'm aware) correctly added the postgres lib and include directories to the project. However, when I go to build the project, it returns a number of "unresolved external symbol" errors.

                  我的路径是 C:Program FilesPostresSQL9.3... 所以我在附加库/包含目录字段中用引号将它们括起来.我已经在项目中包含了 libpq-fe.h 头文件......我只是不确定我做错了什么.

                  My paths are C:Program FilesPostresSQL9.3... so I have them surrounded by quotation marks in the Additional Library/Include Directory fields. I've included the libpq-fe.h header file in the project... I'm just not sure what I'm doing wrong.

                  另一个注意事项,我可以使用带有 -I、-L 和 -lpq 标志的 g++ 从命令行编译测试程序,但我不确定如何从命令行编译为 .dll(加上它增加了我不想处理的复杂性).

                  Another note, I can compile a test program from the command line using g++ with the -I, -L, and -lpq flags, but I'm not sure how to compile to a .dll from the command line (plus it adds complexity that I just don't want to deal with).

                  这些是我遇到的具体错误:

                  These are the specific errors I'm getting:

                  1>sql_arma.obj : error LNK2001: unresolved external symbol _PQconnectdb
                  1>sql_arma.obj : error LNK2001: unresolved external symbol _PQstatus
                  1>sql_arma.obj : error LNK2001: unresolved external symbol _PQerrorMessage
                  1>sql_arma.obj : error LNK2001: unresolved external symbol _PQfinish
                  1>C:Users	ills13documentsvisual studio 2013Projectssql_armaReleasesql_arma.dll : fatal error LNK1120: 4 unresolved externals
                  

                  我已经按照下面的建议在我的项目的源文件中包含了 #pragma comment(lib, "libpq.lib"),但我仍然收到这些错误.

                  I have, as suggested below, included #pragma comment(lib, "libpq.lib") in the source file for my project, I still receive these errors.

                  推荐答案

                  我已经成功编译了 示例程序 通过设置这些项目属性:

                  I've successfully compiled the sample program by setting these project properties:

                  • includelib 添加到 VC++ Directory->Include->Library,相应地
                  • libpq.lib 添加到 Linker->Input->Additional dependencies
                  • Add <pgsql install path>include and lib to VC++ Directories->Include and ->Library, correspondingly
                  • Add libpq.lib to Linker->Input->Additional dependencies

                  这是引用第 3 方库的标准方法.只是他们建议为他们的基本目录"使用环境变量,以避免在 VCS 下修补项目.

                  This is the standard way to reference 3rd-party libs. It's just that they recommend using environment variables for their "base dirs" to avoid patching the project when it's under a VCS.

                  • 为了能够从 VS 运行应用程序(有和没有调试),我还在 Debugging- 中指定了 PATH=%PATH%;<pgsql install path>in>环境,因为这个目录不在我系统的 PATH 中.
                  • To be able to run the app from VS (both with and without debugging), I also specified PATH=%PATH%;<pgsql install path>in in Debugging->Environment since this dir isn't in PATH on my system.

                  这篇关于使用 Visual Studio 链接到第 3 方库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何将未知大小的字符串从 DLL 返回到 Visual Basic 下一篇:线程对象的 WaitForSingleObject 在 DLL 卸载中不起作用

                  相关文章

                  1. <small id='lBChl'></small><noframes id='lBChl'>

                    <tfoot id='lBChl'></tfoot>
                      <legend id='lBChl'><style id='lBChl'><dir id='lBChl'><q id='lBChl'></q></dir></style></legend>
                      <i id='lBChl'><tr id='lBChl'><dt id='lBChl'><q id='lBChl'><span id='lBChl'><b id='lBChl'><form id='lBChl'><ins id='lBChl'></ins><ul id='lBChl'></ul><sub id='lBChl'></sub></form><legend id='lBChl'></legend><bdo id='lBChl'><pre id='lBChl'><center id='lBChl'></center></pre></bdo></b><th id='lBChl'></th></span></q></dt></tr></i><div id='lBChl'><tfoot id='lBChl'></tfoot><dl id='lBChl'><fieldset id='lBChl'></fieldset></dl></div>
                      • <bdo id='lBChl'></bdo><ul id='lBChl'></ul>