窗口链接

发布于 2024-12-02 05:49:19 字数 1219 浏览 2 评论 0原文

我正在尝试使用 SCons 来编译和链接一个简单的 Windows 程序。我有两个需要编译的文件,httprequest.cpp 和curltest.cpp。首先,我想从 httprequest.*pp 文件创建一个库。这些文件依赖于 libcurl.lib 库,该库也在我的源代码中。

编译完成后,我会尝试将curltest.cpp编译为.exe(也依赖于libcurl.lib库)。但是,我不断收到如下错误:

httpreq.lib(httprequest.obj) : error LNK2019: unresolved external symbol __imp__curl_easy_setopt referenced in function "public: __thiscall HTTPRequest::HTTPRequest(void)" (??0HTTPRequest@@QAE@XZ)

尽管显式链接到 libcurl.lib (我已确认 - 使用 nm - 具有可用的方法 __curl_easy_setopt 等),但当 httpreq.lib 尝试查找时,我遇到了问题libcurl 方法。

如何在 libcurl.lib 中链接到 httpreq 库和curltest 可执行文件而不会出现问题?

编辑:这是我的 SConstruct 文件,它在 Ubuntu 11.04 下构建和链接得很好。

httpreq = 'src//httprequest.cpp'
StaticLibrary('httpreq', httpreq)
env = Environment(
                    CPPPATH = ['#//include//curl',
                                '#//src'
                                ],

                    LIBPATH = ['#//bin',
                                '#//'
                                ],

                    LIBS = ['libcurl',
                            'httpreq'
                            ]
                )
curltest = ['src//curltest.cpp']
env.Program('test', curltest)

I'm attempting to use SCons to compile and link a simple Windows program. I have two files that need compilation, httprequest.cpp and curltest.cpp. First, I'd like to make a library from the httprequest.*pp files. These files rely on the libcurl.lib library which is also in my source code.

Once this is compiled I then attempt to compile the curltest.cpp into an .exe (also relying on the libcurl.lib library). However, I keep getting errors like:

httpreq.lib(httprequest.obj) : error LNK2019: unresolved external symbol __imp__curl_easy_setopt referenced in function "public: __thiscall HTTPRequest::HTTPRequest(void)" (??0HTTPRequest@@QAE@XZ)

Despite explicitly linking to the libcurl.lib (which I've confirmed -- using nm -- has the available methods __curl_easy_setopt and the like) I'm encountering problems when the httpreq.lib tries to find the libcurl methods.

How can I link in the libcurl.lib to both the httpreq library and the curltest executable without problems?

EDIT: This is my SConstruct file which builds and links just fine under Ubuntu 11.04.

httpreq = 'src//httprequest.cpp'
StaticLibrary('httpreq', httpreq)
env = Environment(
                    CPPPATH = ['#//include//curl',
                                '#//src'
                                ],

                    LIBPATH = ['#//bin',
                                '#//'
                                ],

                    LIBS = ['libcurl',
                            'httpreq'
                            ]
                )
curltest = ['src//curltest.cpp']
env.Program('test', curltest)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

安静 2024-12-09 05:49:19

这似乎是 libcurl 常见问题解答中已经回答的问题。

关键是要在Windows上使用静态libcurl库,必须在编译时定义CURL_STATICLIB。

This seems to be a question answered in the libcurl FAQ already.

The key is that to use a static libcurl lib on windows, you must define CURL_STATICLIB at compile time.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文