常用工具软件的交叉编译

常用工具软件的交叉编译,持续更新。。。


iproute2、libsocketcan、canutils参考网址:

1、http://www.embedu.org/Column/Column596.htm

2、http://processors.wiki.ti.com/index.php/AM335X_DCAN_Driver_Guide#CAN_Utilities

一、libsocketcan-0.0.9.tar.bz2交叉编译


因为canutils编译需要libsocketcan库的支持,需要下载libsocketcan。
下载地址:http://www.pengutronix.de/software/libsocketcan/download/ 笔者下载的是libsocketcan 0.0.9

1、./configure \
--host=arm-xilinx-linux-gnueabi \
--prefix=/usr/local/libsocketcan

2、make

3、sudo make install
报错如下:
../libtool: line 1088: arm-xilinx-linux-gnueabi-ranlib: command not found
make[2]: *** [install-libLTLIBRARIES] 错误 127
make[2]:正在离开目录 `/home/zb/ruanjianbao/libsocketcan-0.0.9/src'
make[1]: *** [install-am] 错误 2
make[1]:正在离开目录 `/home/zb/ruanjianbao/libsocketcan-0.0.9/src'
make: *** [install-recursive] 错误 1


解决方法:
先进入root用户
然后在root用户下配置交叉编译器
export PATH=/home/zb/mygcc/CodeSourcery/Sourcery_CodeBench_Lite_for_Xilinx_GNU_Li    nux/bin:$PATH
最后在root用户下make install


二、canutils 3.0.0交叉编译
注意:使用3.0.0版本不会出错

下载地址:http://www.pengutronix.de/software/socket-can/download/canutils 。笔者下载的是canutils 3.0.0。
1、./configure --host=arm-xilinx-linux-gnueabi \
--prefix=/usr/local/canutils \
libsocketcan_LIBS=-lsocketcan \
LDFLAGS=-L/home/zb/libsocketcan/lib \
CPPFLAGS=-I/home/zb/libsocketcan/include

2、make

3、sudo make install
 
三、iproute2 2.6.36 交叉编译 Socket CAN测试 
注意:只能用2.6.36,别的版本ip命令不能用

因为最新版BusyBox对Socket CAN的不支持,所以为了测试和使用Socket CAN,我们需要自己编译Socket CAN的工具。这里介绍两个工具,分别是

iproute2 和 canutils。
(1)下载地址:http://pkgs.fedoraproject.org/repo/pkgs/iproute/iproute2-2.6.39.tar.gz/8a3b6bc77c2ecf752284aa4a6fc630a6/iproute2-2.6.39.tar.gz。笔者下载的是iproute2 2.6.36。
(2)解压iproute2-2.6.36.tar.xz,修改Makefile第33行。
        33 #CC = gcc
        34 CC = arm-none-linux-gnueabi-gcc
(3)因为我们只需要iprout2的ip命令,所以修改Makefile的第42行。
        42 #SUBDIRS=lib ip tc bridge misc netem genl man
        43 SUBDIRS=lib ip
(4)修改完成执行make命令,生成ip命令,拷贝到开发板文件系统目录。
(5)使用ip命令。
        ifconfig can0 down         //关闭can0,以便配置
        ./ip link set can0 up type can bitrate 250000       //设置can0波特率

        ./ip -details link show can0        //显示can0信息


四、linuxptp1.6交叉编译 只能用1.6版本

(1)源码下载网址:https://sourceforge.net/projects/linuxptp/files/v1.6/

(2)交叉编译: make ARCH=arm CROSS_COMPILE=arm-xilinx-linux-gnueabi-

(3)编译出错:

sk.c:58:30: error: 'HWTSTAMP_TX_ONESTEP_SYNC' undeclared (first use in this function)
sk.c:58:30: note: each undeclared identifier is reported only once for each function it appears in


clockadj.o:clockadj.c:(.text+0x5d8): more undefined references to `clock_adjtime' follow
collect2: ld returned 1 exit status
make: *** [ptp4l] 错误 1

(4)问题解决:

1、sk.c 缺少宏,我直接把内核的net_tstamp.h拷贝过来//可以不管这一步

2、然后注释掉missing.h  的65行#ifndef HAVE _CLOCK _ADJTIME、70行 #endif和51行#ifndef HAVE_ONESTEP_SYNC、55行#endif


五、redhat下gpsd源码安装gpsd

在ubuntu下:apt-get install gpsd

(1)下载gpsd源码:http://www.catb.org/gpsd/#downloads

(2)安装scons---scons安装和使用 //安装scons 2.1.0以上的版本

首先安装各种依赖:
  • yum install gcc
  • yum install ncurses ncurses-devel
  • yum install python-devel //安装python2.5以上的版本

1. scons是神马?

 scons是linux下的自动构建工具,类似cmake。
2. 安装

 wget http://prdownloads.sourceforge.net/scons/scons-2.2.0.tar.gz .
 tar zxvf scons-2.2.0.tar.gz
 cd scons-2.2.0
 python setup.py install
 正常情况下,scons将安装到${PYTHON_INSTALL_DIR}/bin/下

(3)安装chrpath

yum install chrpath 

(4)在gpsd源码下执行:

1、scons

2、scons install

3、 scons udev-install

(5)安装运行gpsd服务---install as service 

cd <gpsd source folder>
cp packaging/rpm/gpsd.init /etc/init.d/gpsd
chmod 755 /etc/init.d/gpsd
cp packaging/rpm/gpsd.sysconfig /etc/sysconfig/gpsd
chmod 644 /etc/sysconfig/gpsd
chkconfig gpsd on



猜你喜欢

转载自blog.csdn.net/a746742897/article/details/53158754