Static library of libcurl on windows [duplicate]

喜夏-厌秋 提交于 2019-12-25 02:33:09

问题


How to link this library libcurl statically to the exe? i have tried

--disable-share --enable-static that does not help.

I am using MingW32

Is there an easy way to statically link this library so i can have no more .dlls with my app?


回答1:


If using codeblocks, right click your project and press properties then on the defines tab, add:

CURL_STATICLIB

if using command line then:

-static -static-libgcc -static-libstdc++ -DCURL_STATICLIB -lcurl -lws2_32 -lwinmm




回答2:


You need to use -static in linker options




回答3:


Here is the steps how to do that. but you may get some additional errors. those are need to figure out by yourself. This is Just a guidance.

  1. You should have two project in Visual Studio Solution

    • libcurl project (source code downloaded from curl web. this may help you for this)
    • your project
  2. Build libcurl as a static lib.(right click libcurl project in solution explorer -> properties -> configuration properties -> General-> change configuration Type to Static Library (.lib))

  3. Then right click your project go to propertied ->configuration properties ->Linker -> general

  4. In "additional Library directories" add the path to above curl.lib.

  5. then go to propertied ->configuration properties ->Linker -> input
  6. add libcurl.lib name to additional dependencies.
  7. then go to properties -> configuration properties -> General
  8. If your project uses MFC or ATL change use of MFC and use of ATL to use MFC in static library and use ATL in static library accordingly.
  9. then build the solution.
  10. Enjoy libcurl :)


来源:https://stackoverflow.com/questions/20985631/static-library-of-libcurl-on-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!