我在Ubuntu上開發了一個modbus1.c,它包含了某個modbus.h。我想交叉編譯我寫在嵌入式計算機上運行的內容;要做到這一點我知道我需要使用arm-linux-gcc交叉編譯器。arm-linux-gcc編譯器連接,找不到文件
我在Ubuntu上安裝了這個名爲libmodbus的庫。它方便使用pkg配置(其限定-I/USR /包括用於--cflags/MODBUS和-lmodbus和分別--libs)
當我使用定期GCC:
gcc -o modbus1-release modbus1.c `pkg-config --cflags --libs libmodbus`
一切工作正常,modbus1-release被創建,我可以執行它。
,當我嘗試使用臂的linux-gcc編譯器的問題出現了:
/usr/local/arm-linux/bin/arm-linux-gcc -o modbus1-release modbus1.c `pkg-config --cflags --libs libmodbus`
/usr/local/arm-linux/bin/../lib/gcc-lib/arm-linux/3.3.2/../../../../arm-linux/bin/ld: cannot find -lmodbus
collect2: ld returned 1 exit status
make: *** [release] Error 1
從正面回答
除此之外,當我想象有什麼事情的「幫助」我的即時通訊思想回答以下問題可能會'幫助'我:
- 如何展開所有../和../../../../?如果我知道它在哪裏,那麼也許我可以將-lmodbus放在那裏
- 什麼是-lmodbus?這是一個文件嗎?常規gcc和ld可以在哪裏找到它?
- 是-l一個標誌和modbus的文件名?
我的直覺告訴我,問題來自於鏈接...... arm-linux-gcc工具鏈中的cc和ld缺少正常的cc和ld所具有的信息。
任何信息將有所幫助!
TIA
尼科
詳細模式...
/usr/local/arm-linux/bin/arm-linux-gcc -v -o modbus1-release modbus1.c `pkg-config --cflags --libs libmodbus`
Reading specs from /usr/local/arm-linux/bin/../lib/gcc-lib/arm-linux/3.3.2/specs
Configured with: ../configure --target=arm-linux --disable-shared --with-headers=/home/gerg/new-wave.xscale/linux-2.4.x/include --with-gnu-as --with-gnu-ld --enable-multilib
Thread model: posix
gcc version 3.3.2
/usr/local/arm-linux/bin/../lib/gcc-lib/arm-linux/3.3.2/cc1 -quiet -v -I/usr/include/modbus -iprefix /usr/local/arm-linux/bin/../lib/gcc-lib/arm-linux/3.3.2/ -D__GNUC__=3 -D__GNUC_MINOR__=3 -D__GNUC_PATCHLEVEL__=2 -D__ARM_ARCH_4T__ modbus1.c -quiet -dumpbase modbus1.c -auxbase modbus1 -version -o /tmp/ccVLqs9W.s
GNU C version 3.3.2 (arm-linux)
compiled by GNU C version 3.2.2 20030222 (Red Hat Linux 3.2.2-5).
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "NONE/include"
ignoring nonexistent directory "/usr/local/lib/gcc-lib/arm-linux/3.3.2/include"
ignoring nonexistent directory "/usr/local/arm-linux/sys-include"
ignoring duplicate directory "/usr/local/arm-linux/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/include/modbus
/usr/local/arm-linux/lib/gcc-lib/arm-linux/3.3.2/include
/usr/local/arm-linux/arm-linux/sys-include
/usr/local/arm-linux/arm-linux/include
End of search list.
/usr/local/arm-linux/bin/../lib/gcc-lib/arm-linux/3.3.2/../../../../arm-linux/bin/as -o /tmp/ccMyv4IL.o /tmp/ccVLqs9W.s
/usr/local/arm-linux/bin/../lib/gcc-lib/arm-linux/3.3.2/collect2 -dynamic-linker /lib/ld-linux.so.2 -X -m armelf_linux -p -o modbus1-release /usr/local/arm-linux/bin/../lib/gcc-lib/arm-linux/3.3.2/../../../../arm-linux/lib/crt1.o /usr/local/arm-linux/bin/../lib/gcc-lib/arm-linux/3.3.2/crti.o /usr/local/arm-linux/bin/../lib/gcc-lib/arm-linux/3.3.2/crtbegin.o -L/usr/local/arm-linux/bin/../lib/gcc-lib/arm-linux/3.3.2 -L/usr/local/arm-linux/bin/../lib/gcc-lib -L/usr/local/arm-linux/bin/../lib/gcc-lib/arm-linux/3.3.2/../../../../arm-linux/lib -L/usr/local/lib/../arm-linux/lib -L/usr/local/arm-linux/bin/../lib/gcc-lib/arm-linux/3.3.2/../../.. /tmp/ccMyv4IL.o -lmodbus -lgcc -lc -lgcc /usr/local/arm-linux/bin/../lib/gcc-lib/arm-linux/3.3.2/crtend.o /usr/local/arm-linux/bin/../lib/gcc-lib/arm-linux/3.3.2/crtn.o
/usr/local/arm-linux/bin/../lib/gcc-lib/arm-linux/3.3.2/../../../../arm-linux/bin/ld: cannot find -lmodbus
collect2: ld returned 1 exit status
make: *** [release] Error 1
聽起來像你忘了爲ARM構建MODBUS庫... –
我該怎麼做?我有一個ARM的交叉編譯器和MODBUS庫的源代碼......但無法弄清楚如何爲ARM構建modbus庫。我試着將Makefile中的CC改爲arm-linux-gcc。 – nemo