debian RT-AC68U 交叉编译链 编译 ChinaDNS 失败

2015-02-28 22:43:22 +08:00
 xzm1006
我git clone完后使用./autogen.sh && CC=arm-uclibc-linux-2.6.36-gcc CXX=arm-uclibc-linux-2.6.36-g++ AR=arm-uclibc-linux-2.6.36-ar RANLIB=arm-uclibc-linux-2.6.36-ranlib ./configure --host=arm-uclibc-linux --enable-static && make进行编译

结果报错如下:

arm-uclibc-linux-2.6.36-gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT chinadns.o -MD -MP -MF .deps/chinadns.Tpo -c -o chinadns.o chinadns.c
mv -f .deps/chinadns.Tpo .deps/chinadns.Po
arm-uclibc-linux-2.6.36-gcc -g -O2 -static -o chinadns chinadns.o -lresolv
chinadns.o: In function `hostname_from_question':
/root/ChinaDNS/src/chinadns.c:727: undefined reference to `__ns_parserr'
chinadns.o: In function `should_filter_query':
/root/ChinaDNS/src/chinadns.c:767: undefined reference to `__ns_parserr'
chinadns.o: In function `dns_handle_remote':
/root/ChinaDNS/src/chinadns.c:655: undefined reference to `__ns_initparse'
chinadns.o: In function `dns_handle_local':
/root/ChinaDNS/src/chinadns.c:567: undefined reference to `__ns_initparse'

请问应该如何解决?本来想@ /t/124550 76L的szpunk,但是他似乎很久没上了
6187 次点击
所在节点    问与答
30 条回复
XiaoxiaoPu
2015-02-28 23:09:24 +08:00
正确的交叉编译配置应该是 ./configure --host=arm-uclibc-linux-2.6.36 --enable-static,
不要再指定 CC=... 之类的。错误原因似乎是没有找到 libresolv,你应该把 configure 的 log 贴出来。

给个临时解决方案(不一定可行):
cd src
arm-uclibc-linux-2.6.36-gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT chinadns.o -MD -MP -MF .deps/chinadns.Tpo -c -o chinadns.o chinadns.c -lresolv
xzm1006
2015-02-28 23:42:48 +08:00
@XiaoxiaoPu 谢谢你给出临时解决方案,我运行后不报错了,但是我不知道下一步应该做什么,请原谅我编译小白
因为我按照教程用该交叉编译配置成功编译了ss,并且放入路由器可运行,你的交叉编译配置之前已试过,成功生成了文件,但出现报错如下:
chinadns.o: In function `resolve_dns_servers':
/root/ChinaDNS/src/chinadns.c:326: warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking

放入路由器运行出现报错如下:
RT-AC68U-D9F8:/jffs# ./chinadns -m -c chnroute.txt
./chinadns: line 6: syntax error: unexpected word (expecting ")")
RT-AC68U-D9F8:/jffs# ./chinadns: line 1:ELF : not found
LazyZhu
2015-03-01 00:50:01 +08:00
XiaoxiaoPu
2015-03-01 01:18:48 +08:00
有问题的原因主要就是 chinadns 用到了 libresolv,可能你的交叉工具链里没有 libresolv 的静态版本,你试试把 --enable-static 去掉。或者试试这个内嵌了 libresolv 的版本: https://github.com/XiaoxiaoPu/ChinaDNS
yushiro
2015-03-01 14:29:12 +08:00
lz,你是按照哪篇教程交叉编译SS的?我也是Ac68U,正需要~
xzm1006
2015-03-01 17:06:26 +08:00
@LazyZhu 感谢~试了能运行~话说18KB这么小……我以为路由器只能静态编译运行
xzm1006
2015-03-01 17:09:26 +08:00
@XiaoxiaoPu 试了编译你修改的版本,编译出来了!的确是缺少了libresolv,万分感谢!
xzm1006
2015-03-01 17:11:05 +08:00
@yushiro 教程可以参考/t/165064
xzm1006
2015-03-02 11:09:12 +08:00
@LazyZhu 能请教你是用什么交叉工具链编译的吗?发现我之前编译的ss-tunnel,放在路由器运行出现Segmentation fault错误……抓狂了
kdrx
2015-04-12 02:43:54 +08:00
kdrx
2015-04-12 02:45:30 +08:00
@XiaoxiaoPu
请问,你的内嵌libresolv的版本的chinadns能再次分享吗?
@LazyZhu
请问您是如果动态编译这个18k的chinadns的呢?能分享下吗?
XiaoxiaoPu
2015-04-13 10:17:07 +08:00
@kdrx 动态链接能运行就没必要静态链接了
kdrx
2015-04-13 13:23:57 +08:00
@XiaoxiaoPu
我不是需要静态链接啊,静态连接后能运行的,但是体积太大。
我是需要你这种内嵌libresolv的版本的动态链接编译。
我官方源码用 arm-linux-gcc 交叉编译动态链接后,目标机器ac68u提示缺少libresolv.so
而lazyzhu的动态链接版本能在asus 68u 正确运行,而我用ldd观察,发现他根本就没有链接libresolv.so库,可能也是源码中嵌入了libresolv中的相应函数。
XiaoxiaoPu
2015-04-13 14:03:50 +08:00
@kdrx 代码不在工作的电脑里,晚上给你
kdrx
2015-04-13 23:38:34 +08:00
@XiaoxiaoPu 好的,谢谢你!发我邮箱吧: yiziol@qq.com
qq674949301
2015-09-05 13:06:05 +08:00
@kdrx @LazyZhu @XiaoxiaoPu 您好!我交叉编译也遇到一些错误!是编译 tomato mips 平台的
参考: https://github.com/shadowsocks/ChinaDNS

交叉编译 ChinaDNS 出现以下错误:

make[1]: 正在进入目录 `/home/houzi/ChinaDNS'
Making all in src
make[2]: 正在进入目录 `/home/houzi/ChinaDNS/src'
mipsel-linux-gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT local_ns_parser.o -MD -MP -MF .deps/local_ns_parser.Tpo -c -o local_ns_parser.o local_ns_parser.c
local_ns_parser.c: In function `local_ns_parserr':
local_ns_parser.c:92: structure has no member named `_msg_ptr'
local_ns_parser.c:97: structure has no member named `_msg_ptr'
local_ns_parser.c:103: structure has no member named `_msg_ptr'
local_ns_parser.c:106: structure has no member named `_msg_ptr'
local_ns_parser.c:107: structure has no member named `_msg_ptr'
local_ns_parser.c:111: structure has no member named `_msg_ptr'
local_ns_parser.c:111: structure has no member named `_msg_ptr'
local_ns_parser.c:112: structure has no member named `_msg_ptr'
local_ns_parser.c:112: structure has no member named `_msg_ptr'
local_ns_parser.c:118: structure has no member named `_msg_ptr'
local_ns_parser.c:122: structure has no member named `_msg_ptr'
local_ns_parser.c:122: structure has no member named `_msg_ptr'
local_ns_parser.c:123: structure has no member named `_msg_ptr'
local_ns_parser.c:123: structure has no member named `_msg_ptr'
local_ns_parser.c:124: structure has no member named `_msg_ptr'
local_ns_parser.c:128: structure has no member named `_msg_ptr'
local_ns_parser.c:129: structure has no member named `_msg_ptr'
local_ns_parser.c: In function `local_ns_setsection':
local_ns_parser.c:141: structure has no member named `_msg_ptr'
local_ns_parser.c:144: structure has no member named `_msg_ptr'
make[2]: *** [local_ns_parser.o] 错误 1
make[2]:正在离开目录 `/home/houzi/ChinaDNS/src'
make[1]: *** [all-recursive] 错误 1
make[1]:正在离开目录 `/home/houzi/ChinaDNS'
make: *** [all] 错误 2
LazyZhu
2015-09-05 13:10:33 +08:00
qq674949301
2015-09-05 13:13:58 +08:00
@LazyZhu 好的! brcm 53xx 的不是 ARM 平台的?
qq674949301
2015-09-05 13:15:59 +08:00
@LazyZhu 我的是 BRCM 4706,应该属于 BCM 47XX 的吧?
qq674949301
2015-09-05 13:28:56 +08:00
@还有 OpenWrt SDK 编译的放在 tomato 能运行吗?

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/173629

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX