【问题标题】:Error: Illegal Instruction. Mips cross-compiler错误:非法指令。 Mips 交叉编译器
【发布时间】:2019-01-21 12:30:31
【问题描述】:

我在 Linux x64 上使用 Mips 交叉编译器编译简单程序,然后使用 scp 将其上传到我的路由器上。当我运行这个程序时,我有错误:非法指令

我的程序:

#include <stdio.h>
int main(void)
{
  printf("Hello, world!");
  return 0;
}

/proc/cpuinfo 我的 mips-box:

system type         : Atheros AR9330 rev 1
machine             : TP-LINK TL-WR741ND v4
processor           : 0
cpu model           : MIPS 24Kc V7.4
isa                 : mips1 mips2 mips32r1 mips32r2
ASEs implemented    : mips16

编译:

mips-linux-gnu-gcc -static -march=24kc -o hello hello.c

上传:

scp hello root@192.168.1.1:/tmp

运行:

root@OpenWrt:/tmp# ./hello
Illegal instruction

【问题讨论】:

  • 高度怀疑标准 C 库(这里是 stdio.h)可以在这种情况下使用。
  • 我尝试在没有任何库的情况下编译这个程序。只有 int main(void){}。结果完全一样。@SusmitAgrawal
  • 尝试使用-ffreestanding 标志。
  • @SusmitAgrawal 不起作用

标签: c mips


【解决方案1】:

已解决。

我使用另一个工具链。链接:https://www.mips.com/develop/tools/codescape-mips-sdk/download-codescape-mips-sdk-essentials/.

对于MIPS Classic Legacy CPU IP Cores:4k、M4k、M14k、24k、34k、74k、1004k、1074k,使用相同的编译命令。

【讨论】:

    猜你喜欢
    • 2014-07-18
    • 2018-08-21
    • 2019-01-18
    • 1970-01-01
    • 1970-01-01
    • 2011-07-14
    • 2011-06-12
    • 2018-05-31
    • 2017-08-29
    相关资源
    最近更新 更多