linux第三方程序移植

摘要:在linux开发过程中经常需要用到第三方的程序,有时需要用到它们的库,有时需要它们生成的可执行文件,如何正确地编译这些第三方的程序,以方便地使用和开发自己需要的程序,将是本文要论述的内容.

 

1.移植第三方程序有几种情况

1.1 如果源码包有Makefile文件,直接改Makefile,修改CC, AS, LD, CFLAGS,INSTALL_PATH等。

1.2 源码包没有Makefile文件,但有configure/config文件:

1.2.1设置 CC, LD ,AS, LDFLAGS ,AR,RANLIB等环境变量,如下面的lrzsz命令移植中的

CC=/opt/buildroot-2011.11/arm920t/usr/bin/arm-linux-gcc AR=/opt/buildroot-2011.11/arm920t/usr/bin/arm-linux-ar LD=/opt/buildroot-2011.11/arm920t/usr/bin/arm-linux-ld AS=/opt/buildroot-2011.11/arm920t/usr/bin/arm-linux-as RANLIB=/opt/buildroot-2011.11/arm920t/usr/bin/arm-linux-ranlib ./configure --host=arm-linux

指定交叉编译器路径,指定链接路径及AS,AR等。

1.2.2 make

1.2.3.make install

1.3 没有configure/config,也没有Makefile,但是会有一个autogen.sh脚本

 

1.3.1sh autogen.sh -->生成configure文件
1.3.2 再按照二做。

 

 

 

 

 

2.下面以移植lrzsz为例进行讲解:

2.1从网上下载lrzsz压缩包(http://download.chinaunix.net/download.php?ResourceID=6293&id=12772)

[weishusheng@localhost thirdparty]$ ls
lrzsz-0.12.20.tar.gz

2.2.解压

[weishusheng@localhost thirdparty]$ tar -xzf lrzsz-0.12.20.tar.gz
[weishusheng@localhost thirdparty]$ ls
lrzsz-0.12.20 lrzsz-0.12.20.tar.gz

2.3.进入lrzsz-0.12.20

2.4.生成Makefile文件

[weishusheng@localhost lrzsz-0.12.20]$ CC=/opt/buildroot-2011.11/arm920t/usr/bin/arm-linux-gcc AR=/opt/buildroot-2011.11/arm920t/usr/bin/arm-linux-ar LD=/opt/buildroot-2011.11/arm920t/usr/bin/arm-linux-ld AS=/opt/buildroot-2011.11/arm920t/usr/bin/arm-linux-as RANLIB=/opt/buildroot-2011.11/arm920t/usr/bin/arm-linux-ranlib ./configure --host=arm-linux

2.5.

 

2.6.[weishusheng@localhost lrzsz-0.12.20]$ make

2.7.

2.8.我们看到lsz与lrz是在arm上运行的

2.9.把lsz,lrz下到开发板

先放到、tftp目录下

[weishusheng@localhost src]$ cp lsz lrz /tftp

在开发板上下载

>: tftp -gr lsz 192.168.1.3

>: tftp -gr lrz 192.168.1.3

修改权限

>: chmod 777 lsz lrz

 

2.10.测试

移植第三方程序lszrz成功。

 

 

3 tree程序移植到fl2440开发板

3.1.第一步同样从网上下载压缩包

3.2.解压

[weishusheng@localhost tree]$ tar -xzf tree-1.5.1.tar.gz
[weishusheng@localhost tree]$ ls
tree-1.5.1 tree-1.5.1.tar.gz

3.3.[weishusheng@localhost tree]$ cd tree-1.5.1

3.4.修改相关设置

[weishusheng@localhost tree-1.5.1]$ sudo vim Makefile

把CC=gcc

改为

CC=/opt/buildroot-2011.11/arm920t/usr/bin/arm-linux-gcc

3.5.编译

[weishusheng@localhost tree-1.5.1]$ sudo make

3.6.上传到tftp服务器

[weishusheng@localhost tree-1.5.1]$ sudo cp tree /tftp

3.7.下载到开发板

 

3.8.测试

 

tree命令移植到fl2440开发板成功。   

 

posted @ 2014-09-01 20:36  wssheng  阅读(952)  评论(0编辑  收藏  举报