vtysh的移植
vtysh的移植
配置交叉编译链的环境变量
source /opt/fsl-networking/QorIQ-SDK-V1.8/environment-setup-ppce500v2-fsl-linux-gnuspe
替换vtysh工程中的CC变量
vi Makefile
注释掉CC变量
编译
err1:
vtysh.c:37:31: fatal error: readline/readline.h: No such file or directory
需要libreaadline库
交叉编译libreadline
-
下载解压源码
-
./configure --prefix=/opt/fsl-networking/QorIQ-SDK-V1.8/sysroots/ppce500v2-fsl-linux-gnuspe/usr
err2:
configure: loading site script /opt/fsl-networking/QorIQ-SDK-V1.8/site-config-ppce500v2-fsl-linux-gnuspe checking build system type... i686-pc-linux-gnu checking host system type... i686-pc-linux-gnu Beginning configuration for readline-6.0 for i686-pc-linux-gnu checking whether make sets $(MAKE)... yes checking for gcc... powerpc-fsl-linux-gnuspe-gcc -m32 -mcpu=8548 -mabi=spe -mspe -mfloat-gprs=double --sysroot=/opt/fsl-networking/QorIQ-SDK-V1.8/sysroots/ppce500v2-fsl-linux-gnuspe checking for C compiler default output file name... configure: error: in `/home/freescale/work/readline-6.0': configure: error: C compiler cannot create executables See `config.log' for more details.
查看config.log后发现是–hash-style=gnu的问题,查找–hash-style=gnu的位置,发现在/opt/fsl-networking/QorIQ-SDK-V1.8/environment-setup-ppce500v2-fsl-linux-gnuspe中
export LDFLAGS="--hash-style=gnu -Wl,--as-needed"
,所以执行unset LDFLAGS
。类似的问题在编译kernel时遇到过,报错不一样,但是当时百度解决了问题,并没有发现问题的本质。所以我们发现问题和解决问题时,要知道为什么会有问题,掌握解决问题的方法,否则下次出现问题时,依旧不会解决,而且还会花费大量的时间来解决相同的问题。
err3:
checking for C compiler default output file name... a.out checking whether the C compiler works... configure: error: in `/home/freescale/work/readline-6.0': configure: error: cannot run C compiled programs. If you meant to cross compile, use `--host'. See `config.log' for more details.
./configure --host=powerpc-fsl-linux-gnuspe --prefix=/opt/fsl-networking/QorIQ-SDK-V1.8/sysroots/ppce500v2-fsl-linux-gnuspe/usr
-
make
-
make install
继续编译vtysh
-
make
err4:
In file included from /opt/fsl-networking/QorIQ-SDK-V1.8/sysroots/ppce500v2-fsl-linux-gnuspe/usr/include/readline/readline.h:35:0, from vtysh_main.c:27: /opt/fsl-networking/QorIQ-SDK-V1.8/sysroots/ppce500v2-fsl-linux-gnuspe/usr/include/readline/rltypedefs.h:64:28: error: unknown type name 'FILE' typedef int rl_getc_func_t PARAMS((FILE *)); ^ /opt/fsl-networking/QorIQ-SDK-V1.8/sysroots/ppce500v2-fsl-linux-gnuspe/usr/include/readline/readline.h:416:20: error: unknown type name 'FILE' extern int rl_getc PARAMS((FILE *)); ^ In file included from vtysh_main.c:27:0: /opt/fsl-networking/QorIQ-SDK-V1.8/sysroots/ppce500v2-fsl-linux-gnuspe/usr/include/readline/readline.h:539:8: error: unknown type name 'FILE' extern FILE *rl_instream; ^ /opt/fsl-networking/QorIQ-SDK-V1.8/sysroots/ppce500v2-fsl-linux-gnuspe/usr/include/readline/readline.h:540:8: error: unknown type name 'FILE' extern FILE *rl_outstream; ^ /opt/fsl-networking/QorIQ-SDK-V1.8/sysroots/ppce500v2-fsl-linux-gnuspe/usr/include/readline/readline.h:562:8: error: unknown type name 'rl_getc_func_t' extern rl_getc_func_t *rl_getc_function; ^ /opt/fsl-networking/QorIQ-SDK-V1.8/sysroots/ppce500v2-fsl-linux-gnuspe/usr/include/readline/readline.h:844:3: error: unknown type name 'FILE' FILE *inf; ^ /opt/fsl-networking/QorIQ-SDK-V1.8/sysroots/ppce500v2-fsl-linux-gnuspe/usr/include/readline/readline.h:845:3: error: unknown type name 'FILE' FILE *outf;
这是因为readline.h文件中没有stdio.h头文件包含引起的
vi /opt/fsl-networking/QorIQ-SDK-V1.8/sysroots/ppce500v2-fsl-linux-gnuspe/usr/include/readline/readline.
把
#include <stdio.h>
加进去err5:
/opt/fsl-networking/QorIQ-SDK-V1.8/sysroots/i686-fslsdk-linux/usr/bin/powerpc-fsl-linux-gnuspe/powerpc-fsl-linux-gnuspe-ld: cannot find -lncurses collect2: error: ld returned 1 exit status make: *** [vtysh] Error 1
安装ncurses,下载源码,执行
./configure --host=powerpc-fsl-linux-gnuspe --prefix=/opt/fsl-networking/QorIQ-SDK-V1.8/sysroots/ppce500v2-fsl-linux-gnuspe/usr
,然后编译make
,安装make install
err6:
make[1]: powerpc-fsl-linux-gnuspe-ranlib: Command not found make[1]: *** [install] Error 127 make[1]: Leaving directory `/home/freescale/work/ncurses-6.0/ncurses' make: *** [install] Error 2
这是因为$RANLIB环境变量的问题,看来
source /opt/fsl-networking/QorIQ-SDK-V1.8/environment-setup-ppce500v2-fsl-linux-gnuspe
命令的坑还是挺多的,freescale专门坑小朋友。执行
RANLIB="powerpc-fsl-linux-gnuspe-ranlib --sysroot=$SDKTARGETSYSROOT"
,make install
,ok安装完成。发现坑,要填坑,把
/opt/fsl-networking/QorIQ-SDK-V1.8/environment-setup-ppce500v2-fsl-linux-gnuspe
文件的其他编译链的参数也该一下吧,以后就不会遇到类似问题了。主要给as、ld、ranlib
添加就可以。 -
make
-
file vtysh
[email protected]:~/work/yw1016-vty-20190228$ file vtysh vtysh: ELF 32-bit MSB executable, PowerPC or cisco 4500, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.16, BuildID[sha1]=3234b5a501bfe2c0f0ed057ded813a76b0feaf49, not stripped
可执行文件时powerpc架构的,编译成功了
上一篇: SpringBoot整合MQTT