1# how to install curl and libcurl 2 3## Installing Binary Packages 4 5Lots of people download binary distributions of curl and libcurl. This 6document does not describe how to install curl or libcurl using such a binary 7package. This document describes how to compile, build and install curl and 8libcurl from source code. 9 10## Building using vcpkg 11 12You can download and install curl and libcurl using the [vcpkg](https://github.com/Microsoft/vcpkg/) dependency manager: 13 14 git clone https://github.com/Microsoft/vcpkg.git 15 cd vcpkg 16 ./bootstrap-vcpkg.sh 17 ./vcpkg integrate install 18 vcpkg install curl[tool] 19 20The curl port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository. 21 22## Building from git 23 24If you get your code off a git repository instead of a release tarball, see 25the `GIT-INFO` file in the root directory for specific instructions on how to 26proceed. 27 28# Unix 29 30A normal Unix installation is made in three or four steps (after you've 31unpacked the source archive): 32 33 ./configure 34 make 35 make test (optional) 36 make install 37 38You probably need to be root when doing the last command. 39 40Get a full listing of all available configure options by invoking it like: 41 42 ./configure --help 43 44If you want to install curl in a different file hierarchy than `/usr/local`, 45specify that when running configure: 46 47 ./configure --prefix=/path/to/curl/tree 48 49If you have write permission in that directory, you can do 'make install' 50without being root. An example of this would be to make a local install in 51your own home directory: 52 53 ./configure --prefix=$HOME 54 make 55 make install 56 57The configure script always tries to find a working SSL library unless 58explicitly told not to. If you have OpenSSL installed in the default search 59path for your compiler/linker, you don't need to do anything special. If you 60have OpenSSL installed in `/usr/local/ssl`, you can run configure like: 61 62 ./configure --with-ssl 63 64If you have OpenSSL installed somewhere else (for example, `/opt/OpenSSL`) and 65you have pkg-config installed, set the pkg-config path first, like this: 66 67 env PKG_CONFIG_PATH=/opt/OpenSSL/lib/pkgconfig ./configure --with-ssl 68 69Without pkg-config installed, use this: 70 71 ./configure --with-ssl=/opt/OpenSSL 72 73If you insist on forcing a build without SSL support, even though you may 74have OpenSSL installed in your system, you can run configure like this: 75 76 ./configure --without-ssl 77 78If you have OpenSSL installed, but with the libraries in one place and the 79header files somewhere else, you have to set the `LDFLAGS` and `CPPFLAGS` 80environment variables prior to running configure. Something like this should 81work: 82 83 CPPFLAGS="-I/path/to/ssl/include" LDFLAGS="-L/path/to/ssl/lib" ./configure 84 85If you have shared SSL libs installed in a directory where your run-time 86linker doesn't find them (which usually causes configure failures), you can 87provide this option to gcc to set a hard-coded path to the run-time linker: 88 89 LDFLAGS=-Wl,-R/usr/local/ssl/lib ./configure --with-ssl 90 91## More Options 92 93To force a static library compile, disable the shared library creation by 94running configure like: 95 96 ./configure --disable-shared 97 98To tell the configure script to skip searching for thread-safe functions, add 99an option like: 100 101 ./configure --disable-thread 102 103If you're a curl developer and use gcc, you might want to enable more debug 104options with the `--enable-debug` option. 105 106curl can be built to use a whole range of libraries to provide various useful 107services, and configure will try to auto-detect a decent default. But if you 108want to alter it, you can select how to deal with each individual library. 109 110## Select TLS backend 111 112The default OpenSSL configure check will also detect and use BoringSSL or 113libressl. 114 115 - GnuTLS: `--without-ssl --with-gnutls`. 116 - wolfSSL: `--without-ssl --with-wolfssl` 117 - NSS: `--without-ssl --with-nss` 118 - PolarSSL: `--without-ssl --with-polarssl` 119 - mbedTLS: `--without-ssl --with-mbedtls` 120 - schannel: `--without-ssl --with-schannel` 121 - secure transport: `--without-ssl --with-secure-transport` 122 - MesaLink: `--without-ssl --with-mesalink` 123 124# Windows 125 126## Building Windows DLLs and C run-time (CRT) linkage issues 127 128 As a general rule, building a DLL with static CRT linkage is highly 129 discouraged, and intermixing CRTs in the same app is something to avoid at 130 any cost. 131 132 Reading and comprehending Microsoft Knowledge Base articles KB94248 and 133 KB140584 is a must for any Windows developer. Especially important is full 134 understanding if you are not going to follow the advice given above. 135 136 - [How To Use the C Run-Time](https://support.microsoft.com/help/94248/how-to-use-the-c-run-time) 137 - [Run-Time Library Compiler Options](https://docs.microsoft.com/cpp/build/reference/md-mt-ld-use-run-time-library) 138 - [Potential Errors Passing CRT Objects Across DLL Boundaries](https://docs.microsoft.com/cpp/c-runtime-library/potential-errors-passing-crt-objects-across-dll-boundaries) 139 140If your app is misbehaving in some strange way, or it is suffering from 141memory corruption, before asking for further help, please try first to 142rebuild every single library your app uses as well as your app using the 143debug multithreaded dynamic C runtime. 144 145 If you get linkage errors read section 5.7 of the FAQ document. 146 147## MingW32 148 149Make sure that MinGW32's bin dir is in the search path, for example: 150 151 set PATH=c:\mingw32\bin;%PATH% 152 153then run `mingw32-make mingw32` in the root dir. There are other 154make targets available to build libcurl with more features, use: 155 156 - `mingw32-make mingw32-zlib` to build with Zlib support; 157 - `mingw32-make mingw32-ssl-zlib` to build with SSL and Zlib enabled; 158 - `mingw32-make mingw32-ssh2-ssl-zlib` to build with SSH2, SSL, Zlib; 159 - `mingw32-make mingw32-ssh2-ssl-sspi-zlib` to build with SSH2, SSL, Zlib 160 and SSPI support. 161 162If you have any problems linking libraries or finding header files, be sure 163to verify that the provided `Makefile.m32` files use the proper paths, and 164adjust as necessary. It is also possible to override these paths with 165environment variables, for example: 166 167 set ZLIB_PATH=c:\zlib-1.2.8 168 set OPENSSL_PATH=c:\openssl-1.0.2c 169 set LIBSSH2_PATH=c:\libssh2-1.6.0 170 171It is also possible to build with other LDAP SDKs than MS LDAP; currently 172it is possible to build with native Win32 OpenLDAP, or with the Novell CLDAP 173SDK. If you want to use these you need to set these vars: 174 175 set LDAP_SDK=c:\openldap 176 set USE_LDAP_OPENLDAP=1 177 178or for using the Novell SDK: 179 180 set USE_LDAP_NOVELL=1 181 182If you want to enable LDAPS support then set LDAPS=1. 183 184## Cygwin 185 186Almost identical to the unix installation. Run the configure script in the 187curl source tree root with `sh configure`. Make sure you have the `sh` 188executable in `/bin/` or you'll see the configure fail toward the end. 189 190Run `make` 191 192## Disabling Specific Protocols in Windows builds 193 194The configure utility, unfortunately, is not available for the Windows 195environment, therefore, you cannot use the various disable-protocol options of 196the configure utility on this platform. 197 198However, you can use the following defines to disable specific 199protocols: 200 201 - `HTTP_ONLY` disables all protocols except HTTP 202 - `CURL_DISABLE_FTP` disables FTP 203 - `CURL_DISABLE_LDAP` disables LDAP 204 - `CURL_DISABLE_TELNET` disables TELNET 205 - `CURL_DISABLE_DICT` disables DICT 206 - `CURL_DISABLE_FILE` disables FILE 207 - `CURL_DISABLE_TFTP` disables TFTP 208 - `CURL_DISABLE_HTTP` disables HTTP 209 - `CURL_DISABLE_IMAP` disables IMAP 210 - `CURL_DISABLE_POP3` disables POP3 211 - `CURL_DISABLE_SMTP` disables SMTP 212 213If you want to set any of these defines you have the following options: 214 215 - Modify `lib/config-win32.h` 216 - Modify `lib/curl_setup.h` 217 - Modify `winbuild/Makefile.vc` 218 - Modify the "Preprocessor Definitions" in the libcurl project 219 220Note: The pre-processor settings can be found using the Visual Studio IDE 221under "Project -> Settings -> C/C++ -> General" in VC6 and "Project -> 222Properties -> Configuration Properties -> C/C++ -> Preprocessor" in later 223versions. 224 225## Using BSD-style lwIP instead of Winsock TCP/IP stack in Win32 builds 226 227In order to compile libcurl and curl using BSD-style lwIP TCP/IP stack it is 228necessary to make definition of preprocessor symbol `USE_LWIPSOCK` visible to 229libcurl and curl compilation processes. To set this definition you have the 230following alternatives: 231 232 - Modify `lib/config-win32.h` and `src/config-win32.h` 233 - Modify `winbuild/Makefile.vc` 234 - Modify the "Preprocessor Definitions" in the libcurl project 235 236Note: The pre-processor settings can be found using the Visual Studio IDE 237under "Project -> Settings -> C/C++ -> General" in VC6 and "Project -> 238Properties -> Configuration Properties -> C/C++ -> Preprocessor" in later 239versions. 240 241Once that libcurl has been built with BSD-style lwIP TCP/IP stack support, in 242order to use it with your program it is mandatory that your program includes 243lwIP header file `<lwip/opt.h>` (or another lwIP header that includes this) 244before including any libcurl header. Your program does not need the 245`USE_LWIPSOCK` preprocessor definition which is for libcurl internals only. 246 247Compilation has been verified with [lwIP 2481.4.0](https://download.savannah.gnu.org/releases/lwip/lwip-1.4.0.zip) and 249[contrib-1.4.0](https://download.savannah.gnu.org/releases/lwip/contrib-1.4.0.zip). 250 251This BSD-style lwIP TCP/IP stack support must be considered experimental given 252that it has been verified that lwIP 1.4.0 still needs some polish, and libcurl 253might yet need some additional adjustment, caveat emptor. 254 255## Important static libcurl usage note 256 257When building an application that uses the static libcurl library on Windows, 258you must add `-DCURL_STATICLIB` to your `CFLAGS`. Otherwise the linker will 259look for dynamic import symbols. 260 261## Legacy Windows and SSL 262 263Schannel (from Windows SSPI), is the native SSL library in Windows. However, 264Schannel in Windows <= XP is unable to connect to servers that 265no longer support the legacy handshakes and algorithms used by those 266versions. If you will be using curl in one of those earlier versions of 267Windows you should choose another SSL backend such as OpenSSL. 268 269# Apple iOS and macOS 270 271On modern Apple operating systems, curl can be built to use Apple's SSL/TLS 272implementation, Secure Transport, instead of OpenSSL. To build with Secure 273Transport for SSL/TLS, use the configure option `--with-darwinssl`. (It is not 274necessary to use the option `--without-ssl`.) This feature requires iOS 5.0 or 275later, or OS X 10.5 ("Leopard") or later. 276 277When Secure Transport is in use, the curl options `--cacert` and `--capath` 278and their libcurl equivalents, will be ignored, because Secure Transport uses 279the certificates stored in the Keychain to evaluate whether or not to trust 280the server. This, of course, includes the root certificates that ship with the 281OS. The `--cert` and `--engine` options, and their libcurl equivalents, are 282currently unimplemented in curl with Secure Transport. 283 284For macOS users: In OS X 10.8 ("Mountain Lion"), Apple made a major overhaul 285to the Secure Transport API that, among other things, added support for the 286newer TLS 1.1 and 1.2 protocols. To get curl to support TLS 1.1 and 1.2, you 287must build curl on Mountain Lion or later, or by using the equivalent SDK. If 288you set the `MACOSX_DEPLOYMENT_TARGET` environmental variable to an earlier 289version of macOS prior to building curl, then curl will use the new Secure 290Transport API on Mountain Lion and later, and fall back on the older API when 291the same curl binary is executed on older cats. For example, running these 292commands in curl's directory in the shell will build the code such that it 293will run on cats as old as OS X 10.6 ("Snow Leopard") (using bash): 294 295 export MACOSX_DEPLOYMENT_TARGET="10.6" 296 ./configure --with-darwinssl 297 make 298 299# Cross compile 300 301Download and unpack the curl package. 302 303`cd` to the new directory. (e.g. `cd curl-7.12.3`) 304 305Set environment variables to point to the cross-compile toolchain and call 306configure with any options you need. Be sure and specify the `--host` and 307`--build` parameters at configuration time. The following script is an 308example of cross-compiling for the IBM 405GP PowerPC processor using the 309toolchain from MonteVista for Hardhat Linux. 310 311 #! /bin/sh 312 313 export PATH=$PATH:/opt/hardhat/devkit/ppc/405/bin 314 export CPPFLAGS="-I/opt/hardhat/devkit/ppc/405/target/usr/include" 315 export AR=ppc_405-ar 316 export AS=ppc_405-as 317 export LD=ppc_405-ld 318 export RANLIB=ppc_405-ranlib 319 export CC=ppc_405-gcc 320 export NM=ppc_405-nm 321 322 ./configure --target=powerpc-hardhat-linux 323 --host=powerpc-hardhat-linux 324 --build=i586-pc-linux-gnu 325 --prefix=/opt/hardhat/devkit/ppc/405/target/usr/local 326 --exec-prefix=/usr/local 327 328You may also need to provide a parameter like `--with-random=/dev/urandom` to 329configure as it cannot detect the presence of a random number generating 330device for a target system. The `--prefix` parameter specifies where curl 331will be installed. If `configure` completes successfully, do `make` and `make 332install` as usual. 333 334In some cases, you may be able to simplify the above commands to as little as: 335 336 ./configure --host=ARCH-OS 337 338# REDUCING SIZE 339 340There are a number of configure options that can be used to reduce the size of 341libcurl for embedded applications where binary size is an important factor. 342First, be sure to set the `CFLAGS` variable when configuring with any relevant 343compiler optimization flags to reduce the size of the binary. For gcc, this 344would mean at minimum the -Os option, and potentially the `-march=X`, 345`-mdynamic-no-pic` and `-flto` options as well, e.g. 346 347 ./configure CFLAGS='-Os' LDFLAGS='-Wl,-Bsymbolic'... 348 349Note that newer compilers often produce smaller code than older versions 350due to improved optimization. 351 352Be sure to specify as many `--disable-` and `--without-` flags on the 353configure command-line as you can to disable all the libcurl features that you 354know your application is not going to need. Besides specifying the 355`--disable-PROTOCOL` flags for all the types of URLs your application will not 356use, here are some other flags that can reduce the size of the library: 357 358 - `--disable-ares` (disables support for the C-ARES DNS library) 359 - `--disable-cookies` (disables support for HTTP cookies) 360 - `--disable-crypto-auth` (disables HTTP cryptographic authentication) 361 - `--disable-ipv6` (disables support for IPv6) 362 - `--disable-manual` (disables support for the built-in documentation) 363 - `--disable-proxy` (disables support for HTTP and SOCKS proxies) 364 - `--disable-unix-sockets` (disables support for UNIX sockets) 365 - `--disable-verbose` (eliminates debugging strings and error code strings) 366 - `--disable-versioned-symbols` (disables support for versioned symbols) 367 - `--enable-hidden-symbols` (eliminates unneeded symbols in the shared library) 368 - `--without-libidn` (disables support for the libidn DNS library) 369 - `--without-librtmp` (disables support for RTMP) 370 - `--without-ssl` (disables support for SSL/TLS) 371 - `--without-zlib` (disables support for on-the-fly decompression) 372 373The GNU compiler and linker have a number of options that can reduce the 374size of the libcurl dynamic libraries on some platforms even further. 375Specify them by providing appropriate `CFLAGS` and `LDFLAGS` variables on 376the configure command-line, e.g. 377 378 CFLAGS="-Os -ffunction-sections -fdata-sections 379 -fno-unwind-tables -fno-asynchronous-unwind-tables -flto" 380 LDFLAGS="-Wl,-s -Wl,-Bsymbolic -Wl,--gc-sections" 381 382Be sure also to strip debugging symbols from your binaries after compiling 383using 'strip' (or the appropriate variant if cross-compiling). If space is 384really tight, you may be able to remove some unneeded sections of the shared 385library using the -R option to objcopy (e.g. the .comment section). 386 387Using these techniques it is possible to create a basic HTTP-only shared 388libcurl library for i386 Linux platforms that is only 113 KiB in size, and an 389FTP-only library that is 113 KiB in size (as of libcurl version 7.50.3, using 390gcc 5.4.0). 391 392You may find that statically linking libcurl to your application will result 393in a lower total size than dynamically linking. 394 395Note that the curl test harness can detect the use of some, but not all, of 396the `--disable` statements suggested above. Use will cause tests relying on 397those features to fail. The test harness can be manually forced to skip the 398relevant tests by specifying certain key words on the `runtests.pl` command 399line. Following is a list of appropriate key words: 400 401 - `--disable-cookies` !cookies 402 - `--disable-manual` !--manual 403 - `--disable-proxy` !HTTP\ proxy !proxytunnel !SOCKS4 !SOCKS5 404 405# PORTS 406 407This is a probably incomplete list of known hardware and operating systems 408that curl has been compiled for. If you know a system curl compiles and 409runs on, that isn't listed, please let us know! 410 411 - Alpha DEC OSF 4 412 - Alpha Digital UNIX v3.2 413 - Alpha FreeBSD 4.1, 4.5 414 - Alpha Linux 2.2, 2.4 415 - Alpha NetBSD 1.5.2 416 - Alpha OpenBSD 3.0 417 - Alpha OpenVMS V7.1-1H2 418 - Alpha Tru64 v5.0 5.1 419 - AVR32 Linux 420 - ARM Android 1.5, 2.1, 2.3, 3.2, 4.x 421 - ARM INTEGRITY 422 - ARM iOS 423 - Cell Linux 424 - Cell Cell OS 425 - HP-PA HP-UX 9.X 10.X 11.X 426 - HP-PA Linux 427 - HP3000 MPE/iX 428 - MicroBlaze uClinux 429 - MIPS IRIX 6.2, 6.5 430 - MIPS Linux 431 - OS/400 432 - Pocket PC/Win CE 3.0 433 - Power AIX 3.2.5, 4.2, 4.3.1, 4.3.2, 5.1, 5.2 434 - PowerPC Darwin 1.0 435 - PowerPC INTEGRITY 436 - PowerPC Linux 437 - PowerPC Mac OS 9 438 - PowerPC Mac OS X 439 - SH4 Linux 2.6.X 440 - SH4 OS21 441 - SINIX-Z v5 442 - Sparc Linux 443 - Sparc Solaris 2.4, 2.5, 2.5.1, 2.6, 7, 8, 9, 10 444 - Sparc SunOS 4.1.X 445 - StrongARM (and other ARM) RISC OS 3.1, 4.02 446 - StrongARM/ARM7/ARM9 Linux 2.4, 2.6 447 - StrongARM NetBSD 1.4.1 448 - Symbian OS (P.I.P.S.) 9.x 449 - TPF 450 - Ultrix 4.3a 451 - UNICOS 9.0 452 - i386 BeOS 453 - i386 DOS 454 - i386 eCos 1.3.1 455 - i386 Esix 4.1 456 - i386 FreeBSD 457 - i386 HURD 458 - i386 Haiku OS 459 - i386 Linux 1.3, 2.0, 2.2, 2.3, 2.4, 2.6 460 - i386 Mac OS X 461 - i386 MINIX 3.1 462 - i386 NetBSD 463 - i386 Novell NetWare 464 - i386 OS/2 465 - i386 OpenBSD 466 - i386 QNX 6 467 - i386 SCO unix 468 - i386 Solaris 2.7 469 - i386 Windows 95, 98, ME, NT, 2000, XP, 2003 470 - i486 ncr-sysv4.3.03 (NCR MP-RAS) 471 - ia64 Linux 2.3.99 472 - m68k AmigaOS 3 473 - m68k Linux 474 - m68k uClinux 475 - m68k OpenBSD 476 - m88k dg-dgux5.4R3.00 477 - s390 Linux 478 - x86_64 Linux 479 - XScale/PXA250 Linux 2.4 480 - Nios II uClinux 481