How to compile curl static library under windows visual studio

It is never a easy problem to compile curl library under windows, especially a static library.

So first of all we need to have a curl original project:

It's not pretty hard that we can see there's a CMakeLists.txt file inside the project, Without hesitating, we must use cmake to transform this project. 

That's what we got. All we need to do is open up CURL.sln. After opening, in order to compile a static lib we need to jump to the project setting and modified something.

Jump into the (C/C++->code generation) we need to turn running lib to MT

And now we can start the compilation.

 捕获

As we can see, the result is pretty desirable.

However, we have to deal with the using problem.

Although you already have a pretty decent code, sometimes you still can not link the curl library right to it.You may always encounter the linking problem like this:

 捕获

All you need to do is jump into your project's settings -> C/C++ -> CommandLine and add this line into the blank on the downside of your configuration window

/D CURL_STATICLIB

The result is very satisfactory.

捕获

Audio clip: Adobe Flash Player (version 9 or above) is required to play this audio clip. Download the latest version here. You also need to have JavaScript enabled in your browser.

Leave a Comment

Your email address will not be published. Required fields are marked *