bot*_*zko 5 gcc cross-compilation mips
我买了一个中国的P2P摄像头,没有MJPEG流,所以想编译mjpg-streamer
一下。这是我的 CPU 信息:
# cat /proc/cpuinfo
system type : Ralink SoC
processor : 0
cpu model : MIPS 24K V4.12
BogoMIPS : 239.61
wait instruction : yes
microsecond timers : yes
tlb_entries : 32
extra interrupt vector : yes
hardware watchpoint : yes
ASEs implemented : mips16 dsp
VCED exceptions : not available
VCEI exceptions : not available
# uname -a
Linux (none) 2.6.21 #878 Tue Oct 29 09:53:25 CST 2013 mips unknown
Run Code Online (Sandbox Code Playgroud)
我尝试将Sourcery CodeBench 用于 MIPS GNU/Linux(最新版本)并尝试使用以下命令编译一个简单的“Hello world”示例:
$ mips-linux-gnu-gcc -Wall hello.c -o hello
Run Code Online (Sandbox Code Playgroud)
执行后,我收到以下消息:
# ./hello
./hello: line 1: ELF@04: not found
./hello: line 2: syntax error: "(" unexpected
Run Code Online (Sandbox Code Playgroud)
接下来我尝试使用以下命令重新编译:
$ mips-linux-gnu-gcc -mips16 -Wall hello.c -o hello
Run Code Online (Sandbox Code Playgroud)
但结果是:
# ./hello
./hello: line 1: syntax error: "(" unexpected
Run Code Online (Sandbox Code Playgroud)
编辑:
$readelf -h HKIPC #Extracted file from the device
ELF Header:
Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: EXEC (Executable file)
Machine: MIPS R3000
Version: 0x1
Entry point address: 0x406420
Start of program headers: 52 (bytes into file)
Start of section headers: 643764 (bytes into file)
Flags: 0x10001007, noreorder, pic, cpic, o32, mips2
Size of this header: 52 (bytes)
Size of program headers: 32 (bytes)
Number of program headers: 6
Size of section headers: 40 (bytes)
Number of section headers: 25
Section header string table index: 24
$file HKIPC
HKIPC: ELF 32-bit LSB executable, MIPS, MIPS-II version 1 (SYSV), dynamically linked (uses shared libs), stripped
Run Code Online (Sandbox Code Playgroud)
——
$readelf -h hello #Compiled with mips-linux-gnu-gcc -mips2 -EL -mabi=32 hello.c -o hello
ELF Header:
Magic: 7f 45 4c 46 01 01 01 00 01 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 1
Type: EXEC (Executable file)
Machine: MIPS R3000
Version: 0x1
Entry point address: 0x400430
Start of program headers: 52 (bytes into file)
Start of section headers: 2732 (bytes into file)
Flags: 0x70001005, noreorder, cpic, o32, mips32r2
Size of this header: 52 (bytes)
Size of program headers: 32 (bytes)
Number of program headers: 8
Size of section headers: 40 (bytes)
Number of section headers: 34
Section header string table index: 31
$file hello
hello: ELF 32-bit LSB executable, MIPS, MIPS32 rel2 version 1, dynamically linked (uses shared libs), with unknown capability 0xf41 = 0x756e6700, with unknown capability 0x70100 = 0x1040000, not stripped
Run Code Online (Sandbox Code Playgroud)
相机的 libc 与工具链使用的 libc 不匹配。在这种情况下,必须静态编译程序并添加-static
开关。之后“Hello world”就可以在设备上执行了。另一个解决方案是添加所有必需的共享库(我尚未对此进行测试)。
#mipslinux irc 频道的人们帮助我解决了这个问题 - 谢谢。
归档时间: |
|
查看次数: |
4447 次 |
最近记录: |