我正在尝试编译这个 C 代码项目:https://github.com/msantos/sods 使用 Ubuntu、Debian、Kali Linux 和其他操作系统似乎成功了,但是在 Termux 上的 Android 中,它没有成功,因为当我执行 make 命令时,我收到一个错误,提示找不到
libresolv.a
,我已经意识到 libresolv.conf 没有找到。 a 仅存在于某些 Linux 扩展(如 Debian)中,但对于 android 来说情况不一样,配置文件甚至没有针对 android 的特定配置,现在我很困惑,因为我没有找到这个 libresolv 的替代方案android 中的.a,有什么解决方案吗?
我尝试从 ChatGPT 获得帮助,但它并没有像我预期的那样帮助我。
编辑 更清楚的是我在 Termux 中所做的:
pkg install git
git clone https://github.com/msantos/sods.git
然后我去了 sods 客户端文件夹“sdt”
cd sods/sdt
然后我已经执行了配置文件
./configure
它生成操作系统“Linux”所需的Makefile,但是是普通linux,而不是android的linux。 然后当我执行时
make
编译返回错误,libresolv.a不存在 这是配置文件:
#!/bin/sh
OS=`uname -s`
case $OS in
'Linux')
if [ -e /usr/lib/libresolv.a ]; then
STATIC_LIB=/usr/lib/libresolv.a
else
STATIC_LIB=/usr/lib/*/libresolv.a
fi
DEF="-DHAVE_ERRX"
;;
'Darwin'|'NetBSD')
DEF="-DHAVE_ARC4RANDOM -DHAVE_ERRX"
LIB="-lresolv"
;;
'OpenBSD')
if [ ! -e /usr/local/lib/libbind/libbind.a ]; then
echo "Please install libbind: sudo pkg_add libbind"
exit 1
fi
DEF="-DHAVE_ARC4RANDOM -DHAVE_ERRX"
LIB="-L/usr/local/lib/libbind -Wl,-rpath=/usr/local/lib/libbind -lbind -I/usr/local/include/bind"
;;
'FreeBSD')
if [ ! -e /usr/local/lib/libbind.a ]; then
echo "Please install libbind: sudo pkg add libbind"
exit 1
fi
DEF="-DHAVE_ARC4RANDOM -DHAVE_ERRX"
LIB="-L/usr/local/lib -lbind -I/usr/local/include/bind"
;;
'SunOS')
if [ ! -e /opt/local/lib/libbind.a ]; then
echo "Please install libbind: sudo pkg_add libbind"
exit 1
fi
DEF="-DHAVE_ERRX"
LIB="-lsocket -lnsl -L/opt/local/lib -Wl,-rpath=/opt/local/lib -lbind -I/opt/local/include/bind"
;;
*)
echo "Guessing, adjust Makefile by hand ..."
LIB="-lresolv"
;;
esac
if [ -e /dev/urandom ]; then
DEF="${DEF} -DHAVE_URANDOM"
fi
cat<<EOF>Makefile
CC ?= cc
RM ?= rm
APP=sdt
STATIC_LIB=${STATIC_LIB}
DEF=${DEF}
LIB=${LIB}
all:
\$(CC) \$(DEF) -g -Wall \$(LIB) \\
-Wall -Wextra -pedantic \\
-Wshadow -Wpointer-arith -Wcast-qual \\
-Wstrict-prototypes -Wmissing-prototypes \\
-I../common \\
-o \$(APP) \$(APP).c \$(APP)_dns.c \$(APP)_err.c \$(APP)_rand.c base32.c ../common/strtonum.c \$(STATIC_LIB) \\
-Wl,-z,relro,-z,now -Wl,-z,noexecstack
clean:
-@\$(RM) *.o \$(APP)
EOF
这是 Makefile:
CC ?= cc
RM ?= rm
APP=sdt
STATIC_LIB=/usr/lib/*/libresolv.a
DEF=-DHAVE_ERRX -DHAVE_URANDOM
LIB=
all:
$(CC) $(DEF) -g -Wall $(LIB) \
-Wall -Wextra -pedantic \
-Wshadow -Wpointer-arith -Wcast-qual \
-Wstrict-prototypes -Wmissing-prototypes \
-I../common \
-o $(APP) $(APP).c $(APP)_dns.c $(APP)_err.c $(APP)_rand.c base32.c ../common/strtonum.c $(STATIC_LIB) \
-Wl,-z,relro,-z,now -Wl,-z,noexecstack
clean:
-@$(RM) *.o $(APP)
and here is the make command output error :
cc -DHAVE_ERRX -DHAVE_URANDOM -g -Wall \
-Wall -Wextra -pedantic \
-Wshadow -Wpointer-arith -Wcast-qual \
-Wstrict-prototypes -Wmissing-prototypes \
-I../common \
-o sdt sdt.c sdt_dns.c sdt_err.c sdt_rand.c base32.c ../common/strtonum.c /usr/lib/libresolv.a \
-Wl,-z,relro,-z,now -Wl,-z,noexecstack
clang: error: no such file or directory: '/usr/lib/*/libresolv.a'
make: *** [Makefile:10: all] Error 1
问题已解决,我已为项目本身的所有者发布了该问题,并且已解决该问题:https://github.com/msantos/sods/issues/6#issuecomment-2412005202