本文介绍libcurl的交叉编译
如果不需要交叉编译的话,直接通过 configure make make install 三连基本就能用.
首先介绍编译参数
General parameters:
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:
#根据自己需求选择 #由于参数太多,大部分包只列举enable参数,需要禁止把enable改成disable就行 --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") --enable-debug Enable debug build options --enable-optimize Enable compiler optimizations --enable-warnings Enable strict compiler warnings --enable-werror Enable compiler warnings as errors --enable-curldebug Enable curl debug memory tracking --enable-symbol-hiding Enable hiding of library internal symbols --enable-hidden-symbols To be deprecated, use --enable-symbol-hiding --enable-ares[=PATH] Enable c-ares for DNS lookups --disable-rt disable dependency on -lrt --enable-ech Enable ECH support --enable-code-coverage Provide code coverage --enable-dependency-tracking do not reject slow dependency extractors --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-http Enable HTTP support --enable-ftp Enable FTP support --enable-file Enable FILE support --enable-ldap Enable LDAP support --enable-ldaps Enable LDAPS support --enable-rtsp Enable RTSP support --enable-proxy Enable proxy support --enable-dict Enable DICT support --enable-telnet Enable TELNET support --enable-tftp Enable TFTP support --enable-pop3 Enable POP3 support --enable-imap Enable IMAP support --enable-smb Enable SMB/CIFS support --enable-smtp Enable SMTP support --enable-gopher Enable Gopher support --enable-mqtt Enable MQTT support --enable-manual Enable built-in manual --enable-libcurl-option Enable --libcurl C code generation support --enable-libgcc use libgcc when linking --enable-ipv6 Enable IPv6 (with IPv4) support --enable-openssl-auto-load-config Enable automatic loading of OpenSSL configuration --enable-versioned-symbols Enable versioned symbols in shared library --enable-threaded-resolver Enable threaded resolver --enable-pthreads Enable POSIX threads (default for threaded resolver) --enable-verbose Enable verbose strings --enable-sspi Enable SSPI --enable-crypto-auth Enable cryptographic authentication --enable-ntlm-wb[=FILE] Enable NTLM delegation to winbind's ' ntlm_auth \ helper, where FILE is ntlm_auth's ' absolute filename \ (default: /usr/bin/ntlm_auth) --enable-tls-srp Enable TLS-SRP authentication --enable-unix-sockets Enable Unix domain sockets --enable-cookies Enable cookies support --enable-socketpair Enable socketpair support --enable-http-auth Enable HTTP authentication support --enable-doh Enable DoH support --enable-mime Enable mime API support --enable-dateparse Enable date parsing --enable-netrc Enable netrc parsing --enable-progress-meter Enable progress-meter --enable-dnsshuffle Enable DNS shuffling --enable-get-easy-options Enable curl_easy_options --enable-alt-svc Enable alt-svc support --enable-hsts Enable HSTS support
Optional Packages:
#通过--with-<packagesname>=PATH 启动 #通过--without-<packagesname> 禁用 #具体明细可通过 configure -h 查看 #下面只列出几个特殊的参数 --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --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). --with-ldap-lib=libname Specify name of ldap lib file --with-lber-lib=libname Specify name of lber lib file --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-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 --with-default-ssl-backend=NAME Use NAME as default SSL backend --without-default-ssl-backend Use implicit default SSL backend
常规包列表(packagesname)
- quiche
- nghttp3
- ngtcp2
- nghttp2
- libidn2
- winidn
- librtmp
- wolfssh
- libssh
- libssh2
- libmetalink
- libpsl
- ca-fallback
- ca-path
- nss
- schannel
- mesalink
- mbedtls
- gnutls
- zlib
- brotli
- zstd
- winssl
- darwinssl
- amissl
- wolfssl
- bearssl
- ssl
- secure-transport
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.
本文使用的交叉编译器:
arm-linux-gcc
如果没有openssl库的,参考交叉编译openssl
以下是本人进行的编译参数(仅供参考)
#首先配置环境变量 CFLAGS=-fPIC LIBS="-ldl" #生成Makefile ./configure \ --host=arm-linux CC=/opt/vtcs_toolchain/vienna/usr/bin/arm-linux-gcc CXX=/opt/vtcs_toolchain/vienna/usr/bin/arm-linux-g++ \ --prefix=/armlib/curl \ --with-ssl=/armlib/openssl \ --enable-shared --enable-static --enable-http-auth --enable-http --enable-warnings --enable-file --enable-libcurl-option \ --disable-pop3 --disable-dict --disable-imap --disable-ldap --disable-ldaps --disable-proxy --disable-smb --disable-gopher --disable-mqtt --disable-hsts --disable-smtp --disable-telnet \ --without-ca-bundle --without-gnutls --without-libidn --without-librtmp --without-libssh2 --without-nss --without-zlib \ --without-wolfssl --without-winssl --without-schannel --without-darwinssl --without-secure-transport
configure配置成功的打印信息(仅供参考)
最后执行
make
make install
即可
参考网址