Windows and Xcode under compile debug Libcurl source code

Source: Internet
Author: User
Tags windows visual

Curl is a familiar tool for everyone. A few days ago, to track the implementation details of curl, we had to try to build a Curl debugging project. We set up debugging under Xcode on Windows Visual Studio and Mac, respectively. Here are some details to share.

Curl can be compiled and run on dozens of platforms.
This is the official website address: http://curl.haxx.se

Please download the source code here: http://curl.haxx.se/download.html

Download unzip.

One. Windows Debugging:
Debugging on Windows is relatively straightforward. Bring your own project files.
Directly with the VS2012 open the \projects\windows\vc11 inside of the project files can be.
Be sure to open with vs2012.

Direct F10 can be step to main function.

Two. Mac Xcode debugging.
We mainly talk about Xcode debugging.
Probably because the compilation on the *nix is more convenient, so it is compiled with makefile. So there is no self-brought project file.

Fortunately, the open source project CMake can generate engineering files in reverse from makefile and configuration files. And the better news is that curl was early in support of cmake. So we need to modify the Curl configuration file and combine CMake to reverse generate its engineering files on Xcode.

Start.

1) need to install CMake first

Download CMake source code, http://www.cmake.org/files/v3.1/cmake-3.1.0-rc1.tar.gz
Then unzip, go in:./configure && make && make install
If everything goes well, it should be able to succeed.

2) Generate makefile

In the second step, we need to generate curl makefile. Enter the source directory for Curl:

./configure  --without-libssh2  --with-darwinsslmake

To illustrate, we specify two parameters here, we do not need curl support SSH, so the "–without-libssh2" excluded. and "–with-darwinssl" specifies that you use the SSL implementation on your Mac without the need for OpenSSL.

This can reduce the likelihood of errors, and we need to DARWINSSL.

3) Create Xcode project.

The first few steps are nothing special, this step is the key, using Cnamke reverse Generation project.

In the source root directory of curl, there is a file "CMakeLists.txt" which is the necessary configuration file for reverse generation. This is the official curl, but it is very old, in disrepair, unable to work.

We can try it first:

mkdir -p build/xcodecd build/xcodecmake ../../$CURL -G Xcode

As a description, create a subdirectory to save the project. Then use the command:

cmake ../../$CURL -G Xcode

To generate the project.

This step will report a large number of errors in "CMakeLists.txt".

Please use this version of the attachment that I modified in place of the source version, and then repeat the above command generation.
CMakeLists.txt

The project file has been generated.

But when the project is open, it compiles. You need to make some changes to the project files first:
See the following command for details.

sed -i "" "s/OTHER_LDFLAGS = \"/OTHER_LDFLAGS = \"-framework Cocoa -framework CoreFoundation -framework CoreServices -framework Security -fobjc-link-runtime -framework LDAP/"  CURL.xcodeproj/project.pbxproj

Some link target has been added to the project. relatively simple. Not much to say.

Now set up a debugging project, you can debug.

Then check curl this target:

Then find the main function. Can be debugged in one step:

Welcome to my personal Independent blog: http://byNeil.com

Windows and Xcode under compile debug Libcurl source code

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.