0 现象
在 Arch 下编译 OpenWRT (15.05) cmcurl 时报错:
[ 28%] Linking C executable LIBCURL
lib/libcmcurl.a(openssl.c.o): In function `cert_stuff`:
openssl.c:(.text+0x97a): undefined reference to `sk_num`
openssl.c:(.text+0x99a): undefined reference to `sk_pop`
openssl.c:(.text+0xa21): undefined reference to `sk_num`
openssl.c:(.text+0xa62): undefined reference to `sk_pop_free`
lib/libcmcurl.a(openssl.c.o): In function `Curl_ossl_init`:
openssl.c:(.text+0xf74): undefined reference to `SSL_load_error_strings`
openssl.c:(.text+0xf79): undefined reference to `SSL_library_init`
openssl.c:(.text+0xf89): undefined reference to `OPENSSL_add_all_algorithms_noconf`
lib/libcmcurl.a(openssl.c.o): In function `Curl_ossl_cleanup`:
openssl.c:(.text+0xfad): undefined reference to `EVP_cleanup`
openssl.c:(.text+0xfb2): undefined reference to `ERR_free_strings`
lib/libcmcurl.a(openssl.c.o): In function `verifyhost`:
openssl.c:(.text+0x1a7a): undefined reference to `sk_num`
openssl.c:(.text+0x1a9a): undefined reference to `sk_value`
lib/libcmcurl.a(openssl.c.o): In function `ossl_connect_step1`:
openssl.c:(.text+0x29a5): undefined reference to `SSLv23_client_method`
lib/libcmcurl.a(openssl.c.o): In function `X509V3_ext`:
openssl.c:(.text+0x3a77): undefined reference to `sk_num`
openssl.c:(.text+0x3aab): undefined reference to `sk_value`
openssl.c:(.text+0x3d5c): undefined reference to `sk_num`
lib/libcmcurl.a(openssl.c.o): In function `get_cert_chain`:
openssl.c:(.text+0x3fe2): undefined reference to `sk_num`
openssl.c:(.text+0x4061): undefined reference to `sk_value`
lib/libcmcurl.a(openssl.c.o): In function `Curl_ossl_version`:
openssl.c:(.text+0x61c3): undefined reference to `SSLeay`
collect2: error: ld returned 1 exit status
看得出来应该是相关库未链接成功。
1 解决方案
查阅了相关文档,发现这些方法是在老的 OpenSSL 中存在的,首先先安装老版本:
$ sudo pacman -S openssl-1.0
使用软链接的方式,更改默认库的指向使用老版本即可(若已有软链接,需要先删除),如:
# rm libcrypto.so
# rm libssl.so
# ln -s libcrypto.so.1.0.0 libcrypto.so
# ln -s libssl.so.1.0.0 libssl.so