curl编译笔记

1 下载curl 版本为:
curl download
openssl编译参考这里:openssl
2 配置生成makefile

CPPFLAGS="-I/home/qlz/opt/openssl/build-static/include" LDFLAGS="-L/home/qlz/opt/openssl/build-static/lib" LIBS="-ldl" ./configure --host=arm-himix200-linux CC=arm-himix200-linux-gcc CXX=arm-himix200-linux-g++ --with-ssl --disable-shared --enable-static --disable-dict --disable-ftp --disable-imap --disable-ldap --disable-ldaps --disable-pop3 --disable-proxy --disable-rtsp --disable-smtp --disable-telnet --disable-tftp --disable-zlib --without-ca-bundle --without-gnutls --without-libidn --without-librtmp --without-libssh2 --without-nss --without-zlib --prefix=/home/qlz/opt/curl-7.71.1/build

在这里插入图片描述
上边的方法是手动指定了基于openssl的include和lib路径。还可以省去这一步,只需要指定openssl的路径就可以了。

./configure --disable-debug --disable-dict --disable-ftp --disable-imap --disable-ldap --disable-ldaps --disable-pop3 --disable-proxy --disable-smtp --disable-telnet --disable-tftp --disable-zlib --without-ca-bundle --without-gnutls --without-libidn2 --without-librtmp --without-nss --without-zlib --with-ssl=/usr/local/openssl --prefix=/usr/local/curl

我将openssl安装到了/usr/local/openssl下:
在这里插入图片描述
注意:像zlib brotli灯库尽量设置为–without类型,以免运行代码的时候会报以下错误:
在这里插入图片描述
在这里插入图片描述

3 make

make

在这里插入图片描述

4 make install

sudo make install

参考:https://blog.csdn.net/weixin_44023406/article/details/103617654

如果并非交叉编译”
交叉编译和非交叉编译取决于–host参数释放指定

openssl
./config --prefix=/usr/local/openssl
./config --cross-compile-prefix=arm-himix200-linux- --prefix=/usr/local/openssl-mix200
make
sudo make install
curl装到/usr/local/curl
./configure --disable-debug --disable-dict --disable-ftp --disable-imap --disable-ldap --disable-ldaps --disable-pop3 --disable-proxy --disable-smtp --disable-telnet --disable-tftp --disable-zlib --without-ca-bundle --without-gnutls --without-libidn2 --without-librtmp --without-nss --without-zlib --with-ssl=/usr/local/openssl --prefix=/usr/local/curl

./configure --host=arm-himix200-linux CC=arm-himix200-linux-gcc CXX=arm-himix200-linux-g++ --disable-debug --disable-dict --disable-ftp --disable-imap --disable-ldap --disable-ldaps --disable-pop3 --disable-proxy --disable-smtp --disable-telnet --disable-tftp --disable-zlib --without-ca-bundle --without-gnutls --without-libidn2 --without-librtmp --without-nss --without-zlib --with-ssl=/home/xxx/opt/openssl-mix200/build --prefix=/home/xxx/opt/curl-mix200/build
make
sudo make install

遇到的大bug

编译curl make的时候,突然出现 了这种错误:
在这里插入图片描述
找了一天没找到原因,后来在这里看到了这个:

dopi@ubuntu:~$ arm-himix200-linux-gcc -v
arm-himix200-linux-gcc: loadlocale.c:130: _nl_intern_locale_data: Assertion `cnt < (sizeof (_nl_value_type_LC_TIME) / sizeof (_nl_value_type_LC_TIME[0]))' failed.
Aborted (core dumped)
dopi@ubuntu:~$ 

解决方法

export LC_CTYPE=C.UTF-8

后续笔记
发现一个奇怪的现象,如果在pc端或者linux端(非交叉)编译openssl静态库和curl静态库,在项目中只添加curl的头文件,-L库目录 -l库名称,是没有问题的。同样的方法用在交叉编译上,只加curl的头文件目录、库目录、连接库还不行,会报下图的错:

openssl.c:(.text+0x3f64): undefined reference to `SSL_get_privatekey'
openssl.c:(.text+0x3f6c): undefined reference to `EVP_PKEY_id'
openssl.c:(.text+0x3f7c): undefined reference to `SSL_free'
openssl.c:(.text+0x3f84): undefined reference to `SSL_CTX_check_private_key'
openssl.c:(.text+0x3f9c): undefined reference to `X509_free'
openssl.c:(.text+0x3fec): undefined reference to `UI_create_method'
openssl.c:(.text+0x3ff8): undefined reference to `UI_OpenSSL'
openssl.c:(.text+0x3ffc): undefined reference to `UI_method_get_opener'
openssl.c:(.text+0x4008): undefined reference to `UI_method_set_opener'
openssl.c:(.text+0x400c): undefined reference to `UI_OpenSSL'
openssl.c:(.text+0x4010): undefined reference to `UI_method_get_closer'
openssl.c:(.text+0x401c): undefined reference to `UI_method_set_closer'
openssl.c:(.text+0x4028): undefined reference to `UI_method_set_reader'
openssl.c:(.text+0x4034): undefined reference to `UI_method_set_writer'
openssl.c:(.text+0x404c): undefined reference to `ENGINE_load_private_key'
openssl.c:(.text+0x4058): undefined reference to `UI_destroy_method'
openssl.c:(.text+0x406c): undefined reference to `SSL_CTX_use_PrivateKey'
openssl.c:(.text+0x4088): undefined reference to `EVP_PKEY_free'
openssl.c:(.text+0x4098): undefined reference to `X509_free'
openssl.c:(.text+0x40a4): undefined reference to `ERR_get_error'
openssl.c:(.text+0x40fc): undefined reference to `PEM_read_bio_PrivateKey'
openssl.c:(.text+0x4160): undefined reference to `ENGINE_ctrl_cmd'
openssl.c:(.text+0x417c): undefined reference to `SSL_CTX_use_certificate'
openssl.c:(.text+0x4198): undefined reference to `X509_free'
openssl.c:(.text+0x41a4): undefined reference to `PKCS12_free'
openssl.c:(.text+0x41b0): undefined reference to `SSL_CTX_use_certificate'
openssl.c:(.text+0x41bc): undefined reference to `ERR_get_error'
openssl.c:(.text+0x41dc): undefined reference to `EVP_PKEY_free'
openssl.c:(.text+0x41e4): undefined reference to `X509_free'
openssl.c:(.text+0x41f0): undefined reference to `OPENSSL_sk_pop_free'
openssl.c:(.text+0x4258): undefined reference to `SSL_CTX_use_PrivateKey'
openssl.c:(.text+0x4294): undefined reference to `SSL_CTX_use_certificate_file'
openssl.c:(.text+0x42a8): undefined reference to `SSL_CTX_use_certificate_chain_file'
openssl.c:(.text+0x43c4): undefined reference to `X509_free'
openssl.c:(.text+0x441c): undefined reference to `SSL_CTX_get_cert_store'
openssl.c:(.text+0x4424): undefined reference to `X509_STORE_set_flags'
openssl.c:(.text+0x4450): undefined reference to `SSL_CTX_set_verify'
openssl.c:(.text+0x4470): undefined reference to `SSL_CTX_ctrl'
openssl.c:(.text+0x447c): undefined reference to `SSL_CTX_sess_set_new_cb'
openssl.c:(.text+0x44d0): undefined reference to `SSL_free'
openssl.c:(.text+0x44d8): undefined reference to `SSL_new'
openssl.c:(.text+0x450c): undefined reference to `SSL_set_connect_state'
openssl.c:(.text+0x4560): undefined reference to `BIO_f_ssl'
openssl.c:(.text+0x4564): undefined reference to `BIO_new'
openssl.c:(.text+0x457c): undefined reference to `BIO_ctrl'
openssl.c:(.text+0x458c): undefined reference to `SSL_set_bio'
openssl.c:(.text+0x45b0): undefined reference to `SSL_CTX_load_verify_locations'
openssl.c:(.text+0x4624): undefined reference to `SSL_CTX_set_srp_username'
openssl.c:(.text+0x4644): undefined reference to `SSL_CTX_set_srp_password'
openssl.c:(.text+0x4684): undefined reference to `SSL_CTX_set_cipher_list'
openssl.c:(.text+0x46a4): undefined reference to `ERR_get_error'
openssl.c:(.text+0x4748): undefined reference to `SSL_CTX_set_keylog_callback'
openssl.c:(.text+0x47f4): undefined reference to `SSL_CTX_get_cert_store'
openssl.c:(.text+0x47fc): undefined reference to `X509_STORE_set_flags'
openssl.c:(.text+0x4838): undefined reference to `SSL_CTX_get_cert_store'
openssl.c:(.text+0x4840): undefined reference to `X509_STORE_set_flags'
openssl.c:(.text+0x48a8): undefined reference to `SSL_CTX_check_private_key'
openssl.c:(.text+0x48cc): undefined reference to `OPENSSL_sk_pop'
openssl.c:(.text+0x48dc): undefined reference to `SSL_CTX_add_client_CA'
openssl.c:(.text+0x48f8): undefined reference to `SSL_CTX_ctrl'
openssl.c:(.text+0x4908): undefined reference to `OPENSSL_sk_num'
openssl.c:(.text+0x4918): undefined reference to `EVP_PKEY_free'
openssl.c:(.text+0x4920): undefined reference to `X509_free'
openssl.c:(.text+0x492c): undefined reference to `OPENSSL_sk_pop_free'
openssl.c:(.text+0x4984): undefined reference to `EVP_PKEY_free'
openssl.c:(.text+0x49bc): undefined reference to `X509_free'
openssl.c:(.text+0x49d4): undefined reference to `X509_free'
openssl.c:(.text+0x49f0): undefined reference to `X509_free'
openssl.c:(.text+0x4a1c): undefined reference to `BIO_free'
openssl.c:(.text+0x4a24): undefined reference to `ERR_get_error'
openssl.c:(.text+0x4a4c): undefined reference to `SSL_CTX_use_PrivateKey_file'
openssl.c:(.text+0x4a7c): undefined reference to `EVP_PKEY_get1_RSA'
openssl.c:(.text+0x4a84): undefined reference to `RSA_flags'
openssl.c:(.text+0x4a94): undefined reference to `RSA_free'
openssl.c:(.text+0x4a9c): undefined reference to `SSL_free'
openssl.c:(.text+0x4b14): undefined reference to `SSL_ctrl'
openssl.c:(.text+0x4b3c): undefined reference to `SSL_ctrl'
openssl.c:(.text+0x4bb4): undefined reference to `SSL_set_ex_data'
openssl.c:(.text+0x4bcc): undefined reference to `SSL_set_ex_data'
openssl.c:(.text+0x4bfc): undefined reference to `SSL_set_session'
openssl.c:(.text+0x4c10): undefined reference to `ERR_get_error'
openssl.c:(.text+0x4c80): undefined reference to `SSL_set_fd'
openssl.c:(.text+0x4c8c): undefined reference to `ERR_get_error'

,还得加上ssl的库以及crypto库,关键是引用了后,还报各种未定义在这里插入图片描述
无奈了,只有交叉编译不带openssl的curl库,这样在相机上能跑起来,目前不知道为什么.
#跑通了,不用ssl直接编译curl。不连接ssl就能再arm上用.

./configure --host=arm-himix200-linux CC=arm-himix200-linux-gcc CXX=arm-himix200-linux-g++ --disable-shared --enable-static --disable-ftp --disable-ipv6 --disable-rtsp --disable-tftp --disable-telnet --disable-largefile --disable-smtp --disable-imap --without-ssl --without-libssh2 --without-zlib --without-librtmp --without-libidn --without-gnutls --disable-ldap --disable-ldaps --disable-pop3 --prefix=/home/xxx/opt/curl-nossl/build
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值