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

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

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

        将静态 libcurl 添加到 Code::Blocks IDE

        Adding static libcurl to Code::Blocks IDE(将静态 libcurl 添加到 Code::Blocks IDE)

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

              <tfoot id='IVW2G'></tfoot>
                <bdo id='IVW2G'></bdo><ul id='IVW2G'></ul>

                  <tbody id='IVW2G'></tbody>

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

                  本文介绍了将静态 libcurl 添加到 Code::Blocks IDE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我不知道如何将静态 libcurl 库正确添加到我的 Code::Blocks IDE.我希望它是静态的,因为在我的程序运行期间不需要 Windows 中默认不包含的 .dll 文件.我正在使用这个 libcurl:http://curl.haxx.se/dlwiz/?type=lib&os=Win32&flav=-(没有 OpenSSL 的 minGW)

                  I can't figure out how to properly add a static libcurl library to my Code::Blocks IDE. I want it static because then no .dll files, which are not included in Windows by default, are needed during runtime of my program. I am using this libcurl: http://curl.haxx.se/dlwiz/?type=lib&os=Win32&flav=- (minGW without OpenSSL)

                  这是我的全局编译器设置:http://img845.imageshack.us/img845/1381/halpr.jpg

                  Here are my global compiler settings: http://img845.imageshack.us/img845/1381/halpr.jpg

                  我收到以下错误:

                  ld.exe||找不到 -lCURL_STATICLIB|||==== 构建完成:1 个错误,0 个警告 ===|

                  ld.exe||cannot find -lCURL_STATICLIB| ||=== Build finished: 1 errors, 0 warnings ===|

                  编译此代码时:

                  include <stdio.h>
                  include <curl/curl.h>
                  
                  int main(void)
                  {
                  CURL *curl;
                  CURLcode res;
                  
                  curl = curl_easy_init();
                  if(curl) {
                  curl_easy_setopt(curl, CURLOPT_URL, "http://google.com");
                  res = curl_easy_perform(curl);
                  
                  /* always cleanup */
                  curl_easy_cleanup(curl);
                  }
                  return 0;
                  }
                  

                  显然它没有找到 CURL_STATICLIB,因此我不知道为什么.我什至不确定是否需要将 CURL_STATICLIB 添加到我的链接器设置中(我在其他论坛上阅读过).我发现有些人有同样的问题,但在任何地方都没有正确回答:

                  Obviously it does not find CURL_STATICLIB, thu I got no idea why. I am not even sure if it was needed to add CURL_STATICLIB to my linker settings(I read it on other forums). I found some guys having same problem, but it isn't properly answered on any place:

                  stackoverflow.com/questions/4176503/frustrated-with-libcurl

                  stackoverflow.com/questions/4176503/frustrated-with-libcurl

                  forums.codeblocks.org/index.php?topic=11391.0

                  forums.codeblocks.org/index.php?topic=11391.0

                  old.nabble.com/gcc-working-with-libcurl-td20506927.html

                  old.nabble.com/gcc-working-with-libcurl-td20506927.html

                  forums.devshed.com/c-programming-42/linker-error-using-libcurl-698071.html

                  forums.devshed.com/c-programming-42/linker-error-using-libcurl-698071.html

                  我已经厌烦了,请帮帮我.

                  I am so tired of fighting with this, please help me.

                  您好维克多,感谢您的回复!

                  Hello Victor, thank you for response!

                  我会尽量详细,以免造成误解.所以,这是我的 C:libs 文件夹的目录/文件夹树的图像:

                  I will try to be as detailed as possible, so there are no missunderstandings. So, here is the image of the directory/folder tree for my C:libs folder:

                  http://img199.imageshack.us/img199/6977/curl1.png

                  如你所见,它还包括构建日志,你会注意到这次的错误是与我之前发布的不同.这是因为我更改了全局编译器和构建项目设置.

                  As you can see, it also includes build log, you will notice that the error this time is different than the one I posted previously. It's because I changed global compiler and build project settings.

                  我的新构建项目设置:http://img863.imageshack.us/img863/4404/buildoptions.png我的新全局编译器设置:http://img225.imageshack.us/img225/4926/curl2.png

                  My new Build Project settings: http://img863.imageshack.us/img863/4404/buildoptions.png My new Global Compiler settings: http://img225.imageshack.us/img225/4926/curl2.png

                  我确定我配置了这些设置错误,这就是我无法编译它的原因.

                  I am sure I have configured these settings wrong and that's why I can not compile it.

                  推荐答案

                  好的,我使用静态链接成功地使用 libcurl 构建了您的示例.使这项工作所涉及的细节非常复杂 - 正确设置它对于粗心的人来说可能会变得棘手.

                  Okay, I managed to build your example successfully with libcurl using static linkage. The details involved to make this work are quite intricate -- setting it up correctly can get tricky for the unwary.

                  以下是我用来完成这项工作的步骤,请务必仔细遵循:

                  Here are the steps I used to make this work, be sure to follow them carefully:

                  1. 转到项目构建选项->编译器设置->#defines:输入CURL_STATICLIB.定义后,libcurl.h 标头将对其函数签名进行预处理以适应静态链接.否则,假定动态链接,并且损坏的名称将变为 _imp__*.屏幕截图中未解决的错误表明它正在尝试动态链接而不是所需的静态链接.

                  1. Go to Project build options->Compiler settings->#defines: type in CURL_STATICLIB. When this is defined the libcurl.h header will have its function signatures preprocessed to fit static linkage. Otherwise dynamic linkage is assumed and the mangled names then become _imp__*. The unresolved errors from your screenshot indicate it's attempting a dynamic link rather than the desired static link.

                  项目构建选项->链接器设置->链接库下确保它包含以下内容:curl、rtmp、idn、ssl、ssh2、crypto、z、ws2_32, wldap32, winmm, gdi32.请注意,顺序很重要.由于 gnu 链接器的设计缺陷,需要首先列出最依赖的库,然后是最不依赖的库.msvc link 和 borland 的 ilinker 等其他链接器不会出现此类问题——这些库可以按任何顺序列出.

                  Under Project build options->Linker settings->Link libraries make sure it contains the following: curl, rtmp, idn, ssl, ssh2, crypto, z, ws2_32, wldap32, winmm, gdi32. Note that order is important. Due to a design deficiency of the gnu linker, the most dependant libraries need to be listed first followed by least dependant. Other linkers like msvc link and borland's ilinker do not exhibit such issues -- the libraries can be listed in any order.

                  项目构建选项->链接器设置->其他链接器选项下添加'-static'.这将确保使用idn"的静态版本.如果省略此开关,则您编译的程序可能依赖于libidn-11.dll"来运行,这可能不是您想要的.

                  Under Project build options->Linker settings->Other linker options add in '-static'. This will make sure that the static version of 'idn' is used. If this switch is omitted then your compiled program could depend on 'libidn-11.dll' to run which probably isn't what you want.

                  此时,您应该能够毫无问题地编译和链接 libcurl 程序.有几件事值得一提,

                  At this point, you should be able to compile and link libcurl programs without any issues. A couple things worth mentioning,

                  • 其他链接器选项下,不需要屏幕截图中的其他额外开关.链接库已经列出并涵盖了libcurl.a".

                  • Under Other linker options the other extra switches from your screenshot aren't needed. 'libcurl.a' is already listed and covered by Link libraries.

                  libcrypto.a"似乎涵盖了与libeay32.a"相同的引用,因此只需要其中之一.但是,libeay32.a"尽管尺寸较大,但会导致动态链接.如果您希望您的应用程序完全自包含",请使用libcrypto.a"代替屏幕截图.

                  The 'libcrypto.a' seems to cover the same references as the 'libeay32.a' so only one of them is needed. However, 'libeay32.a' causes dynamic linkage despite its larger size. If you want your application to be 'fully self-contained' use 'libcrypto.a' instead like in the screenshot.

                  如果您希望将来动态链接,只需在链接库下用'curldll'替换列表并删除CURL_STATICLIB定义.不需要额外的库(例如 ssl、idn、rtmp 等),因为 libcurl.dll 已经涵盖了它们.

                  If you wish to link dynamically in the future, just replace the listing with 'curldll' under Link libraries and remove the CURL_STATICLIB define. The extra libraries (eg. ssl, idn, rtmp etc.) aren't needed since libcurl.dll already covers them.

                  通过使用代码块的用户模板,您可以避免新 libcurl 程序的繁琐且容易出错的设置.(例如,文件->新建->项目->用户模板)

                  You can avoid the tedious error prone setup of a new libcurl program by employing codeblocks' user templates. (eg. File->New->Project->User templates)

                  希望这能一劳永逸地解决您在使用 libcurl 时遇到的任何构建问题.

                  Hopefully this resolves any build problems you have with libcurl once and for all.

                  这篇关于将静态 libcurl 添加到 Code::Blocks IDE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  C++ stl unordered_map implementation, reference validity(C++ stl unordered_map 实现,参考有效性)
                  C++: Is it possible to use a reference as the value in a map?(C++:是否可以使用引用作为映射中的值?)
                  Where ampersand quot;amp;quot; can be put when passing argument by reference?(其中符号“amp;通过引用传递参数时可以放置吗?)
                  Why can a non-const reference parameter be bound to a temporary object?(为什么可以将非常量引用参数绑定到临时对象?)
                  What is a dangling reference?(什么是悬空引用?)
                  C++ reference changes when push_back new element to std::vector(当 push_back 新元素到 std::vector 时,C++ 引用发生变化)
                  <i id='6k8un'><tr id='6k8un'><dt id='6k8un'><q id='6k8un'><span id='6k8un'><b id='6k8un'><form id='6k8un'><ins id='6k8un'></ins><ul id='6k8un'></ul><sub id='6k8un'></sub></form><legend id='6k8un'></legend><bdo id='6k8un'><pre id='6k8un'><center id='6k8un'></center></pre></bdo></b><th id='6k8un'></th></span></q></dt></tr></i><div id='6k8un'><tfoot id='6k8un'></tfoot><dl id='6k8un'><fieldset id='6k8un'></fieldset></dl></div>

                    1. <legend id='6k8un'><style id='6k8un'><dir id='6k8un'><q id='6k8un'></q></dir></style></legend>
                    2. <tfoot id='6k8un'></tfoot>

                        <bdo id='6k8un'></bdo><ul id='6k8un'></ul>
                          <tbody id='6k8un'></tbody>

                          <small id='6k8un'></small><noframes id='6k8un'>