关于libcurl在各种平台上面的编译

本文档详细介绍了如何在Android、iOS和Windows平台上编译libcurl库,重点在于配置参数的设置。提供了下载源码的链接,并分别给出Android、iOS和Windows上的编译步骤,包括配置脚本内容、Make命令以及针对不同平台的配置参数调整。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

How to compile libcurl

This document describes how to compile libcurl for Android, iOS and windows. The difficulty to compile libcurl is the parameters for configuration.

You can download the source code from:
http://curl.haxx.se/download.html

The document bases on version 7.21.4.

1. Android

1.1 Configure

Place the curl source into external/curl/ in the Android source tree. Create a shell script configure.sh, and put it into external/curl/. The script content is:

#!/bin/sh
SDK_ROOT=/home/nudtzxm/android_sdk
export PATH="$SDK_ROOT/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin:$PATH"
./configure --host=arm-linux CC=arm-eabi-gcc \
CPPFLAGS="-I $SDK_ROOT/system/core/include 
         -I $SDK_ROOT/hardware/libhardware/include 
         -I $SDK_ROOT/hardware/libhardware_legacy/include   
         -I $SDK_ROOT/hardware/ril/include   
         -I $SDK_ROOT/dalvik/libnativehelper/include  
         -I $SDK_ROOT/frameworks/base/include   
         -I $SDK_ROOT/frameworks/base/opengl/include   
         -I $SDK_ROOT/external/skia/include   
         -I $SDK_ROOT/out/target/product/generic/obj/include 
         -I $SDK_ROOT/bionic/libc/arch-arm/include   
         -I $SDK_ROOT/bionic/libc/include   
         -I $SDK_ROOT/bionic/libstdc++/include   
         -I $SDK_ROOT/bionic/libc/kernel/common  
         -I $SDK_ROOT/bionic/libc/kernel/arch-arm   
         -I $SDK_ROOT/bionic/libm/include   
         -I $SDK_ROOT/bionic/libm/include/arch/arm   
         -I $SDK_ROOT/bionic/libthread_db/include   
         -I $SDK_ROOT/bionic/libc/kernel/common   
         -I $SDK_ROOT/bionic/libc/kernel/arch-arm  
         -I $SDK_ROOT/system/core/libcutils   
         -I $SDK_ROOT/out/target/product/generic/obj/STATIC_LIBRARIES/libcutils_intermediates  
         -I $SDK_ROOT/out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates 
         -I $SDK_ROOT/system/core/include/arch/linux-arm/ 
         -include $SDK_ROOT/system/core/include/arch/linux-arm/AndroidConfig.h" \
CFLAGS="-nostdlib -fno-exceptions -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-short-enums 
       -Wno-multichar -msoft-float -march=armv5te -mtune=xscale -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ 
       -mthumb-interwork -DANDROID -fmessage-length=0 
       -W -Wall -Wno-unused -Winit-self -Wpointer-arith -Werror=return-type -Werror=non-virtual-dtor -Werror=address 
       -Werror=sequence-point -DSK_RELEASE -DNDEBUG -g -Wstrict-aliasing=2 -finline-functions 
       -fno-inline-functions-called-once -fgcse-after-reload -frerun-cse-after-loop 
       -frename-registers -DNDEBUG -UDEBUG -mthumb -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64" \
LIBS="-L$SDK_ROOT/out/target/product/generic/obj/lib 
     -L$SDK_ROOT/out/target/product/generic/obj/STATIC_LIBRARIES/libcutils_intermediates/libcutils.a -lc -lm -ldl
     $SDK_ROOT/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/../lib/gcc/arm-eabi/4.4.0/interwork/libgcc.a"

Goto the root of curl, and run the script:

1.2 Make

Goto the root of curl and make curl:

1.3 The parameters of configure

You may see the parameters of configuration are complex. How to set it? You should read the comments of curl/Android.mk.

2. iOS

I compile it as the article says:
http://www.creativealgorithms.com/blog/content/building-libcurl-ios-42
or
http://blog.sina.com.cn/s/blog\_673975590100qjuh.html (chinese)

I change the parameters of configure, so the configure command is:

./configure --disable-shared  --host=arm-apple-darwin10

3. Windows

Open the vc6curl.dsw and select “DLL Release” to build. You may find libcurl.dll and libcurl_imp.lib in the CURL_ROOT\lib\DLL-Release.

4. Mac Osx

    对于最近在mac下面编译curl源码,并在xcode中进行使用的过程,具体纪录在编译方法

   不过全部都是E文,可以锻炼我们的E文水平 呵呵


5. About the header files

The header files of curl/include can be only used after succesful configuration. And the header files are different on different platforms.

出自于  libcurl编译方法

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值