113498266Sopenharmony_ci# how to install curl and libcurl 213498266Sopenharmony_ci 313498266Sopenharmony_ci## Installing Binary Packages 413498266Sopenharmony_ci 513498266Sopenharmony_ciLots of people download binary distributions of curl and libcurl. This 613498266Sopenharmony_cidocument does not describe how to install curl or libcurl using such a binary 713498266Sopenharmony_cipackage. This document describes how to compile, build and install curl and 813498266Sopenharmony_cilibcurl from source code. 913498266Sopenharmony_ci 1013498266Sopenharmony_ci## Building using vcpkg 1113498266Sopenharmony_ci 1213498266Sopenharmony_ciYou can download and install curl and libcurl using the [vcpkg](https://github.com/Microsoft/vcpkg/) dependency manager: 1313498266Sopenharmony_ci 1413498266Sopenharmony_ci git clone https://github.com/Microsoft/vcpkg.git 1513498266Sopenharmony_ci cd vcpkg 1613498266Sopenharmony_ci ./bootstrap-vcpkg.sh 1713498266Sopenharmony_ci ./vcpkg integrate install 1813498266Sopenharmony_ci vcpkg install curl[tool] 1913498266Sopenharmony_ci 2013498266Sopenharmony_ciThe curl port in vcpkg is kept up to date by Microsoft team members and 2113498266Sopenharmony_cicommunity contributors. If the version is out of date, please [create an issue 2213498266Sopenharmony_cior pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository. 2313498266Sopenharmony_ci 2413498266Sopenharmony_ci## Building from git 2513498266Sopenharmony_ci 2613498266Sopenharmony_ciIf you get your code off a git repository instead of a release tarball, see 2713498266Sopenharmony_cithe `GIT-INFO` file in the root directory for specific instructions on how to 2813498266Sopenharmony_ciproceed. 2913498266Sopenharmony_ci 3013498266Sopenharmony_ci# Unix 3113498266Sopenharmony_ci 3213498266Sopenharmony_ciA normal Unix installation is made in three or four steps (after you have 3313498266Sopenharmony_ciunpacked the source archive): 3413498266Sopenharmony_ci 3513498266Sopenharmony_ci ./configure --with-openssl [--with-gnutls --with-wolfssl] 3613498266Sopenharmony_ci make 3713498266Sopenharmony_ci make test (optional) 3813498266Sopenharmony_ci make install 3913498266Sopenharmony_ci 4013498266Sopenharmony_ci(Adjust the configure line accordingly to use the TLS library you want.) 4113498266Sopenharmony_ci 4213498266Sopenharmony_ciYou probably need to be root when doing the last command. 4313498266Sopenharmony_ci 4413498266Sopenharmony_ciGet a full listing of all available configure options by invoking it like: 4513498266Sopenharmony_ci 4613498266Sopenharmony_ci ./configure --help 4713498266Sopenharmony_ci 4813498266Sopenharmony_ciIf you want to install curl in a different file hierarchy than `/usr/local`, 4913498266Sopenharmony_cispecify that when running configure: 5013498266Sopenharmony_ci 5113498266Sopenharmony_ci ./configure --prefix=/path/to/curl/tree 5213498266Sopenharmony_ci 5313498266Sopenharmony_ciIf you have write permission in that directory, you can do 'make install' 5413498266Sopenharmony_ciwithout being root. An example of this would be to make a local install in 5513498266Sopenharmony_ciyour own home directory: 5613498266Sopenharmony_ci 5713498266Sopenharmony_ci ./configure --prefix=$HOME 5813498266Sopenharmony_ci make 5913498266Sopenharmony_ci make install 6013498266Sopenharmony_ci 6113498266Sopenharmony_ciThe configure script always tries to find a working SSL library unless 6213498266Sopenharmony_ciexplicitly told not to. If you have OpenSSL installed in the default search 6313498266Sopenharmony_cipath for your compiler/linker, you do not need to do anything special. If you 6413498266Sopenharmony_cihave OpenSSL installed in `/usr/local/ssl`, you can run configure like: 6513498266Sopenharmony_ci 6613498266Sopenharmony_ci ./configure --with-openssl 6713498266Sopenharmony_ci 6813498266Sopenharmony_ciIf you have OpenSSL installed somewhere else (for example, `/opt/OpenSSL`) and 6913498266Sopenharmony_ciyou have pkg-config installed, set the pkg-config path first, like this: 7013498266Sopenharmony_ci 7113498266Sopenharmony_ci env PKG_CONFIG_PATH=/opt/OpenSSL/lib/pkgconfig ./configure --with-openssl 7213498266Sopenharmony_ci 7313498266Sopenharmony_ciWithout pkg-config installed, use this: 7413498266Sopenharmony_ci 7513498266Sopenharmony_ci ./configure --with-openssl=/opt/OpenSSL 7613498266Sopenharmony_ci 7713498266Sopenharmony_ciIf you insist on forcing a build without SSL support, you can run configure 7813498266Sopenharmony_cilike this: 7913498266Sopenharmony_ci 8013498266Sopenharmony_ci ./configure --without-ssl 8113498266Sopenharmony_ci 8213498266Sopenharmony_ciIf you have OpenSSL installed, but with the libraries in one place and the 8313498266Sopenharmony_ciheader files somewhere else, you have to set the `LDFLAGS` and `CPPFLAGS` 8413498266Sopenharmony_cienvironment variables prior to running configure. Something like this should 8513498266Sopenharmony_ciwork: 8613498266Sopenharmony_ci 8713498266Sopenharmony_ci CPPFLAGS="-I/path/to/ssl/include" LDFLAGS="-L/path/to/ssl/lib" ./configure 8813498266Sopenharmony_ci 8913498266Sopenharmony_ciIf you have shared SSL libs installed in a directory where your runtime 9013498266Sopenharmony_cilinker does not find them (which usually causes configure failures), you can 9113498266Sopenharmony_ciprovide this option to gcc to set a hard-coded path to the runtime linker: 9213498266Sopenharmony_ci 9313498266Sopenharmony_ci LDFLAGS=-Wl,-R/usr/local/ssl/lib ./configure --with-openssl 9413498266Sopenharmony_ci 9513498266Sopenharmony_ci## Static builds 9613498266Sopenharmony_ci 9713498266Sopenharmony_ciTo force a static library compile, disable the shared library creation by 9813498266Sopenharmony_cirunning configure like: 9913498266Sopenharmony_ci 10013498266Sopenharmony_ci ./configure --disable-shared 10113498266Sopenharmony_ci 10213498266Sopenharmony_ciThe configure script is primarily done to work with shared/dynamic third party 10313498266Sopenharmony_cidependencies. When linking with shared libraries, the dependency "chain" is 10413498266Sopenharmony_cihandled automatically by the library loader - on all modern systems. 10513498266Sopenharmony_ci 10613498266Sopenharmony_ciIf you instead link with a static library, you need to provide all the 10713498266Sopenharmony_cidependency libraries already at the link command line. 10813498266Sopenharmony_ci 10913498266Sopenharmony_ciFiguring out all the dependency libraries for a given library is hard, as it 11013498266Sopenharmony_cimight involve figuring out the dependencies of the dependencies and they vary 11113498266Sopenharmony_cibetween platforms and change between versions. 11213498266Sopenharmony_ci 11313498266Sopenharmony_ciWhen using static dependencies, the build scripts will mostly assume that you, 11413498266Sopenharmony_cithe user, will provide all the necessary additional dependency libraries as 11513498266Sopenharmony_ciadditional arguments in the build. With configure, by setting `LIBS` or 11613498266Sopenharmony_ci`LDFLAGS` on the command line. 11713498266Sopenharmony_ci 11813498266Sopenharmony_ciBuilding statically is not for the faint of heart. 11913498266Sopenharmony_ci 12013498266Sopenharmony_ci## Debug 12113498266Sopenharmony_ci 12213498266Sopenharmony_ciIf you are a curl developer and use gcc, you might want to enable more debug 12313498266Sopenharmony_cioptions with the `--enable-debug` option. 12413498266Sopenharmony_ci 12513498266Sopenharmony_cicurl can be built to use a whole range of libraries to provide various useful 12613498266Sopenharmony_ciservices, and configure will try to auto-detect a decent default. If you want 12713498266Sopenharmony_cito alter it, you can select how to deal with each individual library. 12813498266Sopenharmony_ci 12913498266Sopenharmony_ci## Select TLS backend 13013498266Sopenharmony_ci 13113498266Sopenharmony_ciThese options are provided to select the TLS backend to use. 13213498266Sopenharmony_ci 13313498266Sopenharmony_ci - AmiSSL: `--with-amissl` 13413498266Sopenharmony_ci - BearSSL: `--with-bearssl` 13513498266Sopenharmony_ci - GnuTLS: `--with-gnutls`. 13613498266Sopenharmony_ci - mbedTLS: `--with-mbedtls` 13713498266Sopenharmony_ci - OpenSSL: `--with-openssl` (also for BoringSSL, AWS-LC, libressl, and quictls) 13813498266Sopenharmony_ci - rustls: `--with-rustls` 13913498266Sopenharmony_ci - Schannel: `--with-schannel` 14013498266Sopenharmony_ci - Secure Transport: `--with-secure-transport` 14113498266Sopenharmony_ci - wolfSSL: `--with-wolfssl` 14213498266Sopenharmony_ci 14313498266Sopenharmony_ciYou can build curl with *multiple* TLS backends at your choice, but some TLS 14413498266Sopenharmony_cibackends cannot be combined: if you build with an OpenSSL fork (or wolfSSL), 14513498266Sopenharmony_ciyou cannot add another OpenSSL fork (or wolfSSL) simply because they have 14613498266Sopenharmony_ciconflicting identical symbol names. 14713498266Sopenharmony_ci 14813498266Sopenharmony_ciWhen you build with multiple TLS backends, you can select the active one at 14913498266Sopenharmony_ciruntime when curl starts up. 15013498266Sopenharmony_ci 15113498266Sopenharmony_ci## configure finding libs in wrong directory 15213498266Sopenharmony_ci 15313498266Sopenharmony_ciWhen the configure script checks for third-party libraries, it adds those 15413498266Sopenharmony_cidirectories to the `LDFLAGS` variable and then tries linking to see if it 15513498266Sopenharmony_ciworks. When successful, the found directory is kept in the `LDFLAGS` variable 15613498266Sopenharmony_ciwhen the script continues to execute and do more tests and possibly check for 15713498266Sopenharmony_cimore libraries. 15813498266Sopenharmony_ci 15913498266Sopenharmony_ciThis can make subsequent checks for libraries wrongly detect another 16013498266Sopenharmony_ciinstallation in a directory that was previously added to `LDFLAGS` by another 16113498266Sopenharmony_cilibrary check. 16213498266Sopenharmony_ci 16313498266Sopenharmony_ci# Windows 16413498266Sopenharmony_ci 16513498266Sopenharmony_ciBuilding for Windows XP is required as a minimum. 16613498266Sopenharmony_ci 16713498266Sopenharmony_ci## Building Windows DLLs and C runtime (CRT) linkage issues 16813498266Sopenharmony_ci 16913498266Sopenharmony_ci As a general rule, building a DLL with static CRT linkage is highly 17013498266Sopenharmony_ci discouraged, and intermixing CRTs in the same app is something to avoid at 17113498266Sopenharmony_ci any cost. 17213498266Sopenharmony_ci 17313498266Sopenharmony_ci Reading and comprehending Microsoft Knowledge Base articles KB94248 and 17413498266Sopenharmony_ci KB140584 is a must for any Windows developer. Especially important is full 17513498266Sopenharmony_ci understanding if you are not going to follow the advice given above. 17613498266Sopenharmony_ci 17713498266Sopenharmony_ci - [How To Use the C Runtime](https://support.microsoft.com/help/94248/how-to-use-the-c-run-time) 17813498266Sopenharmony_ci - [Runtime Library Compiler Options](https://docs.microsoft.com/cpp/build/reference/md-mt-ld-use-run-time-library) 17913498266Sopenharmony_ci - [Potential Errors Passing CRT Objects Across DLL Boundaries](https://docs.microsoft.com/cpp/c-runtime-library/potential-errors-passing-crt-objects-across-dll-boundaries) 18013498266Sopenharmony_ci 18113498266Sopenharmony_ciIf your app is misbehaving in some strange way, or it is suffering from memory 18213498266Sopenharmony_cicorruption, before asking for further help, please try first to rebuild every 18313498266Sopenharmony_cisingle library your app uses as well as your app using the debug 18413498266Sopenharmony_cimulti-threaded dynamic C runtime. 18513498266Sopenharmony_ci 18613498266Sopenharmony_ci If you get linkage errors read section 5.7 of the FAQ document. 18713498266Sopenharmony_ci 18813498266Sopenharmony_ci## Cygwin 18913498266Sopenharmony_ci 19013498266Sopenharmony_ciAlmost identical to the Unix installation. Run the configure script in the 19113498266Sopenharmony_cicurl source tree root with `sh configure`. Make sure you have the `sh` 19213498266Sopenharmony_ciexecutable in `/bin/` or you will see the configure fail toward the end. 19313498266Sopenharmony_ci 19413498266Sopenharmony_ciRun `make` 19513498266Sopenharmony_ci 19613498266Sopenharmony_ci## MS-DOS 19713498266Sopenharmony_ci 19813498266Sopenharmony_ciRequires DJGPP in the search path and pointing to the Watt-32 stack via 19913498266Sopenharmony_ci`WATT_PATH=c:/djgpp/net/watt`. 20013498266Sopenharmony_ci 20113498266Sopenharmony_ciRun `make -f Makefile.dist djgpp` in the root curl dir. 20213498266Sopenharmony_ci 20313498266Sopenharmony_ciFor build configuration options, please see the mingw-w64 section. 20413498266Sopenharmony_ci 20513498266Sopenharmony_ciNotes: 20613498266Sopenharmony_ci 20713498266Sopenharmony_ci - DJGPP 2.04 beta has a `sscanf()` bug so the URL parsing is not done 20813498266Sopenharmony_ci properly. Use DJGPP 2.03 until they fix it. 20913498266Sopenharmony_ci 21013498266Sopenharmony_ci - Compile Watt-32 (and OpenSSL) with the same version of DJGPP. Otherwise 21113498266Sopenharmony_ci things go wrong because things like FS-extensions and `errno` values have 21213498266Sopenharmony_ci been changed between releases. 21313498266Sopenharmony_ci 21413498266Sopenharmony_ci## AmigaOS 21513498266Sopenharmony_ci 21613498266Sopenharmony_ciRun `make -f Makefile.dist amiga` in the root curl dir. 21713498266Sopenharmony_ci 21813498266Sopenharmony_ciFor build configuration options, please see the mingw-w64 section. 21913498266Sopenharmony_ci 22013498266Sopenharmony_ci## Disabling Specific Protocols in Windows builds 22113498266Sopenharmony_ci 22213498266Sopenharmony_ciThe configure utility, unfortunately, is not available for the Windows 22313498266Sopenharmony_cienvironment, therefore, you cannot use the various disable-protocol options of 22413498266Sopenharmony_cithe configure utility on this platform. 22513498266Sopenharmony_ci 22613498266Sopenharmony_ciYou can use specific defines to disable specific protocols and features. See 22713498266Sopenharmony_ci[CURL-DISABLE](CURL-DISABLE.md) for the full list. 22813498266Sopenharmony_ci 22913498266Sopenharmony_ciIf you want to set any of these defines you have the following options: 23013498266Sopenharmony_ci 23113498266Sopenharmony_ci - Modify `lib/config-win32.h` 23213498266Sopenharmony_ci - Modify `lib/curl_setup.h` 23313498266Sopenharmony_ci - Modify `winbuild/Makefile.vc` 23413498266Sopenharmony_ci - Modify the "Preprocessor Definitions" in the libcurl project 23513498266Sopenharmony_ci 23613498266Sopenharmony_ciNote: The pre-processor settings can be found using the Visual Studio IDE 23713498266Sopenharmony_ciunder "Project -> Properties -> Configuration Properties -> C/C++ -> 23813498266Sopenharmony_ciPreprocessor". 23913498266Sopenharmony_ci 24013498266Sopenharmony_ci## Using BSD-style lwIP instead of Winsock TCP/IP stack in Win32 builds 24113498266Sopenharmony_ci 24213498266Sopenharmony_ciIn order to compile libcurl and curl using BSD-style lwIP TCP/IP stack it is 24313498266Sopenharmony_cinecessary to make the definition of the preprocessor symbol `USE_LWIPSOCK` 24413498266Sopenharmony_civisible to libcurl and curl compilation processes. To set this definition you 24513498266Sopenharmony_cihave the following alternatives: 24613498266Sopenharmony_ci 24713498266Sopenharmony_ci - Modify `lib/config-win32.h` and `src/config-win32.h` 24813498266Sopenharmony_ci - Modify `winbuild/Makefile.vc` 24913498266Sopenharmony_ci - Modify the "Preprocessor Definitions" in the libcurl project 25013498266Sopenharmony_ci 25113498266Sopenharmony_ciNote: The pre-processor settings can be found using the Visual Studio IDE 25213498266Sopenharmony_ciunder "Project -> Properties -> Configuration Properties -> C/C++ -> 25313498266Sopenharmony_ciPreprocessor". 25413498266Sopenharmony_ci 25513498266Sopenharmony_ciOnce that libcurl has been built with BSD-style lwIP TCP/IP stack support, in 25613498266Sopenharmony_ciorder to use it with your program it is mandatory that your program includes 25713498266Sopenharmony_cilwIP header file `<lwip/opt.h>` (or another lwIP header that includes this) 25813498266Sopenharmony_cibefore including any libcurl header. Your program does not need the 25913498266Sopenharmony_ci`USE_LWIPSOCK` preprocessor definition which is for libcurl internals only. 26013498266Sopenharmony_ci 26113498266Sopenharmony_ciCompilation has been verified with lwIP 1.4.0. 26213498266Sopenharmony_ci 26313498266Sopenharmony_ciThis BSD-style lwIP TCP/IP stack support must be considered experimental given 26413498266Sopenharmony_cithat it has been verified that lwIP 1.4.0 still needs some polish, and libcurl 26513498266Sopenharmony_cimight yet need some additional adjustment. 26613498266Sopenharmony_ci 26713498266Sopenharmony_ci## Important static libcurl usage note 26813498266Sopenharmony_ci 26913498266Sopenharmony_ciWhen building an application that uses the static libcurl library on Windows, 27013498266Sopenharmony_ciyou must add `-DCURL_STATICLIB` to your `CFLAGS`. Otherwise the linker will 27113498266Sopenharmony_cilook for dynamic import symbols. 27213498266Sopenharmony_ci 27313498266Sopenharmony_ci## Legacy Windows and SSL 27413498266Sopenharmony_ci 27513498266Sopenharmony_ciSchannel (from Windows SSPI), is the native SSL library in Windows. However, 27613498266Sopenharmony_ciSchannel in Windows <= XP is unable to connect to servers that 27713498266Sopenharmony_cino longer support the legacy handshakes and algorithms used by those 27813498266Sopenharmony_civersions. If you will be using curl in one of those earlier versions of 27913498266Sopenharmony_ciWindows you should choose another SSL backend such as OpenSSL. 28013498266Sopenharmony_ci 28113498266Sopenharmony_ci# Apple Platforms (macOS, iOS, tvOS, watchOS, and their simulator counterparts) 28213498266Sopenharmony_ci 28313498266Sopenharmony_ciOn modern Apple operating systems, curl can be built to use Apple's SSL/TLS 28413498266Sopenharmony_ciimplementation, Secure Transport, instead of OpenSSL. To build with Secure 28513498266Sopenharmony_ciTransport for SSL/TLS, use the configure option `--with-secure-transport`. 28613498266Sopenharmony_ci 28713498266Sopenharmony_ciWhen Secure Transport is in use, the curl options `--cacert` and `--capath` 28813498266Sopenharmony_ciand their libcurl equivalents, will be ignored, because Secure Transport uses 28913498266Sopenharmony_cithe certificates stored in the Keychain to evaluate whether or not to trust 29013498266Sopenharmony_cithe server. This, of course, includes the root certificates that ship with the 29113498266Sopenharmony_ciOS. The `--cert` and `--engine` options, and their libcurl equivalents, are 29213498266Sopenharmony_cicurrently unimplemented in curl with Secure Transport. 29313498266Sopenharmony_ci 29413498266Sopenharmony_ciIn general, a curl build for an Apple `ARCH/SDK/DEPLOYMENT_TARGET` combination 29513498266Sopenharmony_cican be taken by providing appropriate values for `ARCH`, `SDK`, `DEPLOYMENT_TARGET` 29613498266Sopenharmony_cibelow and running the commands: 29713498266Sopenharmony_ci 29813498266Sopenharmony_ci```bash 29913498266Sopenharmony_ci# Set these three according to your needs 30013498266Sopenharmony_ciexport ARCH=x86_64 30113498266Sopenharmony_ciexport SDK=macosx 30213498266Sopenharmony_ciexport DEPLOYMENT_TARGET=10.8 30313498266Sopenharmony_ci 30413498266Sopenharmony_ciexport CFLAGS="-arch $ARCH -isysroot $(xcrun -sdk $SDK --show-sdk-path) -m$SDK-version-min=$DEPLOYMENT_TARGET" 30513498266Sopenharmony_ci./configure --host=$ARCH-apple-darwin --prefix $(pwd)/artifacts --with-secure-transport 30613498266Sopenharmony_cimake -j8 30713498266Sopenharmony_cimake install 30813498266Sopenharmony_ci``` 30913498266Sopenharmony_ci 31013498266Sopenharmony_ciAbove will build curl for macOS platform with `x86_64` architecture and `10.8` as deployment target. 31113498266Sopenharmony_ci 31213498266Sopenharmony_ciHere is an example for iOS device: 31313498266Sopenharmony_ci 31413498266Sopenharmony_ci```bash 31513498266Sopenharmony_ciexport ARCH=arm64 31613498266Sopenharmony_ciexport SDK=iphoneos 31713498266Sopenharmony_ciexport DEPLOYMENT_TARGET=11.0 31813498266Sopenharmony_ci 31913498266Sopenharmony_ciexport CFLAGS="-arch $ARCH -isysroot $(xcrun -sdk $SDK --show-sdk-path) -m$SDK-version-min=$DEPLOYMENT_TARGET" 32013498266Sopenharmony_ci./configure --host=$ARCH-apple-darwin --prefix $(pwd)/artifacts --with-secure-transport 32113498266Sopenharmony_cimake -j8 32213498266Sopenharmony_cimake install 32313498266Sopenharmony_ci``` 32413498266Sopenharmony_ci 32513498266Sopenharmony_ciAnother example for watchOS simulator for macs with Apple Silicon: 32613498266Sopenharmony_ci 32713498266Sopenharmony_ci```bash 32813498266Sopenharmony_ciexport ARCH=arm64 32913498266Sopenharmony_ciexport SDK=watchsimulator 33013498266Sopenharmony_ciexport DEPLOYMENT_TARGET=5.0 33113498266Sopenharmony_ci 33213498266Sopenharmony_ciexport CFLAGS="-arch $ARCH -isysroot $(xcrun -sdk $SDK --show-sdk-path) -m$SDK-version-min=$DEPLOYMENT_TARGET" 33313498266Sopenharmony_ci./configure --host=$ARCH-apple-darwin --prefix $(pwd)/artifacts --with-secure-transport 33413498266Sopenharmony_cimake -j8 33513498266Sopenharmony_cimake install 33613498266Sopenharmony_ci``` 33713498266Sopenharmony_ci 33813498266Sopenharmony_ciIn all above, the built libraries and executables can be found in the 33913498266Sopenharmony_ci`artifacts` folder. 34013498266Sopenharmony_ci 34113498266Sopenharmony_ci# Android 34213498266Sopenharmony_ci 34313498266Sopenharmony_ciWhen building curl for Android it is recommended to use a Linux/macOS 34413498266Sopenharmony_cienvironment since using curl's `configure` script is the easiest way to build 34513498266Sopenharmony_cicurl for Android. Before you can build curl for Android, you need to install 34613498266Sopenharmony_cithe Android NDK first. This can be done using the SDK Manager that is part of 34713498266Sopenharmony_ciAndroid Studio. Once you have installed the Android NDK, you need to figure 34813498266Sopenharmony_ciout where it has been installed and then set up some environment variables 34913498266Sopenharmony_cibefore launching `configure`. On macOS, those variables could look like this 35013498266Sopenharmony_cito compile for `aarch64` and API level 29: 35113498266Sopenharmony_ci 35213498266Sopenharmony_ci```bash 35313498266Sopenharmony_ciexport ANDROID_NDK_HOME=~/Library/Android/sdk/ndk/25.1.8937393 # Point into your NDK. 35413498266Sopenharmony_ciexport HOST_TAG=darwin-x86_64 # Same tag for Apple Silicon. Other OS values here: https://developer.android.com/ndk/guides/other_build_systems#overview 35513498266Sopenharmony_ciexport TOOLCHAIN=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/$HOST_TAG 35613498266Sopenharmony_ciexport AR=$TOOLCHAIN/bin/llvm-ar 35713498266Sopenharmony_ciexport AS=$TOOLCHAIN/bin/llvm-as 35813498266Sopenharmony_ciexport CC=$TOOLCHAIN/bin/aarch64-linux-android21-clang 35913498266Sopenharmony_ciexport CXX=$TOOLCHAIN/bin/aarch64-linux-android21-clang++ 36013498266Sopenharmony_ciexport LD=$TOOLCHAIN/bin/ld 36113498266Sopenharmony_ciexport RANLIB=$TOOLCHAIN/bin/llvm-ranlib 36213498266Sopenharmony_ciexport STRIP=$TOOLCHAIN/bin/llvm-strip 36313498266Sopenharmony_ci``` 36413498266Sopenharmony_ci 36513498266Sopenharmony_ciWhen building on Linux or targeting other API levels or architectures, you need 36613498266Sopenharmony_cito adjust those variables accordingly. After that you can build curl like this: 36713498266Sopenharmony_ci 36813498266Sopenharmony_ci ./configure --host aarch64-linux-android --with-pic --disable-shared 36913498266Sopenharmony_ci 37013498266Sopenharmony_ciNote that this will not give you SSL/TLS support. If you need SSL/TLS, you 37113498266Sopenharmony_cihave to build curl against a SSL/TLS layer, e.g. OpenSSL, because it is 37213498266Sopenharmony_ciimpossible for curl to access Android's native SSL/TLS layer. To build curl 37313498266Sopenharmony_cifor Android using OpenSSL, follow the OpenSSL build instructions and then 37413498266Sopenharmony_ciinstall `libssl.a` and `libcrypto.a` to `$TOOLCHAIN/sysroot/usr/lib` and copy 37513498266Sopenharmony_ci`include/openssl` to `$TOOLCHAIN/sysroot/usr/include`. Now you can build curl 37613498266Sopenharmony_cifor Android using OpenSSL like this: 37713498266Sopenharmony_ci 37813498266Sopenharmony_ci```bash 37913498266Sopenharmony_ciLIBS="-lssl -lcrypto -lc++" # For OpenSSL/BoringSSL. In general, you will need to the SSL/TLS layer's transitive dependencies if you are linking statically. 38013498266Sopenharmony_ci./configure --host aarch64-linux-android --with-pic --disable-shared --with-openssl="$TOOLCHAIN/sysroot/usr" 38113498266Sopenharmony_ci``` 38213498266Sopenharmony_ci 38313498266Sopenharmony_ci# IBM i 38413498266Sopenharmony_ci 38513498266Sopenharmony_ciFor IBM i (formerly OS/400), you can use curl in two different ways: 38613498266Sopenharmony_ci 38713498266Sopenharmony_ci- Natively, running in the **ILE**. The obvious use is being able to call curl 38813498266Sopenharmony_ci from ILE C or RPG applications. 38913498266Sopenharmony_ci - You will need to build this from source. See `packages/OS400/README` for 39013498266Sopenharmony_ci the ILE specific build instructions. 39113498266Sopenharmony_ci- In the **PASE** environment, which runs AIX programs. curl will be built as 39213498266Sopenharmony_ci it would be on AIX. 39313498266Sopenharmony_ci - IBM provides builds of curl in their Yum repository for PASE software. 39413498266Sopenharmony_ci - To build from source, follow the Unix instructions. 39513498266Sopenharmony_ci 39613498266Sopenharmony_ciThere are some additional limitations and quirks with curl on this platform; 39713498266Sopenharmony_cithey affect both environments. 39813498266Sopenharmony_ci 39913498266Sopenharmony_ci## Multi-threading notes 40013498266Sopenharmony_ci 40113498266Sopenharmony_ciBy default, jobs in IBM i will not start with threading enabled. (Exceptions 40213498266Sopenharmony_ciinclude interactive PASE sessions started by `QP2TERM` or SSH.) If you use 40313498266Sopenharmony_cicurl in an environment without threading when options like asynchronous DNS 40413498266Sopenharmony_ciwere enabled, you will get messages like: 40513498266Sopenharmony_ci 40613498266Sopenharmony_ci``` 40713498266Sopenharmony_cigetaddrinfo() thread failed to start 40813498266Sopenharmony_ci``` 40913498266Sopenharmony_ci 41013498266Sopenharmony_ciDo not panic. curl and your program are not broken. You can fix this by: 41113498266Sopenharmony_ci 41213498266Sopenharmony_ci- Set the environment variable `QIBM_MULTI_THREADED` to `Y` before starting 41313498266Sopenharmony_ci your program. This can be done at whatever scope you feel is appropriate. 41413498266Sopenharmony_ci- Alternatively, start the job with the `ALWMLTTHD` parameter set to `*YES`. 41513498266Sopenharmony_ci 41613498266Sopenharmony_ci# Cross compile 41713498266Sopenharmony_ci 41813498266Sopenharmony_ciDownload and unpack the curl package. 41913498266Sopenharmony_ci 42013498266Sopenharmony_ci`cd` to the new directory. (e.g. `cd curl-7.12.3`) 42113498266Sopenharmony_ci 42213498266Sopenharmony_ciSet environment variables to point to the cross-compile toolchain and call 42313498266Sopenharmony_ciconfigure with any options you need. Be sure and specify the `--host` and 42413498266Sopenharmony_ci`--build` parameters at configuration time. The following script is an example 42513498266Sopenharmony_ciof cross-compiling for the IBM 405GP PowerPC processor using the toolchain on 42613498266Sopenharmony_ciLinux. 42713498266Sopenharmony_ci 42813498266Sopenharmony_ci```bash 42913498266Sopenharmony_ci#! /bin/sh 43013498266Sopenharmony_ci 43113498266Sopenharmony_ciexport PATH=$PATH:/opt/hardhat/devkit/ppc/405/bin 43213498266Sopenharmony_ciexport CPPFLAGS="-I/opt/hardhat/devkit/ppc/405/target/usr/include" 43313498266Sopenharmony_ciexport AR=ppc_405-ar 43413498266Sopenharmony_ciexport AS=ppc_405-as 43513498266Sopenharmony_ciexport LD=ppc_405-ld 43613498266Sopenharmony_ciexport RANLIB=ppc_405-ranlib 43713498266Sopenharmony_ciexport CC=ppc_405-gcc 43813498266Sopenharmony_ciexport NM=ppc_405-nm 43913498266Sopenharmony_ci 44013498266Sopenharmony_ci./configure --target=powerpc-hardhat-linux 44113498266Sopenharmony_ci --host=powerpc-hardhat-linux 44213498266Sopenharmony_ci --build=i586-pc-linux-gnu 44313498266Sopenharmony_ci --prefix=/opt/hardhat/devkit/ppc/405/target/usr/local 44413498266Sopenharmony_ci --exec-prefix=/usr/local 44513498266Sopenharmony_ci``` 44613498266Sopenharmony_ci 44713498266Sopenharmony_ciYou may also need to provide a parameter like `--with-random=/dev/urandom` to 44813498266Sopenharmony_ciconfigure as it cannot detect the presence of a random number generating 44913498266Sopenharmony_cidevice for a target system. The `--prefix` parameter specifies where curl 45013498266Sopenharmony_ciwill be installed. If `configure` completes successfully, do `make` and `make 45113498266Sopenharmony_ciinstall` as usual. 45213498266Sopenharmony_ci 45313498266Sopenharmony_ciIn some cases, you may be able to simplify the above commands to as little as: 45413498266Sopenharmony_ci 45513498266Sopenharmony_ci ./configure --host=ARCH-OS 45613498266Sopenharmony_ci 45713498266Sopenharmony_ci# REDUCING SIZE 45813498266Sopenharmony_ci 45913498266Sopenharmony_ciThere are a number of configure options that can be used to reduce the size of 46013498266Sopenharmony_cilibcurl for embedded applications where binary size is an important factor. 46113498266Sopenharmony_ciFirst, be sure to set the `CFLAGS` variable when configuring with any relevant 46213498266Sopenharmony_cicompiler optimization flags to reduce the size of the binary. For gcc, this 46313498266Sopenharmony_ciwould mean at minimum the -Os option, and potentially the `-march=X`, 46413498266Sopenharmony_ci`-mdynamic-no-pic` and `-flto` options as well, e.g. 46513498266Sopenharmony_ci 46613498266Sopenharmony_ci ./configure CFLAGS='-Os' LDFLAGS='-Wl,-Bsymbolic'... 46713498266Sopenharmony_ci 46813498266Sopenharmony_ciNote that newer compilers often produce smaller code than older versions 46913498266Sopenharmony_cidue to improved optimization. 47013498266Sopenharmony_ci 47113498266Sopenharmony_ciBe sure to specify as many `--disable-` and `--without-` flags on the 47213498266Sopenharmony_ciconfigure command-line as you can to disable all the libcurl features that you 47313498266Sopenharmony_ciknow your application is not going to need. Besides specifying the 47413498266Sopenharmony_ci`--disable-PROTOCOL` flags for all the types of URLs your application will not 47513498266Sopenharmony_ciuse, here are some other flags that can reduce the size of the library by 47613498266Sopenharmony_cidisabling support for some feature: 47713498266Sopenharmony_ci 47813498266Sopenharmony_ci - `--disable-alt-svc` (HTTP Alt-Svc) 47913498266Sopenharmony_ci - `--disable-ares` (the C-ARES DNS library) 48013498266Sopenharmony_ci - `--disable-cookies` (HTTP cookies) 48113498266Sopenharmony_ci - `--disable-basic-auth` (cryptographic authentication) 48213498266Sopenharmony_ci - `--disable-bearer-auth` (cryptographic authentication) 48313498266Sopenharmony_ci - `--disable-digest-auth` (cryptographic authentication) 48413498266Sopenharmony_ci - `--disable-kerberos-auth` (cryptographic authentication) 48513498266Sopenharmony_ci - `--disable-negotiate-auth` (cryptographic authentication) 48613498266Sopenharmony_ci - `--disable-aws` (cryptographic authentication) 48713498266Sopenharmony_ci - `--disable-dateparse` (date parsing for time conditionals) 48813498266Sopenharmony_ci - `--disable-dnsshuffle` (internal server load spreading) 48913498266Sopenharmony_ci - `--disable-doh` (DNS-over-HTTP) 49013498266Sopenharmony_ci - `--disable-get-easy-options` (lookup easy options at runtime) 49113498266Sopenharmony_ci - `--disable-hsts` (HTTP Strict Transport Security) 49213498266Sopenharmony_ci - `--disable-http-auth` (all HTTP authentication) 49313498266Sopenharmony_ci - `--disable-ipv6` (IPv6) 49413498266Sopenharmony_ci - `--disable-libcurl-option` (--libcurl C code generation support) 49513498266Sopenharmony_ci - `--disable-manual` (built-in documentation) 49613498266Sopenharmony_ci - `--disable-netrc` (.netrc file) 49713498266Sopenharmony_ci - `--disable-ntlm-wb` (NTLM WinBind) 49813498266Sopenharmony_ci - `--disable-progress-meter` (graphical progress meter in library) 49913498266Sopenharmony_ci - `--disable-proxy` (HTTP and SOCKS proxies) 50013498266Sopenharmony_ci - `--disable-pthreads` (multi-threading) 50113498266Sopenharmony_ci - `--disable-socketpair` (socketpair for asynchronous name resolving) 50213498266Sopenharmony_ci - `--disable-threaded-resolver` (threaded name resolver) 50313498266Sopenharmony_ci - `--disable-tls-srp` (Secure Remote Password authentication for TLS) 50413498266Sopenharmony_ci - `--disable-unix-sockets` (UNIX sockets) 50513498266Sopenharmony_ci - `--disable-verbose` (eliminates debugging strings and error code strings) 50613498266Sopenharmony_ci - `--disable-versioned-symbols` (versioned symbols) 50713498266Sopenharmony_ci - `--enable-symbol-hiding` (eliminates unneeded symbols in the shared library) 50813498266Sopenharmony_ci - `--without-brotli` (Brotli on-the-fly decompression) 50913498266Sopenharmony_ci - `--without-libpsl` (Public Suffix List in cookies) 51013498266Sopenharmony_ci - `--without-nghttp2` (HTTP/2 using nghttp2) 51113498266Sopenharmony_ci - `--without-ngtcp2` (HTTP/2 using ngtcp2) 51213498266Sopenharmony_ci - `--without-zstd` (Zstd on-the-fly decompression) 51313498266Sopenharmony_ci - `--without-libidn2` (internationalized domain names) 51413498266Sopenharmony_ci - `--without-librtmp` (RTMP) 51513498266Sopenharmony_ci - `--without-ssl` (SSL/TLS) 51613498266Sopenharmony_ci - `--without-zlib` (on-the-fly decompression) 51713498266Sopenharmony_ci 51813498266Sopenharmony_ciThe GNU compiler and linker have a number of options that can reduce the 51913498266Sopenharmony_cisize of the libcurl dynamic libraries on some platforms even further. 52013498266Sopenharmony_ciSpecify them by providing appropriate `CFLAGS` and `LDFLAGS` variables on 52113498266Sopenharmony_cithe configure command-line, e.g. 52213498266Sopenharmony_ci 52313498266Sopenharmony_ci CFLAGS="-Os -ffunction-sections -fdata-sections 52413498266Sopenharmony_ci -fno-unwind-tables -fno-asynchronous-unwind-tables -flto" 52513498266Sopenharmony_ci LDFLAGS="-Wl,-s -Wl,-Bsymbolic -Wl,--gc-sections" 52613498266Sopenharmony_ci 52713498266Sopenharmony_ciBe sure also to strip debugging symbols from your binaries after compiling 52813498266Sopenharmony_ciusing 'strip' (or the appropriate variant if cross-compiling). If space is 52913498266Sopenharmony_cireally tight, you may be able to remove some unneeded sections of the shared 53013498266Sopenharmony_cilibrary using the -R option to objcopy (e.g. the .comment section). 53113498266Sopenharmony_ci 53213498266Sopenharmony_ciUsing these techniques it is possible to create a basic HTTP-only libcurl 53313498266Sopenharmony_cishared library for i386 Linux platforms that is only 133 KiB in size 53413498266Sopenharmony_ci(as of libcurl version 7.80.0, using gcc 11.2.0). 53513498266Sopenharmony_ci 53613498266Sopenharmony_ciYou may find that statically linking libcurl to your application will result 53713498266Sopenharmony_ciin a lower total size than dynamically linking. 53813498266Sopenharmony_ci 53913498266Sopenharmony_ciNote that the curl test harness can detect the use of some, but not all, of 54013498266Sopenharmony_cithe `--disable` statements suggested above. Use will cause tests relying on 54113498266Sopenharmony_cithose features to fail. The test harness can be manually forced to skip the 54213498266Sopenharmony_cirelevant tests by specifying certain key words on the `runtests.pl` command 54313498266Sopenharmony_ciline. Following is a list of appropriate key words for those configure options 54413498266Sopenharmony_cithat are not automatically detected: 54513498266Sopenharmony_ci 54613498266Sopenharmony_ci - `--disable-cookies` !cookies 54713498266Sopenharmony_ci - `--disable-dateparse` !RETRY-AFTER !`CURLOPT_TIMECONDITION` !`CURLINFO_FILETIME` !`If-Modified-Since` !`curl_getdate` !`-z` 54813498266Sopenharmony_ci - `--disable-libcurl-option` !`--libcurl` 54913498266Sopenharmony_ci - `--disable-verbose` !verbose\ logs 55013498266Sopenharmony_ci 55113498266Sopenharmony_ci# Ports 55213498266Sopenharmony_ci 55313498266Sopenharmony_ciThis is a probably incomplete list of known CPU architectures and operating 55413498266Sopenharmony_cisystems that curl has been compiled for. If you know a system curl compiles 55513498266Sopenharmony_ciand runs on, that is not listed, please let us know! 55613498266Sopenharmony_ci 55713498266Sopenharmony_ci## 101 Operating Systems 55813498266Sopenharmony_ci 55913498266Sopenharmony_ci AIX, AmigaOS, Android, ArcoOS, Aros, Atari FreeMiNT, BeOS, Blackberry 10, 56013498266Sopenharmony_ci Blackberry Tablet OS, Cell OS, CheriBSD, Chrome OS, Cisco IOS, DG/UX, 56113498266Sopenharmony_ci Dragonfly BSD, DR DOS, eCOS, FreeBSD, FreeDOS, FreeRTOS, Fuchsia, Garmin OS, 56213498266Sopenharmony_ci Genode, Haiku, HardenedBSD, HP-UX, Hurd, Illumos, Integrity, iOS, ipadOS, IRIX, 56313498266Sopenharmony_ci Linux, Lua RTOS, Mac OS 9, macOS, Mbed, Meego, Micrium, MINIX, Moblin, MorphOS, 56413498266Sopenharmony_ci MPE/iX, MS-DOS, NCR MP-RAS, NetBSD, Netware, NextStep, Nintendo Switch, 56513498266Sopenharmony_ci NonStop OS, NuttX, OpenBSD, OpenStep, Orbis OS, OS/2, OS/400, OS21, Plan 9, 56613498266Sopenharmony_ci PlayStation Portable, QNX, Qubes OS, ReactOS, Redox, RICS OS, ROS, RTEMS, 56713498266Sopenharmony_ci Sailfish OS, SCO Unix, Serenity, SINIX-Z, SkyOS, Solaris, Sortix, SunOS, 56813498266Sopenharmony_ci Syllable OS, Symbian, Tizen, TPF, Tru64, tvOS, ucLinux, Ultrix, UNICOS, 56913498266Sopenharmony_ci UnixWare, VMS, vxWorks, watchOS, Wear OS, WebOS, Wii system software, Wii U, 57013498266Sopenharmony_ci Windows, Windows CE, Xbox System, Xenix, Zephyr, z/OS, z/TPF, z/VM, z/VSE 57113498266Sopenharmony_ci 57213498266Sopenharmony_ci## 28 CPU Architectures 57313498266Sopenharmony_ci 57413498266Sopenharmony_ci Alpha, ARC, ARM, AVR32, C-SKY, CompactRISC, Elbrus, ETRAX, HP-PA, Itanium, 57513498266Sopenharmony_ci LoongArch, m68k, m88k, MicroBlaze, MIPS, Nios, OpenRISC, POWER, PowerPC, 57613498266Sopenharmony_ci RISC-V, s390, SH4, SPARC, Tilera, VAX, x86, Xtensa, z/arch 577