在x86_64架构下的Arch Linux上交叉编译smartdns时报错
# ./Configure --cross-compile-prefix=mipsel-openwrt-linux- linux-mips32 --prefix=/root/smartdns_mips/openssl --openssldir=/root/smartdns_mips/openssl no-shared no-asm
# make
# make install
成功静态编译openssl-1.1.1g
# export PKG_CONFIG_PATH=/root/smartdns_mips/openssl/lib/pkgconfig
# cd /root/smartdns_mips/smartdns/src
# vi Makefile
...
override CFLAGS +=-Iinclude -I/root/smartdns_mips/openssl/include
...
ifeq ($(STATIC), yes)
override LDFLAGS += -L/root/smartdns_mips/openssl/lib -lssl -lcrypto -Wl,--whole-archive -lpthread -Wl,--no-whole-archive -ldl -static
# cd /root/smartdns_mips/smartdns/package
最后静态编译smartdns
# ./build-pkg.sh --platform openwrt --arch mips_24kc --static
输出信息如下
...
gcc -O2 -g -Wall -Wstrict-prototypes -fno-omit-frame-pointer -Wstrict-aliasing -Iinclude -I/root/smartdns_mips/openssl/include -DBASE_FILE_NAME=\"radix.c\" -DSMARTDNS_VERION=\"1.2020.05.03-0020\" -c -o lib/radix.o lib/radix.c
gcc -O2 -g -Wall -Wstrict-prototypes -fno-omit-frame-pointer -Wstrict-aliasing -Iinclude -I/root/smartdns_mips/openssl/include -DBASE_FILE_NAME=\"conf.c\" -DSMARTDNS_VERION=\"1.2020.05.03-0020\" -c -o lib/conf.o lib/conf.c
gcc smartdns.o fast_ping.o dns_client.o dns_server.o dns.o util.o tlog.o dns_conf.o dns_cache.o http_parse.o lib/rbtree.o lib/art.o lib/bitops.o lib/radix.o lib/conf.o -o smartdns -L/root/smartdns_mips/openssl/lib -lssl -lcrypto -Wl,--whole-archive -lpthread -Wl,--no-whole-archive -ldl -static
/usr/bin/ld: skipping incompatible /root/smartdns_mips/openssl/lib/libssl.a when searching for -lssl
/usr/bin/ld: cannot find -lssl
/usr/bin/ld: skipping incompatible /root/smartdns_mips/openssl/lib/libcrypto.a when searching for -lcrypto
/usr/bin/ld: cannot find -lcrypto
/usr/bin/ld: fast_ping.o: in function `_fast_ping_getdomain':
/root/smartdns_mips/smartdns/src/fast_ping.c:329: warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:46: smartdns] Error 1
make[1]: Leaving directory '/root/smartdns_mips/smartdns/src'
make: *** [Makefile:29: SMARTDNS_BIN] Error 2
make: Leaving directory '/root/smartdns_mips/smartdns'
make smartdns failed