shadowsocks / ChinaDNS

Protect yourself against DNS poisoning in China.
GNU General Public License v3.0
3.6k stars 1.29k forks source link

在 entware 编译环境下编译失败 #17

Closed consatan closed 10 years ago

consatan commented 10 years ago

我的路由器ASUS RT-N16刷的是AsusWRT Merlin固件,里面配套使用的是Entware,安装percompile里的 ChinaDNS-C_1.1.2_brcm47xx.ipk提示

---------------------- 错误日志 ---------------------- chopin@vpn:~/Entware/openwrt_trunk$ make V=s package/ChinaDNS-C/openwrt/compile make[1]: Entering directory /home/chopin/Entware/openwrt_trunk' make[2]: Entering directory/home/chopin/Entware/openwrt_trunk/package/libs/toolchain' WARNING: skipping libgfortran -- package not selected make[2]: Leaving directory /home/chopin/Entware/openwrt_trunk/package/libs/toolchain' make[2]: Entering directory/home/chopin/Entware/openwrt_trunk/package/ChinaDNS-C/openwrt' . /home/chopin/Entware/openwrt_trunk/include/shell.sh; gzip -dc /home/chopin/Entware/openwrt_trunk/dl/chinadns-c-1.1.2.tar.gz | /bin/tar -C /home/chopin/Entware/openwrt_trunk/build_dir/target-mipsel-linux-gnu/ChinaDNS-C-/chinadns-c-1.1.2/.. -xf - touch /home/chopin/Entware/openwrt_trunk/build_dir/target-mipsel-linux-gnu/ChinaDNS-C-/chinadns-c-1.1.2/.prepared_c9e4a321eca4140e5c6e97fd2357df6b (cd /home/chopin/Entware/openwrt_trunk/build_dir/target-mipsel-linux-gnu/ChinaDNS-C-/chinadns-c-1.1.2; rm -f aclocal.m4; if [ -f ./configure.ac ] || [ -f ./configure.in ]; then [ -d ./autom4te.cache ] && rm -rf autom4te.cache; [ -e ./config.rpath ] || ln -s /home/chopin/Entware/openwrt_trunk/scripts/config.rpath ./config.rpath; touch NEWS AUTHORS COPYING ABOUT-NLS ChangeLog; AUTOM4TE=/home/chopin/Entware/openwrt_trunk/staging_dir/host/bin/autom4te AUTOCONF=/home/chopin/Entware/openwrt_trunk/staging_dir/host/bin/autoconf AUTOMAKE=/home/chopin/Entware/openwrt_trunk/staging_dir/host/bin/automake ACLOCAL=/home/chopin/Entware/openwrt_trunk/staging_dir/host/bin/aclocal AUTOHEADER=/home/chopin/Entware/openwrt_trunk/staging_dir/host/bin/autoheader LIBTOOLIZE=/home/chopin/Entware/openwrt_trunk/staging_dir/host/bin/libtoolize LIBTOOL=/home/chopin/Entware/openwrt_trunk/staging_dir/host/bin/libtool M4=/home/chopin/Entware/openwrt_trunk/staging_dir/host/bin/m4 AUTOPOINT=true /home/chopin/Entware/openwrt_trunk/staging_dir/host/bin/autoreconf -v -f -i -s -B /home/chopin/Entware/openwrt_trunk/staging_dir/host/share/aclocal -I /home/chopin/Entware/openwrt_trunk/staging_dir/target-mipsel-linux-gnu/host/share/aclocal -I /home/chopin/Entware/openwrt_trunk/staging_dir/target-mipsel-linux-gnu/opt/share/aclocal -I m4 -I . . || true; fi; ); autoreconf: Entering directory .' autoreconf: configure.ac: not using Gettext autoreconf: running: /home/chopin/Entware/openwrt_trunk/staging_dir/host/bin/aclocal -I /home/chopin/Entware/openwrt_trunk/staging_dir/target-mipsel-linux-gnu/host/share/aclocal -I /home/chopin/Entware/openwrt_trunk/staging_dir/target-mipsel-linux-gnu/opt/share/aclocal -I m4 -I . --force autoreconf: configure.ac: tracing autoreconf: configure.ac: not using Libtool autoreconf: running: /home/chopin/Entware/openwrt_trunk/staging_dir/host/bin/autoconf --include=/home/chopin/Entware/openwrt_trunk/staging_dir/target-mipsel-linux-gnu/host/share/aclocal --include=/home/chopin/Entware/openwrt_trunk/staging_dir/target-mipsel-linux-gnu/opt/share/aclocal --include=m4 --include=. --prepend-include=/home/chopin/Entware/openwrt_trunk/staging_dir/host/share/aclocal --force autoreconf: running: /home/chopin/Entware/openwrt_trunk/staging_dir/host/bin/autoheader --include=/home/chopin/Entware/openwrt_trunk/staging_dir/target-mipsel-linux-gnu/host/share/aclocal --include=/home/chopin/Entware/openwrt_trunk/staging_dir/target-mipsel-linux-gnu/opt/share/aclocal --include=m4 --include=. --prepend-include=/home/chopin/Entware/openwrt_trunk/staging_dir/host/share/aclocal --force autoreconf: running: /home/chopin/Entware/openwrt_trunk/staging_dir/host/bin/automake --add-missing --force-missing autoreconf: Leaving directory.' (cd /home/chopin/Entware/openwrt_trunk/build_dir/target-mipsel-linux-gnu/ChinaDNS-C-/chinadns-c-1.1.2/./; if [ -x ./configure ]; then /usr/bin/find /home/chopin/Entware/openwrt_trunk/build_dir/target-mipsel-linux-gnu/ChinaDNS-C-/chinadns-c-1.1.2/ -name config.guess | xargs -r chmod u+w; /usr/bin/find /home/chopin/Entware/openwrt_trunk/build_dir/target-mipsel-linux-gnu/ChinaDNS-C-/chinadns-c-1.1.2/ -name config.guess | xargs -r -n1 cp /home/chopin/Entware/openwrt_trunk/scripts/config.guess; /usr/bin/find /home/chopin/Entware/openwrt_trunk/build_dir/target-mipsel-linux-gnu/ChinaDNS-C-/chinadns-c-1.1.2/ -name config.sub | xargs -r chmod u+w; /usr/bin/find /home/chopin/Entware/openwrt_trunk/build_dir/target-mipsel-linux-gnu/ChinaDNS-C-/chinadns-c-1.1.2/ -name config.sub | xargs -r -n1 cp /home/chopin/Entware/openwrt_trunk/scripts/config.sub; AR=mipsel-linux-uclibc-ar AS="mipsel-linux-uclibc-gcc -c -O2 -pipe -mips32 -mtune=mips32 -fno-caller-saves" LD=mipsel-linux-uclibc-ld NM=mipsel-linux-uclibc-nm CC="mipsel-linux-uclibc-gcc" GCC="mipsel-linux-uclibc-gcc" CXX="mipsel-linux-uclibc-g++" RANLIB=mipsel-linux-uclibc-ranlib STRIP=mipsel-linux-uclibc-strip OBJCOPY=mipsel-linux-uclibc-objcopy OBJDUMP=mipsel-linux-uclibc-objdump SIZE=mipsel-linux-uclibc-size CFLAGS="-O2 -pipe -mips32 -mtune=mips32 -fno-caller-saves " CXXFLAGS="-O2 -pipe -mips32 -mtune=mips32 -fno-caller-saves " CPPFLAGS="-I/home/chopin/Entware/openwrt_trunk/staging_dir/target-mipsel-linux-gnu/opt/include -I/home/chopin/Entware/openwrt_trunk/staging_dir/target-mipsel-linux-gnu/include -I/opt/entware/toolchain-entware/include " LDFLAGS="-L/home/chopin/Entware/openwrt_trunk/staging_dir/target-mipsel-linux-gnu/opt/lib -L/home/chopin/Entware/openwrt_trunk/staging_dir/target-mipsel-linux-gnu/lib -Wl,--dynamic-linker=/opt/lib/ld-uClibc.so.0 -Wl,-rpath,/opt/lib -Wl,-rpath-link=/home/chopin/Entware/openwrt_trunk/staging_dir/target-mipsel-linux-gnu/opt/lib -L/opt/entware/toolchain-entware/lib " ./configure --target=mipsel-linux-gnu --host=mipsel-linux-gnu --build=x86_64-linux-gnu --program-prefix="" --program-suffix="" --prefix=/opt --exec-prefix=/opt --bindir=/opt/bin --sbindir=/opt/sbin --libexecdir=/opt/lib --sysconfdir=/opt/etc --datadir=/opt/share --localstatedir=/opt/var --mandir=/opt/man --infodir=/opt/info --disable-nls ; fi; ) configure: WARNING: unrecognized options: --disable-nls configure: loading site script /home/chopin/Entware/openwrt_trunk/include/site/mipsel-linux-gnu checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for mipsel-linux-gnu-strip... mipsel-linux-uclibc-strip checking for a thread-safe mkdir -p... /bin/mkdir -p checking for gawk... gawk checking whether make sets $(MAKE)... yes checking for mipsel-linux-gnu-gcc... mipsel-linux-uclibc-gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... yes checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether mipsel-linux-uclibc-gcc accepts -g... yes checking for mipsel-linux-uclibc-gcc option to accept ISO C89... none needed checking for style of include used by make... GNU checking dependency style of mipsel-linux-uclibc-gcc... gcc3 checking for res_query in -lresolv... no checking for res_query in -lresolv... yes checking for sys/types.h... yes checking for netinet/in.h... yes checking for arpa/nameser.h... yes checking for netdb.h... yes checking for resolv.h... yes checking how to run the C preprocessor... mipsel-linux-uclibc-gcc -E checking for grep that handles long lines and -e... /home/chopin/Entware/openwrt_trunk/staging_dir/host/bin/grep checking for egrep... /home/chopin/Entware/openwrt_trunk/staging_dir/host/bin/grep -E checking for ANSI C header files... yes checking for sys/types.h... (cached) yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking arpa/inet.h usability... yes checking arpa/inet.h presence... yes checking for arpa/inet.h... yes checking fcntl.h usability... yes checking fcntl.h presence... yes checking for fcntl.h... yes checking for netdb.h... (cached) yes checking for stdlib.h... (cached) yes checking for string.h... (cached) yes checking sys/socket.h usability... yes checking sys/socket.h presence... yes checking for sys/socket.h... yes checking for unistd.h... (cached) yes checking for size_t... yes checking for ssize_t... yes checking for uint16_t... yes checking for stdlib.h... (cached) yes checking for GNU libc compatible malloc... (cached) yes checking for stdlib.h... (cached) yes checking for GNU libc compatible realloc... (cached) yes checking for inet_ntoa... yes checking for memset... yes checking for select... yes checking for socket... yes checking for strchr... yes checking for strdup... yes checking for strrchr... yes configure: creating ./config.status config.status: creating Makefile config.status: creating src/Makefile config.status: creating config.h config.status: executing depfiles commands configure: WARNING: unrecognized options: --disable-nls rm -f /home/chopin/Entware/openwrt_trunk/builddir/target-mipsel-linux-gnu/ChinaDNS-C-/chinadns-c-1.1.2/.configured* touch /home/chopin/Entware/openwrt_trunk/builddir/target-mipsel-linux-gnu/ChinaDNS-C-/chinadns-c-1.1.2/.configured CFLAGS="-O2 -pipe -mips32 -mtune=mips32 -fno-caller-saves -I/home/chopin/Entware/openwrt_trunk/staging_dir/target-mipsel-linux-gnu/opt/include -I/home/chopin/Entware/openwrt_trunk/staging_dir/target-mipsel-linux-gnu/include -I/opt/entware/toolchain-entware/include " CXXFLAGS="-O2 -pipe -mips32 -mtune=mips32 -fno-caller-saves -I/home/chopin/Entware/openwrt_trunk/staging_dir/target-mipsel-linux-gnu/opt/include -I/home/chopin/Entware/openwrt_trunk/staging_dir/target-mipsel-linux-gnu/include -I/opt/entware/toolchain-entware/include " LDFLAGS="-L/home/chopin/Entware/openwrt_trunk/staging_dir/target-mipsel-linux-gnu/opt/lib -L/home/chopin/Entware/openwrt_trunk/staging_dir/target-mipsel-linux-gnu/lib -Wl,--dynamic-linker=/opt/lib/ld-uClibc.so.0 -Wl,-rpath,/opt/lib -Wl,-rpath-link=/home/chopin/Entware/openwrt_trunk/staging_dir/target-mipsel-linux-gnu/opt/lib -L/opt/entware/toolchain-entware/lib " make -C /home/chopin/Entware/openwrt_trunk/build_dir/target-mipsel-linux-gnu/ChinaDNS-C-/chinadns-c-1.1.2/. AR=mipsel-linux-uclibc-ar AS="mipsel-linux-uclibc-gcc -c -O2 -pipe -mips32 -mtune=mips32 -fno-caller-saves" LD=mipsel-linux-uclibc-ld NM=mipsel-linux-uclibc-nm CC="mipsel-linux-uclibc-gcc" GCC="mipsel-linux-uclibc-gcc" CXX="mipsel-linux-uclibc-g++" RANLIB=mipsel-linux-uclibc-ranlib STRIP=mipsel-linux-uclibc-strip OBJCOPY=mipsel-linux-uclibc-objcopy OBJDUMP=mipsel-linux-uclibc-objdump SIZE=mipsel-linux-uclibc-size CROSS="mipsel-linux-uclibc-" ARCH="mipsel" ; make[3]: Entering directory /home/chopin/Entware/openwrt_trunk/build_dir/target-mipsel-linux-gnu/ChinaDNS-C-/chinadns-c-1.1.2' make all-recursive make[4]: Entering directory/home/chopin/Entware/openwrt_trunk/build_dir/target-mipsel-linux-gnu/ChinaDNS-C-/chinadns-c-1.1.2' Making all in src make[5]: Entering directory /home/chopin/Entware/openwrt_trunk/build_dir/target-mipsel-linux-gnu/ChinaDNS-C-/chinadns-c-1.1.2/src' mipsel-linux-uclibc-gcc -DHAVE_CONFIG_H -I. -I.. -I/home/chopin/Entware/openwrt_trunk/staging_dir/target-mipsel-linux-gnu/opt/include -I/home/chopin/Entware/openwrt_trunk/staging_dir/target-mipsel-linux-gnu/include -I/opt/entware/toolchain-entware/include -O2 -pipe -mips32 -mtune=mips32 -fno-caller-saves -MT chinadns.o -MD -MP -MF .deps/chinadns.Tpo -c -o chinadns.o chinadns.c mv -f .deps/chinadns.Tpo .deps/chinadns.Po mipsel-linux-uclibc-gcc -O2 -pipe -mips32 -mtune=mips32 -fno-caller-saves -L/home/chopin/Entware/openwrt_trunk/staging_dir/target-mipsel-linux-gnu/opt/lib -L/home/chopin/Entware/openwrt_trunk/staging_dir/target-mipsel-linux-gnu/lib -Wl,--dynamic-linker=/opt/lib/ld-uClibc.so.0 -Wl,-rpath,/opt/lib -Wl,-rpath-link=/home/chopin/Entware/openwrt_trunk/staging_dir/target-mipsel-linux-gnu/opt/lib -L/opt/entware/toolchain-entware/lib -o chinadns chinadns.o -lresolv chinadns.o: In functionhostname_from_question': chinadns.c:(.text+0xc4): undefined reference to __ns_parserr' chinadns.o: In functionshould_filter_query': chinadns.c:(.text+0x45c): undefined reference to `ns_parserr' chinadns.o: In functionmain': chinadns.c:(.text.startup+0xc14): undefined reference to__ns_initparse' chinadns.c:(.text.startup+0xe6c): undefined reference to__ns_initparse' collect2: ld returned 1 exit status make[5]: **\* [chinadns] Error 1 make[5]: Leaving directory/home/chopin/Entware/openwrt_trunk/build_dir/target-mipsel-linux-gnu/ChinaDNS-C-/chinadns-c-1.1.2/src' make[4]: * [all-recursive] Error 1 make[4]: Leaving directory/home/chopin/Entware/openwrt_trunk/build_dir/target-mipsel-linux-gnu/ChinaDNS-C-/chinadns-c-1.1.2' make[3]: **\* [all] Error 2 make[3]: Leaving directory/home/chopin/Entware/openwrt_trunk/build_dir/target-mipsel-linux-gnu/ChinaDNS-C-/chinadns-c-1.1.2' make[2]: [/home/chopin/Entware/openwrt_trunk/build_dir/target-mipsel-linux-gnu/ChinaDNS-C-/chinadns-c-1.1.2/.built] Error 2 make[2]: Leaving directory`/home/chopin/Entware/openwrt_trunk/package/ChinaDNS-C/openwrt' make[1]: \ [package/ChinaDNS-C/openwrt/compile] Error 2 make[1]: Leaving directory `/home/chopin/Entware/openwrt_trunk' make: * [package/ChinaDNS-C/openwrt/compile] Error 2

rampageX commented 10 years ago

二选一:

  1. 先编译 libbind ,然后用 -lbind 替代 -lresolv 来编译;
  2. 从 BIND 里面编译出 libresolv.so,然后再编译。详见: https://github.com/rampageX/ChinaDNS-C
consatan commented 10 years ago

但entware的编译环境里原本就有libresolv.so了啊... chopin@vpn:~/Entware/openwrt_trunk$ find ./ -name libresolv* ./build_dir/target-mipsel-linux-gnu/toolchain/ipkg-entware/libc/opt/lib/libresolv-0.9.32.so ./build_dir/target-mipsel-linux-gnu/toolchain/ipkg-entware/libc/opt/lib/libresolv.so.0 ./staging_dir/target-mipsel-linux-gnu/root-entware/opt/lib/libresolv-0.9.32.so ./staging_dir/target-mipsel-linux-gnu/root-entware/opt/lib/libresolv.so.0

而且configure阶段也提示找到libresolv了,是版本问题??(BTW,entware编译环境里也自带libbind) /* confdefs.h */

define PACKAGE_NAME "ChinaDNS-C"

define PACKAGE_TARNAME "chinadns-c"

define PACKAGE_VERSION "1.1.2"

define PACKAGE_STRING "ChinaDNS-C 1.1.2"

define PACKAGE_BUGREPORT "clowwindy42@gmail.com"

define PACKAGE_URL ""

define PACKAGE "chinadns-c"

define VERSION "1.1.2"

define HAVE_LIBRESOLV 1

define HAVE_SYS_TYPES_H 1

define HAVE_NETINET_IN_H 1

define HAVE_ARPA_NAMESER_H 1

define HAVE_NETDB_H 1

define HAVE_RESOLV_H 1

define STDC_HEADERS 1

define HAVE_SYS_TYPES_H 1

define HAVE_SYS_STAT_H 1

define HAVE_STDLIB_H 1

define HAVE_STRING_H 1

define HAVE_MEMORY_H 1

define HAVE_STRINGS_H 1

define HAVE_INTTYPES_H 1

define HAVE_STDINT_H 1

define HAVE_UNISTD_H 1

define HAVE_ARPA_INET_H 1

define HAVE_FCNTL_H 1

define HAVE_NETDB_H 1

define HAVE_STDLIB_H 1

define HAVE_STRING_H 1

define HAVE_SYS_SOCKET_H 1

define HAVE_UNISTD_H 1

define HAVE_STDLIB_H 1

define HAVE_MALLOC 1

define HAVE_STDLIB_H 1

define HAVE_REALLOC 1

define HAVE_INET_NTOA 1

define HAVE_MEMSET 1

define HAVE_SELECT 1

define HAVE_SOCKET 1

define HAVE_STRCHR 1

define HAVE_STRDUP 1

define HAVE_STRRCHR 1

configure: exit 0

clowwindy commented 10 years ago

你的 include/resolv.h 和 /lib/libresolv.so 不匹配。

xeonxu commented 10 years ago

我觉得是否可以参考dnsmasq的实现来重构chinadns,这样可以减少对库函数的依赖性。目前看下来,不同嵌入式平台的工具链所包含的库函数很不一致,像shibby tomato的SDK中工具链就缺少libresolv库,和dn_expand等函数;而老版本的tomato SDK确有相应的库函数。这对于可移植性有很大影响。 亦或者从libc中移植chinadns使用到的ns函数族的实现到china_dns中?目前我移植了一个简单的版本,在工程中添加一组文件,实现了__ns_initparse等函数,可以在缺少以上库函数的工具链中正常编译。而且这种编译方法生成的静态链接二进制文件比使用库文件版本体积要小6~9倍,大概是100k左右。如果编译为动态链接版本,目标体积只有19k。

clowwindy commented 10 years ago

更好的方法是直接把 bind 的源码目录作为一个可选的依赖参数。类似 nginx 处理它的依赖的方式。如果 configure 时使用了这个参数,就直接和 bind 进行静态链接。