在 ubuntu 中为 MIPS 编译 netcat 时出现问题

问题描述 投票:0回答:1

我是新来的,我对此有点困惑:

我正在尝试编译 MIPS 的 netcat 源代码,以便将其部署在我的路由器中,我所做的是:

下载mips的工具链:mips-linux-gcc

下载netcat源码并将其展开到文件夹中

cd path/to/netcatsource

Execute:
CC=path/to/compiler/mips-linux-gcc ./configure --host=mips-linux

make

make 命令工作正常,并在编译后的 netcat 文件上尝试 file 命令显示:

file netcat
OUTPUT: ELF 32-bit MSB executable, MIPS, MIPS-I version 1 (SYSV), dynamically linked (uses shared libs), not stripped

对我来说一切似乎都很好,但是如果我在我的 ubuntu 机器上执行 ./netcat 它就可以工作,一旦我将其上传到路由器,它就会显示以下错误:

# ./netcat
Segmentation fault

这是我的路由器的 /proc/cpuinfo:

# cat /proc/cpuinfo
system type             : 963281T_TEF
processor               : 0
cpu model               : Broadcom4350 V7.5
BogoMIPS                : 319.48
wait instruction        : yes
microsecond timers      : yes
tlb_entries             : 32
extra interrupt vector  : no
hardware watchpoint     : no
ASEs implemented        :
shadow register sets    : 1
core                    : 0
VCED exceptions         : not available
VCEI exceptions         : not available

unaligned exceptions            : 1395

有人可以帮我吗? 问候

c mips
1个回答
1
投票

(我无法添加评论,因为我没有足够的积分)

尝试静态编译源代码
发生问题可能是因为您在路由器上没有必要的库,也许二进制文件指向ld-linux.so并且路由器使用ld-uclibc.so
所以尝试静态构建...

更新
我推荐 buildroot 工具链,其中包括 netcat 和许多其他工具,例如 busybox

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.