AM335x(TQ335x)学习笔记——Linux CAN测试程序的编译


  1.首先编译libsocketcan

 

  从终端进入libsocketcan源码目录,输入命令

  CC=arm-linux-gcc ./configure --prefix=<安装路径>(需绝对路径) --host=arm-linux --build=i386

  make

  make install

 

  编译成功,在 <安装路径>/lib/pkgconfig/下有个libsocketcan.pc文件,将其拷贝到PC的/usr/lib/pkgconfig/目录下。

 

  2.编译canutils-4.0.6

  先确认系统已安装automake

  apt-get install automake

  配置

  ./configure --host=arm-linux --prefix=<安装目录> --enable-debug

  (如出现

  config.status: executing libtool commands

  sed: can't read config/autoconf/ltmain.sh: No such file or directory

  sed: can't read libtoolT: No such file or directory

  则apt-get install libtool 安装

  然后执行

  终端输入命令:autoreconf

  再重新

  ./configure --host=arm-linux --prefix=<安装目录> --enable-debug

  )

  在canutils-4.0.6源码中的src/GNUmakefile.in 中的

  CFLAGS = @CFLAGS@ (大概在96/97行)改为

  CFLAGS = -Wall -g -O2

  make

  1)错误1:

  cc1: warnings being treated as errors

  candump.c: In function 'main':

  candump.c:190: error: ignoring return value of 'daemon', declared with attribute warn_unused_result

  make[1]: *** [candump.o] 错误 1

  解决方法:

  根据错误提示,是candump.c 忽略了返回值。所以在

  打开源码src/candump.c文件,找到190行,将

  daemon(1, 0);

  改为:

  {

  int ret =0 ;

  ret = daemon(1,0);

  }

  保存退出,重新make。

  2)错误2:

  /bin/bash ../libtool --tag=CC --mode=link arm-linux-gcc -Wall -g -O2 -o candump candump.o

  libtool: Version mismatch error. This is libtool 2.4.2 Debian-2.4.2-1ubuntu1, but the

  libtool: definition of this LT_INIT comes from libtool 2.4.

  libtool: You should recreate aclocal.m4 with macros from libtool 2.4.2 Debian-2.4.2-1ubuntu1

  libtool: and run autoconf again.

  make[1]: *** [candump] 错误 63

  解决方法:

  终端中执行命令:rm aclocal.m4 & aclocal & autoconf

  然后执行:rpmbuild -bb *.spec

  重新 make

  3)错误3:

  canecho.c: In function 'main':

  canecho.c:163: error: ignoring return value of 'write', declared with attribute warn_unused_result

  make[1]: *** [canecho.o] 错误 1

  解决方法:

  将src/canecho.c的第163行:

  write(s[out], &frame, sizeof(frame));

  改为:

  int ret;

  ret = write(s[out], &frame, sizeof(frame));

 

  重新make。

 

http://processors.wiki.ti.com/index.php/AM335X_DCAN_Driver_Guide

http://www.embedsky.com/index.php?s=/Product/show/id/49.html

http://www.embedsky.com/index.php?s=/Product/show/id/86.html


你可能感兴趣的:(linux,can,TQ335X)