|
工作环境: linux, 我的是ubuntu8.04,ubuntu的iso可以刻盘后光盘启动,也能用vmware安装,现在支持wubi方式安装,把ubuntu安装位xp下面的一个应用,整个linux分区就是windows下面的一个文件。
编译工具:http://www.dd-wrt.com/dd-wrtv2/d ... .debian.sp1.tar.bz2
解压,加入到PATH:(建议修改到~/.bashrc)
export PATH=$PATH:/home/steeven/work/dd-wrt/home/dd-wrt/whiterussian/openwrt/staging_dir_mipsel/bin
写一个test.c测试程序:
#include <stdio.h>
int main(){
printf("hello~\n");
return 0;
}
编译:
mipsel-linux-gcc test.c -o test
这时候ls应该看到test程序了。
./test执行,报错了吧?无法工具执行二进制文件!这就对了。因为mipsel-linux-gcc是交叉编译,编译出来的是给mips芯片用的。
file test, 看到MIPS字样了?好,copy到dd-wrt的/tmp目录下面,记得chmod +x test, 在telnet下面执行就能看到"hello~"出来鸟
要在x86平台上验证有个办法,安装qemu:
sudo apt-get install qemu
这玩意可以模拟mipsel芯片,但是要加对应的库目录(-L):
qemu-mipsel -L /home/steeven/work/dd-wrt/home/dd-wrt/whiterussian/openwrt/staging_dir_mipsel/ test
上面的-L目录是交叉编译工具所在目录。一样能运行吧~
在optware下面还可以安装gdb/gdbserver,调试程序更方便。不晓得有没有gcc
本人菜鸟,欢迎大家自己编译出一些有趣的程序出来。
这是我编译过的:以路由攻路由 passwd密码生成工具 |
|