我正在尝试在linux上使用交叉编译器构建一个应用程序 . 应用程序基于OpenEmbedded项目 . 编译器和所有交叉编译的库都位于build文件夹中 . 但是对于一个包构建脚本试图使用我的linux环境中的库 .

最后从make脚本调用的命令:

/ bin / sh ./arm-ABC-linux-gnueabi-libtool --tag = CXX --mode = link arm-ABC-linux-gnueabi-g -march = armv7-a -mtune = cortex-a8 -mfpu = neon -mfloat-abi = softfp -g --std = c 0x -pthread -L / home / ABC / build / sysroots / armv7a-ABC-linux-gnueabi / opt / my / lib -Wl,-rpath-link,/ home / ABC / build / sysroots / armv7a-ABC-linux-gnueabi / opt / my / lib -Wl,-O1 -Wl, - hash-style = gnu -L / opt / my / lib -o modbus_server_test modbus_server_test.o Serial.o SerialUtil.o Crc.o RtuFramer.o Pdu.o SerialMaster.o /home/ABC/build/sysroots/armv7a-ABC-linux-gnueabi/usr/local/apr/lib/libapr-2.la -lcrypt -luuid -lrt -lcrypt -lpthread -ldl -lexpat -lstdc

从这里最重要的是使用-lexpat标志为libexpat.so.1.5.2库 . 这个库是交叉编译的,位于build文件夹中,同时我们在linux环境中有一个库 .

结果我收到了下一个错误:

| arm-ABC-linux-gnueabi-libtool:link:arm-ABC-linux-gnueabi-g -march = armv7-a -mtune = cortex-a8 -mfpu = neon -mfloat-abi = softfp -g --std = c 0x -pthread -Wl,-rpath-link -Wl,/ home / ABC / build / sysroots / armv7a-ABC-linux-gnueabi / opt / my / lib -Wl,-O1 -Wl, - hash-style = gnu -o .libs / modbus_server_test modbus_server_test.o Serial.o SerialUtil.o Crc.o RtuFramer.o Pdu.o SerialMaster.o -L / home / ABC / build / sysroots / armv7a-ABC-linux-gnueabi / opt / my / lib -L / opt / my / lib /usr/local/apr/lib/libapr-2.so -L / home / ABC / build / sysroots / armv7a-ABC-linux-gnueabi / usr / lib / usr / lib / x86_64-linux-gnu / libexpat.so /home/ABC/build/sysroots/armv7a-ABC-linux-gnueabi/usr/lib/libuuid.so -lrt -lcrypt -lpthread -ldl / home / ABC / build / sysroots / armv7a-ABC-linux-gnueabi / usr / lib / libexpat.so / home / ABC / build / build / sysroots / armv7a-ABC-linux-gnueabi / usr / lib / libstdc .so -lm -pthread -Wl,-rpath -Wl,/ usr / local / apr / lib -Wl,-rpath -Wl,/ home / ABC / build / sysroots / armv7a-ABC-linux-gnueabi / usr / lib | /usr/lib/x86_64-linux-gnu/libexpat.so:文件无法识别:无法识别文件格式collect2:ld返回1退出状态| make [2]:*** [modbus_server_test]错误1

从输出我可以看到它包括两个库:一个来自linux环境(/usr/lib/x86_64-linux-gnu/libexpat.so,这是x86),一个来自build文件夹(build / sysroots / armv7a-ABC-linux) -gnueabi / usr / lib / libexpat.so用于ARM) . 最后它抱怨x86类型 .

如何在全球环境中排除此库以进行搜索?为什么甚至试图同时使用它们?