Cross-compiler curl and support http2

Copyright: original articles without consent, is prohibited reprint https://blog.csdn.net/zmlovelx/article/details/86617920

Download nghttp2 Code
https://github.com/nghttp2/nghttp2/releases
decompression code, such as decompression to /home/zm/download/nghttp2-1.36.0, enter the code directory, compile
./configure --enable-lib- OpenWrt --host = ARM-only-Linux --prefix = / opt / Test / ThirdParty / the install /
the make
the make the install

Download curl Code
https://curl.haxx.se/download.html
or
https://curl.haxx.se/download/?C=M;O=D
unpacked, enter the code directory

假设其他的依赖库放在/opt/test/thirdparty/install/下,包括ssl cares 等库
生成Makefile
PKG_CONFIG_PATH="/opt/test/thirdparty/install/lib/pkgconfig" \
./configure --host=arm-openwrt-linux --enable-ares --enable-http --enable-ipv6 --enable-pthreads --enable-cookies --with-nghttp2=/opt/test/thirdparty/install  CPPFLAGS="-I/opt/test/thirdparty/install/include"  LDFLAGS="-L/opt/test/thirdparty/install/lib" LIBS="-L/opt/test/thirdparty/install/lib" --prefix=`pwd`/install

Modify Makefile
src / Makefile
1) CCLD = $ (CC) into CCLD = $ (CC) $ ( LIBCURL_LIBS)
do not change CCLD will
../lib/.libs/libcurl.so: undefined reference to `EVP_MD_CTX_free @ OPENSSL_1_1_0 '
../lib/.libs/libcurl.so: undefined reference to `X509_EXTENSION_get_object @ OPENSSL_1_1_0 '
error

After the curl-7.62.0, Makefile no CCLD, may be generated when the Makefile IBS = "- L / opt / test / thirdparty / install / lib" into

IBS="-L/opt/test/thirdparty/install/lib -lcares -lnghttp2 -lssl -lcrypto -lz"

After the change began compiling:
the make
the make install

Test support HTTP2
curl -v -k --http2 https://www.xdty.org

If you print out the following instructions compiled curl does not support HTTP2
curl: (1) Unsupported Protocol

以下为正常的打印
root@(none):/# curl -v -k --http2 https://www.xdty.org
*   Trying 54.95.68.178...
* TCP_NODELAY set
* Connected to www.xdty.org (54.95.68.178) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-ECDSA-CHACHA20-POLY1305
* ALPN, server accepted to use h2
* Server certificate:
*  subject: CN=xdty.org
*  start date: Dec 14 10:16:39 2018 GMT
*  expire date: Mar 14 10:16:39 2019 GMT
*  issuer: C=US; O=Let's Encrypt; CN=Let's Encrypt Authority X3
*  SSL certificate verify result: unable to get local issuer certificate (20), continuing anyway.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x79e788)
> GET / HTTP/2
> Host: www.xdty.org
> User-Agent: curl/7.63.0
> Accept: */*
>
* Connection state changed (MAX_CONCURRENT_STREAMS == 128)!
< HTTP/2 200

Author: handsome too afraid to go c ++ Haha Church: 31,843,264
 

Guess you like

Origin blog.csdn.net/zmlovelx/article/details/86617920