问题
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.
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
Build libcurl as a static lib.(right click
libcurl project
in solution explorer -> properties -> configuration properties -> General-> changeconfiguration Type
toStatic Library (.lib)
)Then right click your project go to propertied ->configuration properties ->Linker -> general
In "additional Library directories" add the path to above curl.lib.
- then go to propertied ->configuration properties ->Linker -> input
- add libcurl.lib name to
additional dependencies
. - then go to properties -> configuration properties -> General
- If your project uses MFC or ATL change
use of MFC
anduse of ATL
touse MFC in static library
anduse ATL in static library
accordingly. - then build the solution.
- Enjoy libcurl :)
来源:https://stackoverflow.com/questions/20985631/static-library-of-libcurl-on-windows