我正在尝试使用工具链(/home/amruta/Downloads/poky-glibc-x86_64-core-image-weston-sdk-cortexa7hf-neon-toolchain-2.4.2.sh)交叉编译 C 代码(在 yocto 之外),用于瑞萨 G1E模块。交叉编译遵循的程序:
安装给定的工具链
设置环境:
amruta@amruta-OptiPlex-3060:~$ . /opt/poky/2.4.2/environment-setup-cortexa7hf-neon-poky-linux-gnueabi
- 在同一终端编译:
amruta@amruta-OptiPlex-3060:~/amruta/amruta_projects/G1E/EnergyMeterApp1/src$ $CC *.c -o Energymeter -L /opt/poky/2.4.2/sysroots/cortexa7hf-neon-poky-linux-gnueabi/usr/lib/libmosquitto -I /opt/poky/2.4.2/sysroots/cortexa7hf-neon-poky-linux-gnueabi/usr/include/
用于交叉编译的源文件:
amruta@amruta-OptiPlex-3060:~/amruta/amruta_projects/G1E/EnergyMeterApp1/src$ ls
client_shared_lib.c EnergyMeterApp1.h GenericFunctions.c modbus ProcessHandler.c
client_shared_lib.h FileLogger.c GenericFunctions.h mosq_pub_sub_client.c ProcessHandler.h
FileLogger.h libconfig.h mosq_pub_sub_client.h ReadAllConfigs.c
EnergyMeterApp1.c GenericDefns.h Makefile mosquitto.h ReadAllConfigs.h
lib 目录中已经存在的库文件
amruta@amruta-OptiPlex-3060:~$ ls /opt/poky/2.4.2/sysroots/cortexa7hf-neon-poky-linux-gnueabi/usr/lib | grep libmos
libmosquitto.so.1
amruta@amruta-OptiPlex-3060:~$ ls /opt/poky/2.4.2/sysroots/cortexa7hf-neon-poky-linux-gnueabi/usr/lib | grep libconf
libconfig.so.9
libconfig++.so.9
libconfig.so.9.2.0
libconfig++.so.9.2.0
amruta@amruta-OptiPlex-3060:~$
包含目录中的头文件
amruta@amruta-OptiPlex-3060:~$ ls /opt/poky/2.4.2/sysroots/cortexa7hf-neon-poky-linux-gnueabi/usr/include/ | grep mos
mosquitto.h
amruta@amruta-OptiPlex-3060:~$ ls /opt/poky/2.4.2/sysroots/cortexa7hf-neon-poky-linux-gnueabi/usr/include/ | grep libconfig
libconfig.h
构建输出(部分):
amruta@amruta-OptiPlex-3060:~/amruta/amruta_projects/G1E/EnergyMeterApp1/src$ $CC *.c -o Energymeter -L /opt/poky/2.4.2/sysroots/cortexa7hf-neon-poky-linux-gnueabi/usr/lib/libmosquitto -I /opt/poky/2.4.2/sysroots/cortexa7hf-neon-poky-linux-gnueabi/usr/include/
/tmp/ccBMhPYg.o: In function client_id_generate':
client_shared_lib.c:(.text+0x64): undefined reference to mosquitto_lib_cleanup'
client_shared_lib.c:(.text+0x144): undefined reference to `mosquitto_lib_cleanup'
/tmp/ccRMPfVp.o: In function ReadEnergyMeterConfigs':
ReadAllConfigs.c:(.text+0x374): undefined reference to config_init'
ReadAllConfigs.c:(.text+0x384): undefined reference to config_read_file'
ReadAllConfigs.c:(.text+0x3c8): undefined reference to config_destroy'
请建议成功的交叉编译。