CINXE.COM
build and install curl from source
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>build and install curl from source</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta content="text/html; charset=UTF-8" http-equiv="Content-Type"> <link rel="stylesheet" type="text/css" href="/curl.css"> <link rel="shortcut icon" href="/favicon.ico"> <link rel="icon" href="/logo/curl-symbol.svg" type="image/svg+xml"> <link rel="alternate" type="application/rss+xml" title="cURL Releases" href="https://github.com/curl/curl/releases.atom"> </head> <body> <div class="main"> <div class="menu"> <a href="/docs/" class="menuitem" title="Documentation Overview">Docs Overview</a> <div class="dropdown"> <a class="dropbtn" href="/docs/projdocs.html">Project</a> <div class="dropdown-content"> <a href="/docs/bugbounty.html">Bug Bounty</a> <a href="/docs/bugs.html">Bug Report</a> <a href="/docs/code-of-conduct.html">Code of conduct</a> <a href="/docs/libs.html">Dependencies</a> <a href="/donation.html">Donate</a> <a href="/docs/faq.html">FAQ</a> <a href="/docs/features.html">Features</a> <a href="/docs/governance.html">Governance</a> <a href="/docs/history.html">History</a> <a href="/docs/install.html">Install</a> <a href="/docs/knownbugs.html">Known Bugs</a> <a href="/logo/">Logo</a> <a href="/docs/todo.html">TODO</a> <a href="/about.html">website Info</a> </div> </div> <div class="dropdown"> <a class="dropbtn" href="/docs/protdocs.html">Protocols</a> <div class="dropdown-content"> <a href="/docs/caextract.html">CA Extract</a> <a href="/docs/http-cookies.html">HTTP cookies</a> <a href="/docs/http3.html">HTTP/3</a> <a href="/docs/mqtt.html">MQTT</a> <a href="/docs/sslcerts.html">SSL certs</a> <a href="/docs/ssl-compared.html">SSL libs compared</a> <a href="/docs/url-syntax.html">URL syntax</a> <a href="/docs/websocket.html">WebSocket</a> </div> </div> <div class="dropdown"> <a class="dropbtn" href="/docs/reldocs.html">Releases</a> <div class="dropdown-content"> <a href="/ch/">Changelog</a> <a href="/docs/security.html">curl CVEs</a> <a href="/docs/releases.html">Release Table</a> <a href="/docs/versions.html">Version Numbering</a> <a href="/docs/vulnerabilities.html">Vulnerabilities</a> </div> </div> <div class="dropdown"> <a class="dropbtn" href="/docs/tooldocs.html">Tool</a> <div class="dropdown-content"> <a href="/docs/comparison-table.html">Comparison Table</a> <a href="/docs/manpage.html">curl man page</a> <a href="/docs/httpscripting.html">HTTP Scripting</a> <a href="/docs/mk-ca-bundle.html">mk-ca-bundle</a> <a href="/docs/tutorial.html">Tutorial</a> <a href="optionswhen.html">When options were added</a> </div> </div> <div class="dropdown"> <a class="dropbtn" href="/docs/whodocs.html">Who and Why</a> <div class="dropdown-content"> <a href="/docs/companies.html">Companies</a> <a href="/docs/copyright.html">Copyright</a> <a href="/sponsors.html">Sponsors</a> <a href="/docs/thanks.html">Thanks</a> <a href="/docs/thename.html">The name</a> </div> </div> </div> <div class="contents"> <div class="where"><a href="/">curl</a> / <a href="/docs/">Docs</a> / <a href="/docs/projdocs.html">Project</a> / <b>Install from source</b></div> <div class="relatedbox"> <b>Related:</b> <br><a href="/ch/">Changelog</a> <br><a href="/dev/">Developing curl</a> <br><a href="/mail/">Get help</a> </div> <!-- Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. SPDX-License-Identifier: curl --> <h1 id="how-to-install-curl-and-libcurl">How to install curl and libcurl</h1> <h2 id="installing-binary-packages">Installing Binary Packages</h2> <p>Lots of people download binary distributions of curl and libcurl. This document does not describe how to install curl or libcurl using such a binary package. This document describes how to compile, build and install curl and libcurl from source code.</p> <h2 id="building-using-vcpkg">Building using vcpkg</h2> <p>You can download and install curl and libcurl using the <a href="https://github.com/Microsoft/vcpkg/">vcpkg</a> dependency manager:</p> <pre><code>git clone https://github.com/Microsoft/vcpkg.git cd vcpkg ./bootstrap-vcpkg.sh ./vcpkg integrate install vcpkg install curl[tool]</code></pre> <p>The curl port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please <a href="https://github.com/Microsoft/vcpkg">create an issue or pull request</a> on the vcpkg repository.</p> <h2 id="building-from-git">Building from git</h2> <p>If you get your code off a git repository instead of a release tarball, see the <code>GIT-INFO.md</code> file in the root directory for specific instructions on how to proceed.</p> <h1 id="unix">Unix</h1> <p>A normal Unix installation is made in three or four steps (after you have unpacked the source archive):</p> <pre><code>./configure --with-openssl [--with-gnutls --with-wolfssl] make make test (optional) make install</code></pre> <p>(Adjust the configure line accordingly to use the TLS library you want.)</p> <p>You probably need to be root when doing the last command.</p> <p>Get a full listing of all available configure options by invoking it like:</p> <pre><code>./configure --help</code></pre> <p>If you want to install curl in a different file hierarchy than <code>/usr/local</code>, specify that when running configure:</p> <pre><code>./configure --prefix=/path/to/curl/tree</code></pre> <p>If you have write permission in that directory, you can do 'make install' without being root. An example of this would be to make a local install in your own home directory:</p> <pre><code>./configure --prefix=$HOME make make install</code></pre> <p>The configure script always tries to find a working SSL library unless explicitly told not to. If you have OpenSSL installed in the default search path for your compiler/linker, you do not need to do anything special. If you have OpenSSL installed in <code>/usr/local/ssl</code>, you can run configure like:</p> <pre><code>./configure --with-openssl</code></pre> <p>If you have OpenSSL installed somewhere else (for example, <code>/opt/OpenSSL</code>) and you have pkg-config installed, set the pkg-config path first, like this:</p> <pre><code>env PKG_CONFIG_PATH=/opt/OpenSSL/lib/pkgconfig ./configure --with-openssl</code></pre> <p>Without pkg-config installed, use this:</p> <pre><code>./configure --with-openssl=/opt/OpenSSL</code></pre> <p>If you insist on forcing a build without SSL support, you can run configure like this:</p> <pre><code>./configure --without-ssl</code></pre> <p>If you have OpenSSL installed, but with the libraries in one place and the header files somewhere else, you have to set the <code>LDFLAGS</code> and <code>CPPFLAGS</code> environment variables prior to running configure. Something like this should work:</p> <pre><code>CPPFLAGS="-I/path/to/ssl/include" LDFLAGS="-L/path/to/ssl/lib" ./configure</code></pre> <p>If you have shared SSL libs installed in a directory where your runtime linker does not find them (which usually causes configure failures), you can provide this option to gcc to set a hard-coded path to the runtime linker:</p> <pre><code>LDFLAGS=-Wl,-R/usr/local/ssl/lib ./configure --with-openssl</code></pre> <h2 id="static-builds">Static builds</h2> <p>To force a static library compile, disable the shared library creation by running configure like:</p> <pre><code>./configure --disable-shared</code></pre> <p>The configure script is primarily done to work with shared/dynamic third party dependencies. When linking with shared libraries, the dependency "chain" is handled automatically by the library loader - on all modern systems.</p> <p>If you instead link with a static library, you need to provide all the dependency libraries already at the link command line.</p> <p>Figuring out all the dependency libraries for a given library is hard, as it might involve figuring out the dependencies of the dependencies and they vary between platforms and change between versions.</p> <p>When using static dependencies, the build scripts mostly assume that you, the user, provide all the necessary additional dependency libraries as additional arguments in the build. With configure, by setting <code>LIBS</code> or <code>LDFLAGS</code> on the command line.</p> <p>Building statically is not for the faint of heart.</p> <h2 id="debug">Debug</h2> <p>If you are a curl developer and use gcc, you might want to enable more debug options with the <code>--enable-debug</code> option.</p> <p>curl can be built to use a whole range of libraries to provide various useful services, and configure tries to auto-detect a decent default. If you want to alter it, you can select how to deal with each individual library.</p> <h2 id="select-tls-backend">Select TLS backend</h2> <p>These options are provided to select the TLS backend to use.</p> <ul> <li>AmiSSL: <code>--with-amissl</code></li> <li>BearSSL: <code>--with-bearssl</code></li> <li>GnuTLS: <code>--with-gnutls</code>.</li> <li>mbedTLS: <code>--with-mbedtls</code></li> <li>OpenSSL: <code>--with-openssl</code> (also for BoringSSL, AWS-LC, LibreSSL, and quictls)</li> <li>rustls: <code>--with-rustls</code></li> <li>Schannel: <code>--with-schannel</code></li> <li>Secure Transport: <code>--with-secure-transport</code></li> <li>wolfSSL: <code>--with-wolfssl</code></li> </ul> <p>You can build curl with <em>multiple</em> TLS backends at your choice, but some TLS backends cannot be combined: if you build with an OpenSSL fork (or wolfSSL), you cannot add another OpenSSL fork (or wolfSSL) simply because they have conflicting identical symbol names.</p> <p>When you build with multiple TLS backends, you can select the active one at runtime when curl starts up.</p> <h2 id="multissl-and-http3">MultiSSL and HTTP/3</h2> <p>HTTP/3 needs QUIC and QUIC needs TLS. Building libcurl with HTTP/3 and QUIC support is not compatible with the MultiSSL feature: they are mutually exclusive. If you need MultiSSL in your build, you cannot have HTTP/3 support and vice versa.</p> <p>libcurl can only use a single TLS library with QUIC and that <em>same</em> TLS library needs to be used for the other TLS using protocols.</p> <h2 id="configure-finding-libs-in-wrong-directory">Configure finding libs in wrong directory</h2> <p>When the configure script checks for third-party libraries, it adds those directories to the <code>LDFLAGS</code> variable and then tries linking to see if it works. When successful, the found directory is kept in the <code>LDFLAGS</code> variable when the script continues to execute and do more tests and possibly check for more libraries.</p> <p>This can make subsequent checks for libraries wrongly detect another installation in a directory that was previously added to <code>LDFLAGS</code> by another library check.</p> <h1 id="windows">Windows</h1> <p>Building for Windows XP is required as a minimum.</p> <h2 id="building-windows-dlls-and-c-runtime-crt-linkage-issues">Building Windows DLLs and C runtime (CRT) linkage issues</h2> <p>As a general rule, building a DLL with static CRT linkage is highly discouraged, and intermixing CRTs in the same app is something to avoid at any cost.</p> <p>Reading and comprehending Microsoft Knowledge Base articles KB94248 and KB140584 is a must for any Windows developer. Especially important is full understanding if you are not going to follow the advice given above.</p> <ul> <li><a href="https://support.microsoft.com/help/94248/how-to-use-the-c-run-time">How To Use the C Runtime</a></li> <li><a href="https://docs.microsoft.com/cpp/build/reference/md-mt-ld-use-run-time-library">Runtime Library Compiler Options</a></li> <li><a href="https://docs.microsoft.com/cpp/c-runtime-library/potential-errors-passing-crt-objects-across-dll-boundaries">Potential Errors Passing CRT Objects Across DLL Boundaries</a></li> </ul> <p>If your app is misbehaving in some strange way, or it is suffering from memory corruption, before asking for further help, please try first to rebuild every single library your app uses as well as your app using the debug multi-threaded dynamic C runtime.</p> <p>If you get linkage errors read section 5.7 of the FAQ document.</p> <h2 id="cygwin">Cygwin</h2> <p>Almost identical to the Unix installation. Run the configure script in the curl source tree root with <code>sh configure</code>. Make sure you have the <code>sh</code> executable in <code>/bin/</code> or you see the configure fail toward the end.</p> <p>Run <code>make</code></p> <h2 id="ms-dos">MS-DOS</h2> <p>Requires DJGPP in the search path and pointing to the Watt-32 stack via <code>WATT_PATH=c:/djgpp/net/watt</code>.</p> <p>Run <code>make -f Makefile.dist djgpp</code> in the root curl dir.</p> <p>For build configuration options, please see the mingw-w64 section.</p> <p>Notes:</p> <ul> <li><p>DJGPP 2.04 beta has a <code>sscanf()</code> bug so the URL parsing is not done properly. Use DJGPP 2.03 until they fix it.</p></li> <li><p>Compile Watt-32 (and OpenSSL) with the same version of DJGPP. Otherwise things go wrong because things like FS-extensions and <code>errno</code> values have been changed between releases.</p></li> </ul> <h2 id="amigaos">AmigaOS</h2> <p>Run <code>make -f Makefile.dist amiga</code> in the root curl dir.</p> <p>For build configuration options, please see the mingw-w64 section.</p> <h2 id="disabling-specific-protocols-in-windows-builds">Disabling Specific Protocols in Windows builds</h2> <p>The configure utility, unfortunately, is not available for the Windows environment, therefore, you cannot use the various disable-protocol options of the configure utility on this platform.</p> <p>You can use specific defines to disable specific protocols and features. See <a href="CURL-DISABLE.md">CURL-DISABLE</a> for the full list.</p> <p>If you want to set any of these defines you have the following options:</p> <ul> <li>Modify <code>lib/config-win32.h</code></li> <li>Modify <code>lib/curl_setup.h</code></li> <li>Modify <code>winbuild/Makefile.vc</code></li> <li>Modify the "Preprocessor Definitions" in the libcurl project</li> </ul> <p>Note: The pre-processor settings can be found using the Visual Studio IDE under "Project -> Properties -> Configuration Properties -> C/C++ -> Preprocessor".</p> <h2 id="using-bsd-style-lwip-instead-of-winsock-tcpip-stack-in-windows-builds">Using BSD-style lwIP instead of Winsock TCP/IP stack in Windows builds</h2> <p>In order to compile libcurl and curl using BSD-style lwIP TCP/IP stack it is necessary to make the definition of the preprocessor symbol <code>USE_LWIPSOCK</code> visible to libcurl and curl compilation processes. To set this definition you have the following alternatives:</p> <ul> <li>Modify <code>lib/config-win32.h</code> and <code>src/config-win32.h</code></li> <li>Modify <code>winbuild/Makefile.vc</code></li> <li>Modify the "Preprocessor Definitions" in the libcurl project</li> </ul> <p>Note: The pre-processor settings can be found using the Visual Studio IDE under "Project -> Properties -> Configuration Properties -> C/C++ -> Preprocessor".</p> <p>Once that libcurl has been built with BSD-style lwIP TCP/IP stack support, in order to use it with your program it is mandatory that your program includes lwIP header file <code><lwip/opt.h></code> (or another lwIP header that includes this) before including any libcurl header. Your program does not need the <code>USE_LWIPSOCK</code> preprocessor definition which is for libcurl internals only.</p> <p>Compilation has been verified with lwIP 1.4.0.</p> <p>This BSD-style lwIP TCP/IP stack support must be considered experimental given that it has been verified that lwIP 1.4.0 still needs some polish, and libcurl might yet need some additional adjustment.</p> <h2 id="important-static-libcurl-usage-note">Important static libcurl usage note</h2> <p>When building an application that uses the static libcurl library on Windows, you must add <code>-DCURL_STATICLIB</code> to your <code>CFLAGS</code>. Otherwise the linker looks for dynamic import symbols.</p> <h2 id="legacy-windows-and-ssl">Legacy Windows and SSL</h2> <p>Schannel (from Windows SSPI), is the native SSL library in Windows. However, Schannel in Windows <= XP is unable to connect to servers that no longer support the legacy handshakes and algorithms used by those versions. If you are using curl in one of those earlier versions of Windows you should choose another SSL backend such as OpenSSL.</p> <h1 id="apple-platforms-macos-ios-tvos-watchos-and-their-simulator-counterparts">Apple Platforms (macOS, iOS, tvOS, watchOS, and their simulator counterparts)</h1> <p>On modern Apple operating systems, curl can be built to use Apple's SSL/TLS implementation, Secure Transport, instead of OpenSSL. To build with Secure Transport for SSL/TLS, use the configure option <code>--with-secure-transport</code>.</p> <p>When Secure Transport is in use, the curl options <code>--cacert</code> and <code>--capath</code> and their libcurl equivalents, are ignored, because Secure Transport uses the certificates stored in the Keychain to evaluate whether or not to trust the server. This, of course, includes the root certificates that ship with the OS. The <code>--cert</code> and <code>--engine</code> options, and their libcurl equivalents, are currently unimplemented in curl with Secure Transport.</p> <p>In general, a curl build for an Apple <code>ARCH/SDK/DEPLOYMENT_TARGET</code> combination can be taken by providing appropriate values for <code>ARCH</code>, <code>SDK</code>, <code>DEPLOYMENT_TARGET</code> below and running the commands:</p> <div class="sourceCode" id="cb13"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Set these three according to your needs</span></span> <span id="cb13-2"><a href="#cb13-2" aria-hidden="true" tabindex="-1"></a><span class="bu">export</span> <span class="va">ARCH</span><span class="op">=</span>x86_64</span> <span id="cb13-3"><a href="#cb13-3" aria-hidden="true" tabindex="-1"></a><span class="bu">export</span> <span class="va">SDK</span><span class="op">=</span>macosx</span> <span id="cb13-4"><a href="#cb13-4" aria-hidden="true" tabindex="-1"></a><span class="bu">export</span> <span class="va">DEPLOYMENT_TARGET</span><span class="op">=</span>10.8</span> <span id="cb13-5"><a href="#cb13-5" aria-hidden="true" tabindex="-1"></a></span> <span id="cb13-6"><a href="#cb13-6" aria-hidden="true" tabindex="-1"></a><span class="bu">export</span> <span class="va">CFLAGS</span><span class="op">=</span><span class="st">"-arch </span><span class="va">$ARCH</span><span class="st"> -isysroot </span><span class="va">$(</span><span class="ex">xcrun</span> <span class="at">-sdk</span> <span class="va">$SDK</span> <span class="at">--show-sdk-path</span><span class="va">)</span><span class="st"> -m</span><span class="va">$SDK</span><span class="st">-version-min=</span><span class="va">$DEPLOYMENT_TARGET</span><span class="st">"</span></span> <span id="cb13-7"><a href="#cb13-7" aria-hidden="true" tabindex="-1"></a><span class="ex">./configure</span> <span class="at">--host</span><span class="op">=</span><span class="va">$ARCH</span>-apple-darwin <span class="at">--prefix</span> <span class="va">$(</span><span class="bu">pwd</span><span class="va">)</span>/artifacts <span class="at">--with-secure-transport</span></span> <span id="cb13-8"><a href="#cb13-8" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> <span class="at">-j8</span></span> <span id="cb13-9"><a href="#cb13-9" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> install</span></code></pre></div> <p>The above command lines build curl for macOS platform with <code>x86_64</code> architecture and <code>10.8</code> as deployment target.</p> <p>Here is an example for iOS device:</p> <div class="sourceCode" id="cb14"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb14-1"><a href="#cb14-1" aria-hidden="true" tabindex="-1"></a><span class="bu">export</span> <span class="va">ARCH</span><span class="op">=</span>arm64</span> <span id="cb14-2"><a href="#cb14-2" aria-hidden="true" tabindex="-1"></a><span class="bu">export</span> <span class="va">SDK</span><span class="op">=</span>iphoneos</span> <span id="cb14-3"><a href="#cb14-3" aria-hidden="true" tabindex="-1"></a><span class="bu">export</span> <span class="va">DEPLOYMENT_TARGET</span><span class="op">=</span>11.0</span> <span id="cb14-4"><a href="#cb14-4" aria-hidden="true" tabindex="-1"></a></span> <span id="cb14-5"><a href="#cb14-5" aria-hidden="true" tabindex="-1"></a><span class="bu">export</span> <span class="va">CFLAGS</span><span class="op">=</span><span class="st">"-arch </span><span class="va">$ARCH</span><span class="st"> -isysroot </span><span class="va">$(</span><span class="ex">xcrun</span> <span class="at">-sdk</span> <span class="va">$SDK</span> <span class="at">--show-sdk-path</span><span class="va">)</span><span class="st"> -m</span><span class="va">$SDK</span><span class="st">-version-min=</span><span class="va">$DEPLOYMENT_TARGET</span><span class="st">"</span></span> <span id="cb14-6"><a href="#cb14-6" aria-hidden="true" tabindex="-1"></a><span class="ex">./configure</span> <span class="at">--host</span><span class="op">=</span><span class="va">$ARCH</span>-apple-darwin <span class="at">--prefix</span> <span class="va">$(</span><span class="bu">pwd</span><span class="va">)</span>/artifacts <span class="at">--with-secure-transport</span></span> <span id="cb14-7"><a href="#cb14-7" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> <span class="at">-j8</span></span> <span id="cb14-8"><a href="#cb14-8" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> install</span></code></pre></div> <p>Another example for watchOS simulator for macs with Apple Silicon:</p> <div class="sourceCode" id="cb15"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a><span class="bu">export</span> <span class="va">ARCH</span><span class="op">=</span>arm64</span> <span id="cb15-2"><a href="#cb15-2" aria-hidden="true" tabindex="-1"></a><span class="bu">export</span> <span class="va">SDK</span><span class="op">=</span>watchsimulator</span> <span id="cb15-3"><a href="#cb15-3" aria-hidden="true" tabindex="-1"></a><span class="bu">export</span> <span class="va">DEPLOYMENT_TARGET</span><span class="op">=</span>5.0</span> <span id="cb15-4"><a href="#cb15-4" aria-hidden="true" tabindex="-1"></a></span> <span id="cb15-5"><a href="#cb15-5" aria-hidden="true" tabindex="-1"></a><span class="bu">export</span> <span class="va">CFLAGS</span><span class="op">=</span><span class="st">"-arch </span><span class="va">$ARCH</span><span class="st"> -isysroot </span><span class="va">$(</span><span class="ex">xcrun</span> <span class="at">-sdk</span> <span class="va">$SDK</span> <span class="at">--show-sdk-path</span><span class="va">)</span><span class="st"> -m</span><span class="va">$SDK</span><span class="st">-version-min=</span><span class="va">$DEPLOYMENT_TARGET</span><span class="st">"</span></span> <span id="cb15-6"><a href="#cb15-6" aria-hidden="true" tabindex="-1"></a><span class="ex">./configure</span> <span class="at">--host</span><span class="op">=</span><span class="va">$ARCH</span>-apple-darwin <span class="at">--prefix</span> <span class="va">$(</span><span class="bu">pwd</span><span class="va">)</span>/artifacts <span class="at">--with-secure-transport</span></span> <span id="cb15-7"><a href="#cb15-7" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> <span class="at">-j8</span></span> <span id="cb15-8"><a href="#cb15-8" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> install</span></code></pre></div> <p>In all above, the built libraries and executables can be found in the <code>artifacts</code> folder.</p> <h1 id="android">Android</h1> <p>When building curl for Android it is recommended to use a Linux/macOS environment since using curl's <code>configure</code> script is the easiest way to build curl for Android. Before you can build curl for Android, you need to install the Android NDK first. This can be done using the SDK Manager that is part of Android Studio. Once you have installed the Android NDK, you need to figure out where it has been installed and then set up some environment variables before launching <code>configure</code>. On macOS, those variables could look like this to compile for <code>aarch64</code> and API level 29:</p> <div class="sourceCode" id="cb16"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb16-1"><a href="#cb16-1" aria-hidden="true" tabindex="-1"></a><span class="bu">export</span> <span class="va">ANDROID_NDK_HOME</span><span class="op">=</span>~/Library/Android/sdk/ndk/25.1.8937393 <span class="co"># Point into your NDK.</span></span> <span id="cb16-2"><a href="#cb16-2" aria-hidden="true" tabindex="-1"></a><span class="bu">export</span> <span class="va">HOST_TAG</span><span class="op">=</span>darwin-x86_64 <span class="co"># Same tag for Apple Silicon. Other OS values here: https://developer.android.com/ndk/guides/other_build_systems#overview</span></span> <span id="cb16-3"><a href="#cb16-3" aria-hidden="true" tabindex="-1"></a><span class="bu">export</span> <span class="va">TOOLCHAIN</span><span class="op">=</span><span class="va">$ANDROID_NDK_HOME</span>/toolchains/llvm/prebuilt/<span class="va">$HOST_TAG</span></span> <span id="cb16-4"><a href="#cb16-4" aria-hidden="true" tabindex="-1"></a><span class="bu">export</span> <span class="va">AR</span><span class="op">=</span><span class="va">$TOOLCHAIN</span>/bin/llvm-ar</span> <span id="cb16-5"><a href="#cb16-5" aria-hidden="true" tabindex="-1"></a><span class="bu">export</span> <span class="va">AS</span><span class="op">=</span><span class="va">$TOOLCHAIN</span>/bin/llvm-as</span> <span id="cb16-6"><a href="#cb16-6" aria-hidden="true" tabindex="-1"></a><span class="bu">export</span> <span class="va">CC</span><span class="op">=</span><span class="va">$TOOLCHAIN</span>/bin/aarch64-linux-android21-clang</span> <span id="cb16-7"><a href="#cb16-7" aria-hidden="true" tabindex="-1"></a><span class="bu">export</span> <span class="va">CXX</span><span class="op">=</span><span class="va">$TOOLCHAIN</span>/bin/aarch64-linux-android21-clang++</span> <span id="cb16-8"><a href="#cb16-8" aria-hidden="true" tabindex="-1"></a><span class="bu">export</span> <span class="va">LD</span><span class="op">=</span><span class="va">$TOOLCHAIN</span>/bin/ld</span> <span id="cb16-9"><a href="#cb16-9" aria-hidden="true" tabindex="-1"></a><span class="bu">export</span> <span class="va">RANLIB</span><span class="op">=</span><span class="va">$TOOLCHAIN</span>/bin/llvm-ranlib</span> <span id="cb16-10"><a href="#cb16-10" aria-hidden="true" tabindex="-1"></a><span class="bu">export</span> <span class="va">STRIP</span><span class="op">=</span><span class="va">$TOOLCHAIN</span>/bin/llvm-strip</span></code></pre></div> <p>When building on Linux or targeting other API levels or architectures, you need to adjust those variables accordingly. After that you can build curl like this:</p> <pre><code>./configure --host aarch64-linux-android --with-pic --disable-shared</code></pre> <p>Note that this does not give you SSL/TLS support. If you need SSL/TLS, you have to build curl with a SSL/TLS library, e.g. OpenSSL, because it is impossible for curl to access Android's native SSL/TLS layer. To build curl for Android using OpenSSL, follow the OpenSSL build instructions and then install <code>libssl.a</code> and <code>libcrypto.a</code> to <code>$TOOLCHAIN/sysroot/usr/lib</code> and copy <code>include/openssl</code> to <code>$TOOLCHAIN/sysroot/usr/include</code>. Now you can build curl for Android using OpenSSL like this:</p> <div class="sourceCode" id="cb18"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb18-1"><a href="#cb18-1" aria-hidden="true" tabindex="-1"></a><span class="va">LIBS</span><span class="op">=</span><span class="st">"-lssl -lcrypto -lc++"</span> <span class="co"># For OpenSSL/BoringSSL. In general, you need to the SSL/TLS layer's transitive dependencies if you are linking statically.</span></span> <span id="cb18-2"><a href="#cb18-2" aria-hidden="true" tabindex="-1"></a><span class="ex">./configure</span> <span class="at">--host</span> aarch64-linux-android <span class="at">--with-pic</span> <span class="at">--disable-shared</span> <span class="at">--with-openssl</span><span class="op">=</span><span class="st">"</span><span class="va">$TOOLCHAIN</span><span class="st">/sysroot/usr"</span></span></code></pre></div> <h1 id="ibm-i">IBM i</h1> <p>For IBM i (formerly OS/400), you can use curl in two different ways:</p> <ul> <li>Natively, running in the <strong>ILE</strong>. The obvious use is being able to call curl from ILE C or RPG applications.</li> <li>You need to build this from source. See <code>packages/OS400/README</code> for the ILE specific build instructions.</li> <li>In the <strong>PASE</strong> environment, which runs AIX programs. curl is built as it would be on AIX.</li> <li>IBM provides builds of curl in their Yum repository for PASE software.</li> <li>To build from source, follow the Unix instructions.</li> </ul> <p>There are some additional limitations and quirks with curl on this platform; they affect both environments.</p> <h2 id="multi-threading-notes">Multi-threading notes</h2> <p>By default, jobs in IBM i does not start with threading enabled. (Exceptions include interactive PASE sessions started by <code>QP2TERM</code> or SSH.) If you use curl in an environment without threading when options like asynchronous DNS were enabled, you get messages like:</p> <pre><code>getaddrinfo() thread failed to start</code></pre> <p>Do not panic. curl and your program are not broken. You can fix this by:</p> <ul> <li>Set the environment variable <code>QIBM_MULTI_THREADED</code> to <code>Y</code> before starting your program. This can be done at whatever scope you feel is appropriate.</li> <li>Alternatively, start the job with the <code>ALWMLTTHD</code> parameter set to <code>*YES</code>.</li> </ul> <h1 id="cross-compile">Cross compile</h1> <p>Download and unpack the curl package.</p> <p><code>cd</code> to the new directory. (e.g. <code>cd curl-7.12.3</code>)</p> <p>Set environment variables to point to the cross-compile toolchain and call configure with any options you need. Be sure and specify the <code>--host</code> and <code>--build</code> parameters at configuration time. The following script is an example of cross-compiling for the IBM 405GP PowerPC processor using the toolchain on Linux.</p> <div class="sourceCode" id="cb20"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb20-1"><a href="#cb20-1" aria-hidden="true" tabindex="-1"></a><span class="co">#! /bin/sh</span></span> <span id="cb20-2"><a href="#cb20-2" aria-hidden="true" tabindex="-1"></a></span> <span id="cb20-3"><a href="#cb20-3" aria-hidden="true" tabindex="-1"></a><span class="bu">export</span> <span class="va">PATH</span><span class="op">=</span><span class="va">$PATH</span>:/opt/hardhat/devkit/ppc/405/bin</span> <span id="cb20-4"><a href="#cb20-4" aria-hidden="true" tabindex="-1"></a><span class="bu">export</span> <span class="va">CPPFLAGS</span><span class="op">=</span><span class="st">"-I/opt/hardhat/devkit/ppc/405/target/usr/include"</span></span> <span id="cb20-5"><a href="#cb20-5" aria-hidden="true" tabindex="-1"></a><span class="bu">export</span> <span class="va">AR</span><span class="op">=</span>ppc_405-ar</span> <span id="cb20-6"><a href="#cb20-6" aria-hidden="true" tabindex="-1"></a><span class="bu">export</span> <span class="va">AS</span><span class="op">=</span>ppc_405-as</span> <span id="cb20-7"><a href="#cb20-7" aria-hidden="true" tabindex="-1"></a><span class="bu">export</span> <span class="va">LD</span><span class="op">=</span>ppc_405-ld</span> <span id="cb20-8"><a href="#cb20-8" aria-hidden="true" tabindex="-1"></a><span class="bu">export</span> <span class="va">RANLIB</span><span class="op">=</span>ppc_405-ranlib</span> <span id="cb20-9"><a href="#cb20-9" aria-hidden="true" tabindex="-1"></a><span class="bu">export</span> <span class="va">CC</span><span class="op">=</span>ppc_405-gcc</span> <span id="cb20-10"><a href="#cb20-10" aria-hidden="true" tabindex="-1"></a><span class="bu">export</span> <span class="va">NM</span><span class="op">=</span>ppc_405-nm</span> <span id="cb20-11"><a href="#cb20-11" aria-hidden="true" tabindex="-1"></a></span> <span id="cb20-12"><a href="#cb20-12" aria-hidden="true" tabindex="-1"></a><span class="ex">./configure</span> <span class="at">--target</span><span class="op">=</span>powerpc-hardhat-linux</span> <span id="cb20-13"><a href="#cb20-13" aria-hidden="true" tabindex="-1"></a> <span class="ex">--host=powerpc-hardhat-linux</span></span> <span id="cb20-14"><a href="#cb20-14" aria-hidden="true" tabindex="-1"></a> <span class="ex">--build=i586-pc-linux-gnu</span></span> <span id="cb20-15"><a href="#cb20-15" aria-hidden="true" tabindex="-1"></a> <span class="ex">--prefix=/opt/hardhat/devkit/ppc/405/target/usr/local</span></span> <span id="cb20-16"><a href="#cb20-16" aria-hidden="true" tabindex="-1"></a> <span class="ex">--exec-prefix=/usr/local</span></span></code></pre></div> <p>You may also need to provide a parameter like <code>--with-random=/dev/urandom</code> to configure as it cannot detect the presence of a random number generating device for a target system. The <code>--prefix</code> parameter specifies where curl gets installed. If <code>configure</code> completes successfully, do <code>make</code> and <code>make install</code> as usual.</p> <p>In some cases, you may be able to simplify the above commands to as little as:</p> <pre><code>./configure --host=ARCH-OS</code></pre> <h1 id="reducing-size">REDUCING SIZE</h1> <p>There are a number of configure options that can be used to reduce the size of libcurl for embedded applications where binary size is an important factor. First, be sure to set the <code>CFLAGS</code> variable when configuring with any relevant compiler optimization flags to reduce the size of the binary. For gcc, this would mean at minimum the <code>-Os</code> option, and others like the following that may be relevant in some environments: <code>-march=X</code>, <code>-mthumb</code>, <code>-m32</code>, <code>-mdynamic-no-pic</code>, <code>-flto</code>, <code>-fdata-sections</code>, <code>-ffunction-sections</code>, <code>-fno-unwind-tables</code>, <code>-fno-asynchronous-unwind-tables</code>, <code>-fno-record-gcc-switches</code>, <code>-fsection-anchors</code>, <code>-fno-plt</code>, <code>-Wl,--gc-sections</code>, <code>-Wl,-Bsymbolic</code>, <code>-Wl,-s</code>,</p> <p>For example, this is how to combine a few of these options:</p> <pre><code>./configure CC=gcc CFLAGS='-Os -ffunction-sections' LDFLAGS='-Wl,--gc-sections'...</code></pre> <p>Note that newer compilers often produce smaller code than older versions due to improved optimization.</p> <p>Be sure to specify as many <code>--disable-</code> and <code>--without-</code> flags on the configure command-line as you can to disable all the libcurl features that you know your application is not going to need. Besides specifying the <code>--disable-PROTOCOL</code> flags for all the types of URLs your application do not use, here are some other flags that can reduce the size of the library by disabling support for some feature (run <code>./configure --help</code> to see them all):</p> <ul> <li><code>--disable-alt-svc</code> (HTTP Alt-Svc)</li> <li><code>--disable-ares</code> (the C-ARES DNS library)</li> <li><code>--disable-cookies</code> (HTTP cookies)</li> <li><code>--disable-basic-auth</code> (cryptographic authentication)</li> <li><code>--disable-bearer-auth</code> (cryptographic authentication)</li> <li><code>--disable-digest-auth</code> (cryptographic authentication)</li> <li><code>--disable-kerberos-auth</code> (cryptographic authentication)</li> <li><code>--disable-negotiate-auth</code> (cryptographic authentication)</li> <li><code>--disable-aws</code> (cryptographic authentication)</li> <li><code>--disable-dateparse</code> (date parsing for time conditionals)</li> <li><code>--disable-dnsshuffle</code> (internal server load spreading)</li> <li><code>--disable-doh</code> (DNS-over-HTTP)</li> <li><code>--disable-form-api</code> (POST form API)</li> <li><code>--disable-get-easy-options</code> (lookup easy options at runtime)</li> <li><code>--disable-headers-api</code> (API to access headers)</li> <li><code>--disable-hsts</code> (HTTP Strict Transport Security)</li> <li><code>--disable-http-auth</code> (all HTTP authentication)</li> <li><code>--disable-ipv6</code> (IPv6)</li> <li><code>--disable-libcurl-option</code> (--libcurl C code generation support)</li> <li><code>--disable-manual</code> (--manual built-in documentation)</li> <li><code>--disable-mime</code> (MIME API)</li> <li><code>--disable-netrc</code> (.netrc file)</li> <li><code>--disable-ntlm</code> (NTLM authentication)</li> <li><code>--disable-ntlm-wb</code> (NTLM winbind)</li> <li><code>--disable-progress-meter</code> (graphical progress meter in library)</li> <li><code>--disable-proxy</code> (HTTP and SOCKS proxies)</li> <li><code>--disable-pthreads</code> (multi-threading)</li> <li><code>--disable-socketpair</code> (socketpair for asynchronous name resolving)</li> <li><code>--disable-threaded-resolver</code> (threaded name resolver)</li> <li><code>--disable-tls-srp</code> (Secure Remote Password authentication for TLS)</li> <li><code>--disable-unix-sockets</code> (Unix sockets)</li> <li><code>--disable-verbose</code> (eliminates debugging strings and error code strings)</li> <li><code>--disable-versioned-symbols</code> (versioned symbols)</li> <li><code>--enable-symbol-hiding</code> (eliminates unneeded symbols in the shared library)</li> <li><code>--without-brotli</code> (Brotli on-the-fly decompression)</li> <li><code>--without-libpsl</code> (Public Suffix List in cookies)</li> <li><code>--without-nghttp2</code> (HTTP/2 using nghttp2)</li> <li><code>--without-ngtcp2</code> (HTTP/2 using ngtcp2)</li> <li><code>--without-zstd</code> (Zstd on-the-fly decompression)</li> <li><code>--without-libidn2</code> (internationalized domain names)</li> <li><code>--without-librtmp</code> (RTMP)</li> <li><code>--without-ssl</code> (SSL/TLS)</li> <li><code>--without-zlib</code> (on-the-fly decompression)</li> </ul> <p>Be sure also to strip debugging symbols from your binaries after compiling using 'strip' or an option like <code>-s</code>. If space is really tight, you may be able to gain a few bytes by removing some unneeded sections of the shared library using the -R option to objcopy (e.g. the .comment section).</p> <p>Using these techniques it is possible to create a basic HTTP-only libcurl shared library for i386 Linux platforms that is only 130 KiB in size (as of libcurl version 8.6.0, using gcc 13.2.0).</p> <p>You may find that statically linking libcurl to your application results in a lower total size than dynamically linking.</p> <p>The curl test harness can detect the use of some, but not all, of the <code>--disable</code> statements suggested above. Use of these can cause tests relying on those features to fail. The test harness can be manually forced to skip the relevant tests by specifying certain key words on the <code>runtests.pl</code> command line. Following is a list of appropriate key words for those configure options that are not automatically detected:</p> <ul> <li><code>--disable-cookies</code> !cookies</li> <li><code>--disable-dateparse</code> !RETRY-AFTER !<code>CURLOPT_TIMECONDITION</code> !<code>CURLINFO_FILETIME</code> !<code>If-Modified-Since</code> !<code>curl_getdate</code> !<code>-z</code></li> <li><code>--disable-libcurl-option</code> !<code>--libcurl</code></li> <li><code>--disable-verbose</code> !verbose\ logs</li> </ul> <h1 id="ports">Ports</h1> <p>This is a probably incomplete list of known CPU architectures and operating systems that curl has been compiled for. If you know a system curl compiles and runs on, that is not listed, please let us know.</p> <h2 id="101-operating-systems">101 Operating Systems</h2> <pre><code>AIX, AmigaOS, Android, ArcoOS, Aros, Atari FreeMiNT, BeOS, Blackberry 10, Blackberry Tablet OS, Cell OS, CheriBSD, Chrome OS, Cisco IOS, DG/UX, Dragonfly BSD, DR DOS, eCOS, FreeBSD, FreeDOS, FreeRTOS, Fuchsia, Garmin OS, Genode, Haiku, HardenedBSD, HP-UX, Hurd, illumos, Integrity, iOS, ipadOS, IRIX, Linux, Lua RTOS, Mac OS 9, macOS, Mbed, Meego, Micrium, MINIX, Moblin, MorphOS, MPE/iX, MS-DOS, NCR MP-RAS, NetBSD, Netware, NextStep, Nintendo Switch, NonStop OS, NuttX, OpenBSD, OpenStep, Orbis OS, OS/2, OS/400, OS21, Plan 9, PlayStation Portable, QNX, Qubes OS, ReactOS, Redox, RISC OS, ROS, RTEMS, Sailfish OS, SCO Unix, Serenity, SINIX-Z, SkyOS, Solaris, Sortix, SunOS, Syllable OS, Symbian, Tizen, TPF, Tru64, tvOS, ucLinux, Ultrix, UNICOS, UnixWare, VMS, vxWorks, watchOS, Wear OS, WebOS, Wii system software, Wii U, Windows, Windows CE, Xbox System, Xenix, Zephyr, z/OS, z/TPF, z/VM, z/VSE</code></pre> <h2 id="28-cpu-architectures">28 CPU Architectures</h2> <pre><code>Alpha, ARC, ARM, AVR32, C-SKY, CompactRISC, Elbrus, ETRAX, HP-PA, Itanium, LoongArch, m68k, m88k, MicroBlaze, MIPS, Nios, OpenRISC, POWER, PowerPC, RISC-V, s390, SH4, SPARC, Tilera, VAX, x86, Xtensa, z/arch</code></pre> </div> </div> </body> </html>