简体   繁体   English

在Visual Studio 2013中将libcurl库静态链接到我的项目(一个dll)

[英]Statically link the libcurl library to my project (a dll) in Visual Studio 2013

So I've been trying to statically link the libcurl library to my project for the past DAY and I'm literally pulling my hair out. 因此,在过去的一天中,我一直在尝试将libcurl库静态链接到我的项目,而我实际上是在拔头发。 Everywhere on the internet different instructions are given and none seem to work. 互联网上的每个地方都给出了不同的说明,但似乎没有一个起作用。 I've never statically liked a library before but now I have to (for the sake of keeping things organized). 以前我从没有一开始就喜欢图书馆,但现在我不得不(为了使事情井井有条)。

So my project is a .dll file, which requires the libcurl library to function. 因此,我的项目是一个.dll文件,该文件需要libcurl库才能运行。 I've managed to build a libcurl.lib file from the libcurl source, but I have no idea what I need to do with the properties of my dll project. 我已经设法从libcurl源构建了一个libcurl.lib文件,但是我不知道该如何处理dll项目的属性。 I've tried adding it to "Additional library directories", "Additional include directories", "Additional dependencies" all without success. 我尝试将其添加到“其他库目录”,“其他包含目录”,“其他依赖项”都没有成功。 Some configurations seem to work, but in the end it still doesn't link statically, only dynamically. 某些配置似乎可以工作,但最终它仍然不能静态链接,而只能动态链接。 Oh, and I'm using Visual Studio 2013. 哦,我在用Visual Studio 2013。

Does anyone have any experience statically linking libcurl? 有没有人有静态链接libcurl的经验? Any help would be much appreciated. 任何帮助将非常感激。 Thanks! 谢谢!

After a lot of experimenting I finally figured it out: I had to do exactly this (for anyone else experiencing these issues): 经过大量的试验,我终于弄清楚了:我必须完全做到这一点(对于遇到这些问题的其他人):

  1. Open properties 开放属性
  2. Go to Configuration Properties -> VC++ Directories 转到配置属性-> VC ++目录
    1. Add the location of your curldownload/lib folder to "Library Directories" 将您的curldownload / lib文件夹的位置添加到“库目录”
  3. Go to Configuration Properties -> C/C++ -> General 转到配置属性-> C / C ++->常规
    1. Add the location of your curldownload/include folder to "Additional Include Directories" 将您的curldownload / include文件夹的位置添加到“其他包含目录”
  4. Go to Configuration Properties -> Linker -> Input 转到配置属性->链接器->输入
    1. Add this to "Additional Dependencies": libcurl.lib;ws2_32.lib;wldap32.lib;advapi32.lib;kernel32.lib;comdlg32.lib 将此添加到“其他依赖项”:libcurl.lib; ws2_32.lib; wldap32.lib; advapi32.lib; kernel32.lib; comdlg32.lib
    2. Add "libcmt.lib" to "Ignore Specific Default Libraries" 将“ libcmt.lib”添加到“忽略特定的默认库”

And then it compiled. 然后编译。 Hope that helped! 希望能有所帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM