How to compile curl static library under windows visual studio

By October 25, 2015February 18th, 2021Programming

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:

Here’s what we got

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. 

捕获

After transforming

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: Feel This Moment.mp3|initialvolume=80|loop=yes|titles=Feel this moment|artists=邓智彰]

Leave a Reply