curl交叉编译
curl 用于在命令行或脚本中传输数据。curl 同时也是 libcurl——一个被广泛集成于汽车、电视机、路由器、打印机、音响设备、手机、平板电脑、医疗设备、机顶盒、电脑游戏、媒体播放器中的网络传输引擎,并作为超过两百亿个软件安装中的互联网数据传输核心组件。
curl下载
curl官方发布站:curl
git地址上源码下载:GitHub - curl/curl
最新版本下载地址:curl - Download
所有已释放版本下载地址:Releases · curl/curl · GitHub
以下载的最新版本curl-8.18.0.tar.gz为例:
curl-8.18.0.tar.gz
#解压并进入libssh-0.10.6目录
tar -zxvf curl-8.18.0.tar.gz
cd curl-8.18.0/
编译说明
进入curl-8.18.0源码目录后,通过在当前目录输入以下指令:
./configure --help
可以得知configure配置信息,此信息会告知我们如何配置configure配置文件来生成我们需要的Makefile,通过此Makefile来使用交叉编译工具链编译curl源码。
configure 帮助说明
英文说明:
`configure' configures curl - to adapt to many kinds of systems.
Usage: ./configure [OPTION]... [VAR=VALUE]...
To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE. See below for descriptions of some of the useful variables.
Defaults for the options are specified in brackets.
Configuration:
-h, --help display this help and exit
--help=short display options specific to this package
--help=recursive display the short help of all the included packages
-V, --version display version information and exit
-q, --quiet, --silent do not print `checking ...' messages
--cache-file=FILE cache test results in FILE [disabled]
-C, --config-cache alias for `--cache-file=config.cache'
-n, --no-create do not create output files
--srcdir=DIR find the sources in DIR [configure dir or `..']
Installation directories:
--prefix=PREFIX install architecture-independent files in PREFIX
[/usr/local]
--exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
[PREFIX]
By default, `make install' will install all the files in
`/usr/local/bin', `/usr/local/lib' etc. You can specify
an installation prefix other than `/usr/local' using `--prefix',
for instance `--prefix=$HOME'.
For better control, use the options below.
Fine tuning of the installation directories:
--bindir=DIR user executables [EPREFIX/bin]
--sbindir=DIR system admin executables [EPREFIX/sbin]
--libexecdir=DIR program executables [EPREFIX/libexec]
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
--runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
--datarootdir=DIR read-only arch.-independent data root [PREFIX/share]
--datadir=DIR read-only architecture-independent data [DATAROOTDIR]
--infodir=DIR info documentation [DATAROOTDIR/info]
--localedir=DIR locale-dependent data [DATAROOTDIR/locale]
--mandir=DIR man documentation [DATAROOTDIR/man]
--docdir=DIR documentation root [DATAROOTDIR/doc/curl]
--htmldir=DIR html documentation [DOCDIR]
--dvidir=DIR dvi documentation [DOCDIR]
--pdfdir=DIR pdf documentation [DOCDIR]
--psdir=DIR ps documentation [DOCDIR]
Program names:
--program-prefix=PREFIX prepend PREFIX to installed program names
--program-suffix=SUFFIX append SUFFIX to installed program names
--program-transform-name=PROGRAM run sed PROGRAM on installed program names
System types:
--build=BUILD configure for building on BUILD [guessed]
--host=HOST cross-compile to build programs to run on HOST [BUILD]
Optional Features:
--disable-option-checking ignore unrecognized --enable/--with options
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--enable-maintainer-mode
enable make rules and dependencies not useful (and
sometimes confusing) to the casual installer
--enable-silent-rules less verbose build output (undo: "make V=1")
--disable-silent-rules verbose build output (undo: "make V=0")
--enable-debug Enable debug build options
--disable-debug Disable debug build options
--enable-optimize Enable compiler optimizations
--disable-optimize Disable compiler optimizations
--enable-warnings Enable strict compiler warnings
--disable-warnings Disable strict compiler warnings
--enable-werror Enable compiler warnings as errors
--disable-werror Disable compiler warnings as errors
--enable-curldebug Enable curl debug memory tracking
--disable-curldebug Disable curl debug memory tracking
--enable-symbol-hiding Enable hiding of library internal symbols
--disable-symbol-hiding Disable hiding of library internal symbols
--enable-ares[=PATH] Enable c-ares for DNS lookups
--disable-ares Disable c-ares for DNS lookups
--disable-rt disable dependency on -lrt
--enable-httpsrr Enable HTTPSRR support
--disable-httpsrr Disable HTTPSRR support
--enable-ech Enable ECH support
--disable-ech Disable ECH support
--enable-ssls-export Enable SSL session export support
--disable-ssls-export Disable SSL session export support
--enable-dependency-tracking
do not reject slow dependency extractors
--disable-dependency-tracking
speeds up one-time build
--disable-largefile omit support for large files
--enable-shared[=PKGS] build shared libraries [default=yes]
--enable-static[=PKGS] build static libraries [default=yes]
--enable-fast-install[=PKGS]
optimize for fast installation [default=yes]
--disable-libtool-lock avoid locking (might break parallel builds)
--enable-code-coverage Provide code coverage
--enable-unity Enable unity mode
--disable-unity Disable unity (default)
--enable-http Enable HTTP support
--disable-http Disable HTTP support
--enable-ftp Enable FTP support
--disable-ftp Disable FTP support
--enable-file Enable FILE support
--disable-file Disable FILE support
--enable-ipfs Enable IPFS support
--disable-ipfs Disable IPFS support
--enable-ldap Enable LDAP support
--disable-ldap Disable LDAP support
--enable-ldaps Enable LDAPS support
--disable-ldaps Disable LDAPS support
--enable-rtsp Enable RTSP support
--disable-rtsp Disable RTSP support
--enable-proxy Enable proxy support
--disable-proxy Disable proxy support
--enable-dict Enable DICT support
--disable-dict Disable DICT support
--enable-telnet Enable TELNET support
--disable-telnet Disable TELNET support
--enable-tftp Enable TFTP support
--disable-tftp Disable TFTP support
--enable-pop3 Enable POP3 support
--disable-pop3 Disable POP3 support
--enable-imap Enable IMAP support
--disable-imap Disable IMAP support
--enable-smb Enable SMB/CIFS support
--disable-smb Disable SMB/CIFS support
--enable-smtp Enable SMTP support
--disable-smtp Disable SMTP support
--enable-gopher Enable Gopher support
--disable-gopher Disable Gopher support
--enable-mqtt Enable MQTT support
--disable-mqtt Disable MQTT support
--enable-manual Enable built-in manual
--disable-manual Disable built-in manual
--enable-docs Enable documentation
--disable-docs Disable documentation
--enable-libcurl-option Enable --libcurl C code generation support
--disable-libcurl-option
Disable --libcurl C code generation support
--enable-libgcc use libgcc when linking
--enable-ipv6 Enable IPv6 (with IPv4) support
--disable-ipv6 Disable IPv6 support
--enable-openssl-auto-load-config
Enable automatic loading of OpenSSL configuration
--disable-openssl-auto-load-config
Disable automatic loading of OpenSSL configuration
--enable-ca-search Enable unsafe CA bundle search in PATH on Windows
(default)
--disable-ca-search Disable unsafe CA bundle search in PATH on Windows
--enable-ca-search-safe Enable safe CA bundle search
--disable-ca-search-safe
Disable safe CA bundle search (default)
--enable-versioned-symbols
Enable versioned symbols in shared library
--disable-versioned-symbols
Disable versioned symbols in shared library
--enable-windows-unicode
Enable Windows Unicode
--disable-windows-unicode
Disable Windows Unicode (default)
--enable-threaded-resolver
Enable threaded resolver
--disable-threaded-resolver
Disable threaded resolver
--enable-typecheck Enable type checking (default)
--disable-typecheck Disable type checking
--enable-verbose Enable verbose strings
--disable-verbose Disable verbose strings
--enable-sspi Enable SSPI
--disable-sspi Disable SSPI
--enable-basic-auth Enable basic authentication (default)
--disable-basic-auth Disable basic authentication
--enable-bearer-auth Enable bearer authentication (default)
--disable-bearer-auth Disable bearer authentication
--enable-digest-auth Enable digest authentication (default)
--disable-digest-auth Disable digest authentication
--enable-kerberos-auth Enable kerberos authentication (default)
--disable-kerberos-auth Disable kerberos authentication
--enable-negotiate-auth Enable negotiate authentication (default)
--disable-negotiate-auth
Disable negotiate authentication
--enable-aws Enable AWS sig support (default)
--disable-aws Disable AWS sig support
--enable-ntlm Enable NTLM support
--disable-ntlm Disable NTLM support
--enable-tls-srp Enable TLS-SRP authentication
--disable-tls-srp Disable TLS-SRP authentication
--enable-unix-sockets Enable Unix domain sockets
--disable-unix-sockets Disable Unix domain sockets
--enable-cookies Enable cookies support
--disable-cookies Disable cookies support
--enable-socketpair Enable socketpair support
--disable-socketpair Disable socketpair support
--enable-http-auth Enable HTTP authentication support
--disable-http-auth Disable HTTP authentication support
--enable-doh Enable DoH support
--disable-doh Disable DoH support
--enable-mime Enable mime API support
--disable-mime Disable mime API support
--enable-bindlocal Enable local binding support
--disable-bindlocal Disable local binding support
--enable-form-api Enable form API support
--disable-form-api Disable form API support
--enable-dateparse Enable date parsing
--disable-dateparse Disable date parsing
--enable-netrc Enable netrc parsing
--disable-netrc Disable netrc parsing
--enable-progress-meter Enable progress-meter
--disable-progress-meter
Disable progress-meter
--enable-sha512-256 Enable SHA-512/256 hash algorithm (default)
--disable-sha512-256 Disable SHA-512/256 hash algorithm
--enable-dnsshuffle Enable DNS shuffling
--disable-dnsshuffle Disable DNS shuffling
--enable-get-easy-options
Enable curl_easy_options
--disable-get-easy-options
Disable curl_easy_options
--enable-alt-svc Enable alt-svc support
--disable-alt-svc Disable alt-svc support
--enable-headers-api Enable headers-api support
--disable-headers-api Disable headers-api support
--enable-hsts Enable HSTS support
--disable-hsts Disable HSTS support
--enable-websockets Enable WebSockets support
--disable-websockets Disable WebSockets support
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--with-schannel enable Windows native SSL/TLS
--with-amissl enable Amiga native SSL/TLS (AmiSSL)
--with-ssl=PATH old version of --with-openssl
--without-ssl build without any TLS library
--with-openssl=PATH Where to look for OpenSSL, PATH points to the SSL
installation (default: /usr/local/ssl); when
possible, set the PKG_CONFIG_PATH environment
variable instead of using this option
--with-gnutls=PATH where to look for GnuTLS, PATH points to the
installation root
--with-mbedtls=PATH where to look for mbedTLS, PATH points to the
installation root
--with-wolfssl=PATH where to look for wolfSSL, PATH points to the
installation root (default: system lib default)
--with-rustls=PATH where to look for Rustls, PATH points to the
installation root
--with-apple-sectrust enable Apple OS native certificate verification
--with-test-nghttpx=PATH
where to find nghttpx for testing
--with-test-caddy=PATH where to find caddy for testing
--with-test-vsftpd=PATH where to find vsftpd for testing
--with-test-httpd=PATH where to find httpd/apache2 for testing
--with-test-danted=PATH where to find danted socks daemon for testing
--with-test-sshd=PATH where to find sshd for testing
--with-pic[=PKGS] try to use only PIC/non-PIC objects [default=use
both]
--with-aix-soname=aix|svr4|both
shared library versioning (aka "SONAME") variant to
provide on AIX, [default=aix].
--with-gnu-ld assume the C compiler uses GNU ld [default=no]
--with-sysroot[=DIR] Search for dependent libraries within DIR (or the
compiler's sysroot if not specified).
--enable-backtrace use libbacktrace when linking
--with-zlib=PATH search for zlib in PATH
--without-zlib disable use of zlib
--with-brotli=PATH Where to look for brotli, PATH points to the BROTLI
installation; when possible, set the PKG_CONFIG_PATH
environment variable instead of using this option
--without-brotli disable BROTLI
--with-zstd=PATH Where to look for libzstd, PATH points to the
libzstd installation; when possible, set the
PKG_CONFIG_PATH environment variable instead of
using this option
--without-zstd disable libzstd
--with-gssapi-includes=DIR
Specify location of GSS-API headers
--with-gssapi-libs=DIR Specify location of GSS-API libs
--with-gssapi=DIR Where to look for GSS-API
--with-default-ssl-backend=NAME
Use NAME as default SSL backend
--without-default-ssl-backend
Use implicit default SSL backend
--with-ca-bundle=FILE Absolute path to a file containing CA certificates
(example: /etc/ca-bundle.crt)
--without-ca-bundle Do not use a default CA bundle
--with-ca-path=DIRECTORY
Absolute path to a directory containing CA
certificates stored individually, with their
filenames in a hash format. This option can be used
with the OpenSSL, GnuTLS, mbedTLS and wolfSSL
backends. Refer to OpenSSL c_rehash for details.
(example: /etc/certificates)
--without-ca-path Do not use a default CA path
--with-ca-fallback Use OpenSSL's built-in CA store
--without-ca-fallback Do not use OpenSSL's built-in CA store
--with-ca-embed=FILE Absolute path to a file containing CA certificates
to embed in the curl tool (example:
/etc/ca-bundle.crt)
--without-ca-embed Do not embed a default CA bundle in the curl tool
--with-libpsl=PATH Where to look for libpsl, PATH points to the LIBPSL
installation; when possible, set the PKG_CONFIG_PATH
environment variable instead of using this option
--without-libpsl disable LIBPSL
--with-libgsasl=PATH Where to look for libgsasl, PATH points to the
libgsasl installation; when possible, set the
PKG_CONFIG_PATH environment variable instead of
using this option
--without-libgsasl disable libgsasl support for SCRAM
--with-libssh2=PATH Where to look for libssh2, PATH points to the
libssh2 installation; when possible, set the
PKG_CONFIG_PATH environment variable instead of
using this option
--with-libssh2 enable libssh2
--with-libssh=PATH Where to look for libssh, PATH points to the libssh
installation; when possible, set the PKG_CONFIG_PATH
environment variable instead of using this option
--with-libssh enable libssh
--with-ldap-lib=libname Specify name of ldap lib file
--with-lber-lib=libname Specify name of lber lib file
--with-ldap=PATH Where to look for LDAP, PATH points to the LDAP
installation; when possible, set the PKG_CONFIG_PATH
environment variable instead of using this option
--without-ldap disable LDAP
--with-librtmp=PATH Where to look for librtmp, PATH points to the
LIBRTMP installation; when possible, set the
PKG_CONFIG_PATH environment variable instead of
using this option
--without-librtmp disable LIBRTMP
--with-winidn=PATH enable Windows native IDN
--without-winidn disable Windows native IDN
--with-apple-idn Enable AppleIDN
--without-apple-idn Disable AppleIDN
--with-libidn2=PATH Enable libidn2 usage
--without-libidn2 Disable libidn2 usage
--with-nghttp2=PATH Enable nghttp2 usage
--without-nghttp2 Disable nghttp2 usage
--with-ngtcp2=PATH Enable ngtcp2 usage
--without-ngtcp2 Disable ngtcp2 usage
--with-openssl-quic Enable OpenSSL QUIC usage
--without-openssl-quic Disable OpenSSL QUIC usage
--with-nghttp3=PATH Enable nghttp3 usage
--without-nghttp3 Disable nghttp3 usage
--with-quiche=PATH Enable quiche usage
--without-quiche Disable quiche usage
--with-libuv=PATH Enable libuv
--without-libuv Disable libuv
--with-zsh-functions-dir=PATH
Install zsh completions to PATH
--without-zsh-functions-dir
Do not install zsh completions
--with-fish-functions-dir=PATH
Install fish completions to PATH
--without-fish-functions-dir
Do not install fish completions
Some influential environment variables:
CC C compiler command
CFLAGS C compiler flags
LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
nonstandard directory <lib dir>
LIBS libraries to pass to the linker, e.g. -l<library>
CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
you have headers in a nonstandard directory <include dir>
CPP C preprocessor
LT_SYS_LIBRARY_PATH
User-defined run-time library search path.
Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.
Report bugs to <a suitable curl mailing list: https://curl.se/mail/>.
中文说明
configure 用于配置 curl,使其适应多种系统。
用法: ./configure [选项]... [变量=值]...
要设置环境变量(例如 CC、CFLAGS 等),请以 VAR=VALUE 的形式指定。下方列出了一些有用变量的说明。
选项的默认值在方括号中注明。
配置选项:
-h, --help 显示此帮助信息并退出
--help=short 显示本软件包特有的选项
--help=recursive 显示所有包含软件包的简短帮助
-V, --version 显示版本信息并退出
-q, --quiet, --silent 不打印“checking ...”消息
--cache-file=FILE 将测试结果缓存到文件中 [禁用]
-C, --config-cache --cache-file=config.cache 的别名
-n, --no-create 不创建输出文件
--srcdir=DIR 在指定目录中查找源码 [configure 所在目录或其上一级]
安装目录:
--prefix=PREFIX 将与体系结构无关的文件安装到 PREFIX [/usr/local]
--exec-prefix=EPREFIX 将与体系结构相关的文件安装到 EPREFIX[PREFIX]
默认情况下,“make install”会将所有文件安装到 /usr/local/bin、/usr/local/lib 等目录。
您可以使用 --prefix 指定不同于 /usr/local 的安装前缀,例如 --prefix= $ HOME。
如需更精细的控制,请使用以下选项。
安装目录的精细调整:
--bindir=DIR 用户可执行程序 [EPREFIX/bin]
--sbindir=DIR 系统管理员可执行程序 [EPREFIX/sbin]
--libexecdir=DIR 程序可执行文件 [EPREFIX/libexec]
--sysconfdir=DIR 只读的单机数据 [PREFIX/etc]
--sharedstatedir=DIR 可修改的、与体系结构无关的数据 [PREFIX/com]
--localstatedir=DIR 可修改的单机数据 [PREFIX/var]
--runstatedir=DIR 可修改的每进程数据 [LOCALSTATEDIR/run]
--libdir=DIR 目标代码库 [EPREFIX/lib]
--includedir=DIR C 头文件 [PREFIX/include]
--oldincludedir=DIR 非 GCC 使用的 C 头文件 [/usr/include]
--datarootdir=DIR 只读的、与体系结构无关的数据根目录 [PREFIX/share]
--datadir=DIR 只读的、与体系结构无关的数据 [DATAROOTDIR]
--infodir=DIR info 文档 [DATAROOTDIR/info]
--localedir=DIR 本地化相关数据 [DATAROOTDIR/locale]
--mandir=DIR man 手册文档 [DATAROOTDIR/man]
--docdir=DIR 文档根目录 [DATAROOTDIR/doc/curl]
--htmldir=DIR HTML 文档 [DOCDIR]
--dvidir=DIR DVI 文档 [DOCDIR]
--pdfdir=DIR PDF 文档 [DOCDIR]
--psdir=DIR PostScript 文档 [DOCDIR]
程序名称:
--program-prefix=PREFIX 为已安装的程序名添加前缀 PREFIX
--program-suffix=SUFFIX 为已安装的程序名添加后缀 SUFFIX
--program-transform-name=PROGRAM 对已安装的程序名运行 sed PROGRAM
系统类型:
--build=BUILD 配置在 BUILD 上进行构建 [自动检测]
--host=HOST 交叉编译,生成在 HOST 上运行的程序 [BUILD]
可选功能:
--disable-option-checking 忽略无法识别的 --enable/--with 选项
--disable-FEATURE 不包含 FEATURE(等同于 --enable-FEATURE=no)
--enable-FEATURE[=ARG] 包含 FEATURE [ARG=yes]
--enable-maintainer-mode
启用对普通安装者无用(有时会造成混淆)的 make 规则和依赖项
--enable-silent-rules 构建输出更简洁(取消:make V=1)
--disable-silent-rules 构建输出更详细(取消:make V=0)
--enable-debug 启用调试构建选项
--disable-debug 禁用调试构建选项
--enable-optimize 启用编译器优化
--disable-optimize 禁用编译器优化
--enable-warnings 启用严格的编译器警告
--disable-warnings 禁用严格的编译器警告
--enable-werror 将编译器警告视为错误
--disable-werror 不将编译器警告视为错误
--enable-curldebug 启用 curl 调试内存跟踪
--disable-curldebug 禁用 curl 调试内存跟踪
--enable-symbol-hiding 启用隐藏库内部符号
--disable-symbol-hiding 禁用隐藏库内部符号
--enable-ares[=PATH] 启用 c-ares 用于 DNS 查询
--disable-ares 禁用 c-ares 用于 DNS 查询
--disable-rt 禁用对 -lrt 的依赖
--enable-httpsrr 启用 HTTPSRR 支持
--disable-httpsrr 禁用 HTTPSRR 支持
--enable-ech 启用 ECH 支持
--disable-ech 禁用 ECH 支持
--enable-ssls-export 启用 SSL 会话导出支持
--disable-ssls-export 禁用 SSL 会话导出支持
--enable-dependency-tracking
不拒绝较慢的依赖提取器
--disable-dependency-tracking
加快一次性构建速度
--disable-largefile 省略对大文件的支持
--enable-shared[=PKGS] 构建共享库 [default=yes]
--enable-static[=PKGS] 构建静态库 [default=yes]
--enable-fast-install[=PKGS]
优化以加快安装速度 [default=yes]
--disable-libtool-lock 避免锁定(可能破坏并行构建)
--enable-code-coverage 提供代码覆盖率支持
--enable-unity 启用 unity 模式
--disable-unity 禁用 unity 模式 (default)
--enable-http 启用 HTTP 支持
--disable-http 禁用 HTTP 支持
--enable-ftp 启用 FTP 支持
--disable-ftp 禁用 FTP 支持
--enable-file 启用 FILE 支持
--disable-file 禁用 FILE 支持
--enable-ipfs 启用 IPFS 支持
--disable-ipfs 禁用 IPFS 支持
--enable-ldap 启用 LDAP 支持
--disable-ldap 禁用 LDAP 支持
--enable-ldaps 启用 LDAPS 支持
--disable-ldaps 禁用 LDAPS 支持
--enable-rtsp 启用 RTSP 支持
--disable-rtsp 禁用 RTSP 支持
--enable-proxy 启用 proxy 支持
--disable-proxy 禁用 proxy 支持
--enable-dict 启用 DICT 支持
--disable-dict 禁用 DICT 支持
--enable-telnet 启用 TELNET 支持
--disable-telnet 禁用 TELNET 支持
--enable-tftp 启用 TFTP 支持
--disable-tftp 禁用 TFTP 支持
--enable-pop3 启用 POP3 支持
--disable-pop3 禁用 POP3 支持
--enable-imap 启用 IMAP 支持
--disable-imap 禁用 IMAP 支持
--enable-smb 启用 SMB/CIFS 支持
--disable-smb 禁用 SMB/CIFS 支持
--enable-smtp 启用 SMTP 支持
--disable-smtp 禁用 SMTP 支持
--enable-gopher 启用 Gopher 支持
--disable-gopher 禁用 Gopher 支持
--enable-mqtt 启用 MQTT 支持
--disable-mqtt 禁用 MQTT 支持
--enable-manual 启用内置手册
--disable-manual 禁用内置手册
--enable-docs 启用文档生成
--disable-docs 禁用文档生成
--enable-libcurl-option 启用 --libcurl C 代码生成功能
--disable-libcurl-option
禁用 --libcurl C 代码生成功能
--enable-libgcc 链接时使用 libgcc
--enable-ipv6 启用 IPv6(同时支持 IPv4)
--disable-ipv6 禁用 IPv6 支持
--enable-openssl-auto-load-config
启用 OpenSSL 配置的自动加载
--disable-openssl-auto-load-config
禁用 OpenSSL 配置的自动加载
--enable-ca-search 在 Windows 上启用不安全的 CA bundle PATH 搜索(default)
--disable-ca-search 在 Windows 上禁用不安全的 CA bundle PATH 搜索
--enable-ca-search-safe 启用安全的 CA bundle 搜索
--disable-ca-search-safe
禁用安全的 CA bundle 搜索 (default)
--enable-versioned-symbols
在共享库中启用带版本的符号
--disable-versioned-symbols
在共享库中禁用带版本的符号
--enable-windows-unicode
启用 Windows Unicode
--disable-windows-unicode
禁用 Windows Unicode (default)
--enable-threaded-resolver
启用线程化解析器
--disable-threaded-resolver
禁用线程化解析器
--enable-typecheck 启用类型检查 (default)
--disable-typecheck 禁用类型检查
--enable-verbose 启用详细字符串
--disable-verbose 禁用详细字符串
--enable-sspi 启用 SSPI
--disable-sspi 禁用 SSPI
--enable-basic-auth 启用基本认证 (default)
--disable-basic-auth 禁用基本认证
--enable-bearer-auth 启用 Bearer 认证 (default)
--disable-bearer-auth 禁用 Bearer 认证
--enable-digest-auth 启用摘要认证 (default)
--disable-digest-auth 禁用摘要认证
--enable-kerberos-auth 启用 Kerberos 认证 (default)
--disable-kerberos-auth 禁用 Kerberos 认证
--enable-negotiate-auth 启用 Negotiate 认证 (default)
--disable-negotiate-auth
禁用 Negotiate 认证
--enable-aws 启用 AWS 签名支持 (default)
--disable-aws 禁用 AWS 签名支持
--enable-ntlm 启用 NTLM 支持
--disable-ntlm 禁用 NTLM 支持
--enable-tls-srp 启用 TLS-SRP 认证
--disable-tls-srp 禁用 TLS-SRP 认证
--enable-unix-sockets 启用 Unix 域套接字
--disable-unix-sockets 禁用 Unix 域套接字
--enable-cookies 启用 cookies 支持
--disable-cookies 禁用 cookies 支持
--enable-socketpair 启用 socketpair 支持
--disable-socketpair 禁用 socketpair 支持
--enable-http-auth 启用 HTTP 认证支持
--disable-http-auth 禁用 HTTP 认证支持
--enable-doh 启用 DoH 支持
--disable-doh 禁用 DoH 支持
--enable-mime 启用 mime API 支持
--disable-mime 禁用 mime API 支持
--enable-bindlocal 启用本地绑定支持
--disable-bindlocal 禁用本地绑定支持
--enable-form-api 启用表单 API 支持
--disable-form-api 禁用表单 API 支持
--enable-dateparse 启用日期解析
--disable-dateparse 禁用日期解析
--enable-netrc 启用 netrc 解析
--disable-netrc 禁用 netrc 解析
--enable-progress-meter 启用进度条
--disable-progress-meter
禁用进度条
--enable-sha512-256 启用 SHA-512/256 哈希算法 (default)
--disable-sha512-256 禁用 SHA-512/256 哈希算法 algorithm
--enable-dnsshuffle 启用 DNS 打乱
--disable-dnsshuffle 禁用 DNS 打乱
--enable-get-easy-options
启用 curl_easy_options
--disable-get-easy-options
禁用 curl_easy_options
--enable-alt-svc 启用 alt-svc 支持
--disable-alt-svc 禁用 alt-svc 支持
--enable-headers-api 启用 headers-api 支持
--disable-headers-api 禁用 headers-api 支持
--enable-hsts 启用 HSTS 支持
--disable-hsts 禁用 HSTS 支持
--enable-websockets 启用 WebSockets 支持
--disable-websockets 禁用 WebSockets 支持
可选软件包:
--with-PACKAGE[=ARG] 使用 PACKAGE [ARG=yes]
--without-PACKAGE 不使用 PACKAGE (same as --with-PACKAGE=no)
--with-schannel 启用 Windows 原生 SSL/TLS
--with-amissl 启用 Amiga 原生 SSL/TLS(AmiSSL)
--with-ssl=PATH --with-openssl 的旧版写法
--without-ssl 不使用任何 TLS 库进行构建
--with-openssl=PATH 指定 OpenSSL 安装路径(default:/usr/local/ssl);
建议优先设置 PKG_CONFIG_PATH 环境变量
--with-gnutls=PATH 指定 GnuTLS 安装根路径
--with-mbedtls=PATH 指定 mbedTLS 安装根路径
--with-wolfssl=PATH 指定 wolfSSL 安装根路径(default: 系统库默认位置)
--with-rustls=PATH 指定 Rustls 安装根路径
--with-apple-sectrust 启用 Apple OS 原生证书验证
--with-test-nghttpx=PATH
指定用于测试的 nghttpx 路径
--with-test-caddy=PATH 指定用于测试的 caddy 路径
--with-test-vsftpd=PATH 指定用于测试的 vsftpd 路径
--with-test-httpd=PATH 指定用于测试的 httpd/apache2 路径
--with-test-danted=PATH 指定用于测试的 danted socks 守护进程路径
--with-test-sshd=PATH 指定用于测试的 sshd 路径
--with-pic[=PKGS] 尝试仅使用 PIC/non-PIC 对象 [默认=两者都用] [default=use both]
--with-aix-soname=aix|svr4|both
在 AIX 上提供的共享库版本(即“SONAME”)变体 [默认=aix]
[default=aix].
--with-gnu-ld 假设 C 编译器使用 GNU ld [default=no]
--with-sysroot[=DIR] 在 DIR 内(或编译器的 sysroot,若未指定)搜索依赖库
--enable-backtrace 链接时使用 libbacktrace
--with-zlib=PATH 在 PATH 中搜索 zlib
--without-zlib 禁用 zlib
--with-brotli=PATH 指定 Brotli 安装路径;建议优先设置 PKG_CONFIG_PATH
--without-brotli 禁用 Brotli
--with-zstd=PATH 指定 libzstd 安装路径;建议优先设置 PKG_CONFIG_PATH
--without-zstd 禁用 libzstd
--with-gssapi-includes=DIR
指定 GSS-API 头文件位置
--with-gssapi-libs=DIR 指定 GSS-API 库文件位置
--with-gssapi=DIR 指定 GSS-API 安装路径
--with-default-ssl-backend=NAME
使用 NAME 作为默认 SSL 后端
--without-default-ssl-backend
使用隐式默认 SSL 后端
--with-ca-bundle=FILE 指定包含 CA 证书的文件绝对路径(例如:/etc/ca-bundle.crt)
--without-ca-bundle 不使用默认 CA bundle
--with-ca-path=DIRECTORY
指定包含单独存储的 CA 证书的目录绝对路径,
文件名需为哈希格式(适用于 OpenSSL、GnuTLS、mbedTLS 和 wolfSSL;详情参见 OpenSSL c_rehash)
(例如:/etc/certificates)
--without-ca-path 不使用默认 CA 路径
--with-ca-fallback 使用 OpenSSL 内置的 CA 存储
--without-ca-fallback 不使用 OpenSSL 内置的 CA 存储
--with-ca-embed=FILE 指定要嵌入 curl 工具中的 CA 证书文件绝对路径(例如:/etc/ca-bundle.crt)
--without-ca-embed 不在 curl 工具中嵌入默认 CA bundle
--with-libpsl=PATH 指定 libpsl 安装路径;建议优先设置 PKG_CONFIG_PATH
--without-libpsl 禁用 libpsl
--with-libgsasl=PATH 指定 libgsasl 安装路径;建议优先设置 PKG_CONFIG_PATH
--without-libgsasl 禁用 libgsasl 的 SCRAM 支持
--with-libssh2=PATH 指定 libssh2 安装路径;建议优先设置 PKG_CONFIG_PATH
--with-libssh2 启用 libssh2
--with-libssh=PATH 指定 libssh 安装路径;建议优先设置 PKG_CONFIG_PATH
--with-libssh 启用 libssh
--with-ldap-lib=libname 指定 ldap 库文件名
--with-lber-lib=libname 指定 lber 库文件名
--with-ldap=PATH 指定 LDAP 安装路径;建议优先设置 PKG_CONFIG_PATH
--without-ldap 禁用 LDAP
--with-librtmp=PATH 指定 librtmp 安装路径;建议优先设置 PKG_CONFIG_PATH
--without-librtmp 禁用 librtmp
--with-winidn=PATH 启用 Windows 原生 IDN
--without-winidn 禁用 Windows 原生 IDN
--with-apple-idn 启用 AppleIDN
--without-apple-idn 禁用 AppleIDN
--with-libidn2=PATH 启用 libidn2 用法
--without-libidn2 禁用 libidn2 用法
--with-nghttp2=PATH 启用 nghttp2 用法
--without-nghttp2 禁用 nghttp2 用法
--with-ngtcp2=PATH 启用 ngtcp2 用法
--without-ngtcp2 禁用 ngtcp2 用法
--with-openssl-quic 启用 OpenSSL QUIC 用法
--without-openssl-quic 禁用 OpenSSL QUIC 用法
--with-nghttp3=PATH 启用 nghttp3 用法
--without-nghttp3 禁用 nghttp3 用法
--with-quiche=PATH 启用 quiche 用法
--without-quiche 禁用 quiche 用法
--with-libuv=PATH 启用 libuv
--without-libuv 禁用 libuv
--with-zsh-functions-dir=PATH
将 zsh 补全脚本安装到 PATH
--without-zsh-functions-dir
不安装 zsh 补全脚本
--with-fish-functions-dir=PATH
将 fish 补全脚本安装到 PATH
--without-fish-functions-dir
不安装 fish 补全脚本
一些有影响的环境变量:
CC C 编译器命令
CFLAGS 编译器标志
LDFLAGS 链接器标志,例如当库位于非标准目录 时使用 -L
LIBS 传递给链接器的库,例如 -l
CPPFLAGS (Objective) C/C++ 预处理器标志,例如当头文件位于非标准目录 时使用 -I
CPP C 预处理器
LT_SYS_LIBRARY_PATH
用户定义的运行时库搜索路径
使用这些变量可覆盖 configure 的选择,或帮助它找到具有非标准名称/位置的库和程序。
请将 bug 报告发送至合适的 curl 邮件列表t: https://curl.se/mail/>.
额外说明
在 Unix 系统上,curl 的标准安装通常分为三到四个步骤(解压源码包之后):
./configure --with-openssl # 或 --with-gnutls、--with-wolfssl 等
make
make test # (可选)
make install
默认行为与依赖
默认启用 libpsl(Public Suffix List)支持。
如果你的系统未安装 libpsl,要么安装它,要么通过 --without-libpsl 显式禁用:
./configure --with-openssl --without-libpsl
- 必须显式指定一个 TLS 后端,除非你完全禁用 TLS(使用
--without-ssl)。
curl 不会自动猜测使用哪个 TLS 库。
安装路径自定义
默认安装前缀是 /usr/local。若要安装到其他位置(例如你的家目录),使用 --prefix:
./configure --prefix=$HOME
make
make install
这样就不需要 root 权限(前提是对你指定的目录有写权限)。
指定 TLS 库的位置
推荐方式:使用 pkg-config(如果可用)
如果你的 OpenSSL 安装在非标准路径(如 /opt/OpenSSL),且系统有 pkg-config:
env PKG_CONFIG_PATH=/opt/OpenSSL/lib/pkgconfig ./configure --with-openssl
无 pkg-config 时:直接指定路径
./configure --with-openssl=/opt/OpenSSL
头文件和库分离的情况
如果 OpenSSL 的头文件和库分别位于不同目录:
CPPFLAGS="-I/path/to/ssl/include" \
LDFLAGS="-L/path/to/ssl/lib" \
./configure --with-openssl
运行时链接问题(共享库找不到)
如果 OpenSSL 共享库安装在运行时链接器无法找到的位置(如 /usr/local/ssl/lib),需硬编码运行时库路径:
LDFLAGS="-Wl,-R/usr/local/ssl/lib" ./configure --with-openssl
-R(或--rpath)会将该路径嵌入可执行文件中,确保运行时能正确加载库。
完全禁用 TLS(不推荐)
仅在特殊场景下使用(例如仅用于调试或受限环境):
./configure --without-ssl
⚠️ 注意:这将导致 curl 无法使用 HTTPS、FTPS 等安全协议。
权限说明
make和make test无需特殊权限。make install通常需要 root 权限(除非--prefix指向你有写权限的目录,如$HOME)。
静态构建(Static Builds)
若要强制生成静态库,需在配置时禁用共享库:
./configure --disable-shared
重要提示:
configure脚本主要为使用共享/动态第三方依赖库而设计。
使用共享库时,现代系统的动态链接器会自动处理依赖链。
但使用静态库时,你必须在链接阶段显式提供所有直接和间接依赖项。
静态链接的挑战
- 静态链接要求你手动指定整个依赖树(包括依赖的依赖)。
- 这些依赖因平台、版本不同而变化,难以自动推断。
- 构建脚本通常假设用户自行提供所有额外依赖库,例如通过
LIBS或LDFLAGS传入:
./configure --disable-shared \
LDFLAGS="-L/path/to/deps/lib" \
LIBS="-lssl -lcrypto -lz -ldl"
“静态构建不适合胆小者” —— 官方原话,意指其复杂性和易错性。
调试构建(Debug)
如果你是 curl 开发者并使用 GCC,可启用更详细的调试选项:
./configure --enable-debug
这会开启额外的断言、内存跟踪(如 --enable-curldebug)和编译器警告。
选择 TLS 后端(Select TLS Backend)
curl 支持多种 TLS 库,可通过以下选项启用:
| TLS 库 | 配置选项 |
|---|---|
| OpenSSL | --with-openssl |
| GnuTLS | --with-gnutls |
| mbedTLS | --with-mbedtls |
| wolfSSL | --with-wolfssl |
| Rustls | --with-rustls |
| Schannel | --with-schannel(Windows) |
| AmiSSL | --with-amissl(Amiga) |
多 TLS 后端支持(MultiSSL)
-
可同时启用多个 TLS 后端(如
OpenSSL + GnuTLS):./configure --with-openssl --with-gnutls -
限制:
- 不能同时启用两个 OpenSSL 分支(如 OpenSSL + LibreSSL)或多个 wolfSSL,因为符号名冲突。
-
运行时可通过
curl_easy_setopt(..., CURLOPT_SSL_BACKEND, ...)切换后端。
TLS 信任锚(Trust Anchors)配置
服务器证书验证依赖“信任锚”(根证书)。可通过以下方式指定:
| 选项 | 说明 |
|---|---|
--with-ca-bundle=FILE | 指定默认 CA 证书包文件(运行时加载) |
--with-ca-path=DIR | 指定包含散列命名 CA 证书的目录 |
--with-ca-embed=FILE | 构建时嵌入 CA 证书到 curl 二进制中 |
--with-ca-fallback | (OpenSSL 专用)回退到 OpenSSL 内置的信任存储 |
--with-apple-sectrust | (macOS/iOS)使用系统 SecTrust API(8.17.0+) |
若未指定,configure 会尝试自动检测系统默认 CA 存储位置。
MultiSSL 与 HTTP/3 互斥
- HTTP/3 依赖 QUIC,而 QUIC 要求 TLS 与传输层深度集成。
- 因此:
- 启用 HTTP/3 → 必须使用单一 TLS 后端(如
OpenSSL with QUIC或ngtcp2+nghttp3)。 - 启用 MultiSSL → 无法支持 HTTP/3。
- 启用 HTTP/3 → 必须使用单一 TLS 后端(如
- 两者不能共存,构建时需二选一。
常见问题:configure 找错库路径
当 configure 检测第三方库时,会将找到的路径加入 LDFLAGS。
这可能导致后续库检测误用之前添加的路径,从而找到错误版本的库。
解决方法:
-
清理环境:确保无残留的
LDFLAGS/CPPFLAGS。 -
显式指定路径:对每个依赖使用
--with-xxx=/path。 -
使用 pkg-config
(推荐):避免路径污染。
PKG_CONFIG_PATH=/opt/lib/pkgconfig ./configure --with-openssl
curl交叉编译
交叉编译
解压下载后的源码包内容如下:
acinclude.m4 CHANGES.md CMakeLists.txt config.guess configure COPYING depcomp docs install-sh libcurl.pc.in m4 Makefile.in packages projects RELEASE-NOTES src
aclocal.m4 CMake compile config.sub configure.ac curl-config.in Dockerfile include lib ltmain.sh Makefile.am missing plan9 README scripts tests
其中有一个configure文件,此文件使用方法见上述configure帮助说明。
交叉编译请设置环境变量以指向交叉编译工具链,并在调用 configure 时传入所需选项。务必在配置时明确指定 --host 和 --build 参数。
示例:
# 设置工具链路径(假设工具链已安装在 /opt/hardhat/devkit/ppc/405/bin)
export PATH=$PATH:/opt/hardhat/devkit/ppc/405/bin
export CPPFLAGS="-I/opt/hardhat/devkit/ppc/405/target/usr/include"
export AR=ppc_405-ar
export AS=ppc_405-as
export LD=ppc_405-ld
export RANLIB=ppc_405-ranlib
export CC=ppc_405-gcc
export NM=ppc_405-nm
# --host=目标系统(IBM 405GP 属于 powerpc 架构)
# --build=指定构建系统(当前主机)
./configure \
--target=powerpc-hardhat-linux
--host=powerpc-hardhat-linux
--build=i586-pc-linux-gnu
--prefix=/opt/hardhat/devkit/ppc/405/target/usr/local
--exec-prefix=/usr/local
--prefix 参数用于指定 curl 的安装路径。如果 configure 成功完成,接下来只需像平常一样执行 make 和 make install 即可。
在某些情况下,你可以将上述命令简化为仅一行,例如:
./configure --host=ARCH-OS
其中 ARCH-OS 是目标平台的架构和操作系统标识(如 arm-linux-gnueabihf、aarch64-linux-gnu 等)。
这种简化之所以可行,是因为:
- 交叉编译工具链已正确加入
PATH; - 环境变量(如
CC)已自动匹配到对应前缀的编译器(例如ARCH-OS-gcc); - 不需要额外指定
--build(configure 可自动检测); - 无需自定义 TLS 后端或其他依赖(或系统默认满足要求)。
不过,在实际项目中,为确保可重现性和明确性,建议显式设置关键参数(如 --build、工具链变量和依赖路径),尤其是在复杂或嵌入式环境中。
龙芯平台交叉编译静态库
由于交叉编译需要用到openssl,所以同时需要对openssl的源码也使用龙芯的交叉编译工具链进行编译,
对于OpenSSL的交叉编译,参照文章:linux下使用交叉编译工具链编译openssl_openssl linux编译-CSDN博客
以龙芯交叉编译工具进行说明,Linux平台下编译,编译为静态库,工具链路径:
/opt/loongson-gnu-toolchain-13.2/bin
静态库存放路径:
/root/workspace/lib_libary
那么配置config时输入以下指令后直接make即可进行编译:
#CPPFLAGS= 显式指定依赖库的头文件路径
#LDFLAGS= 显式指定静态库路径
#CC 指定交叉编译工具的位置
#--host 交叉编译,用于生成在loongarch64-unknown-linux-gnu上运行的程序
#--prefix 编译出来的文件安装路径
#--disable-shared 只构建静态库
CPPFLAGS="-I/root/workspace/svn_code/lib_libary/dep_libs/openssl/include" \
LDFLAGS="-L/root/workspace/svn_code/lib_libary/dep_libs/openssl/lib" \
CC=/opt/loongson-gnu-toolchain-13.2/bin/loongarch64-unknown-linux-gnu-gcc \
./configure \
--host=loongarch64-unknown-linux-gnu \
--prefix=/root/workspace/lib_libary \
--with-openssl \
--without-libpsl \
--disable-shared \
--disable-ldap \
--disable-ldaps \
--disable-rtsp \
--disable-proxy \
--disable-dict \
--disable-telnet \
--disable-tftp \
--disable-pop3 \
--disable-imap \
--disable-smb \
--disable-smtp \
--disable-gopher \
--disable-manual \
--disable-libcurl-option
#使用makefile文件进行编译,并将编译好的文件安装到`--prefix`指定的目录`/root/workspace/lib_libary`下
make
make install
编译完成后,在--prefix指定的目录/root/workspace/lib_libary下会有四个文件夹:
ls
bin include lib share
编译后所需要的头文件在include中,静态库libcurl.a就在lib目录下。
清理编译结果:
make clean

5674

被折叠的 条评论
为什么被折叠?



