目前,我正在做一个从西门子PLC中记录数据的项目。为了实现这一点,我使用了Snap7。Snap7 (http://snap7.sourceforge.net/)是一个通信库。
我已经设法让它在我的linux桌面上工作,但是当我试图交叉编译snap7库时,我得到了一些错误。
链接所有目标文件时会生成该错误。
g++ -shared -fPIC -o ../bin/mips-openwrt-linux-g++/libsnap7.so @"filelist.txt" -L. -lpthread -lrt -O3
/usr/bin/ld: ../temp/mips-openwrt-linux/sys_snap_msgsock.o: Relocations in generic ELF (EM: 8)
./temp/mips-openwrt-linux/sys_snap_msgsock.o: could not read symbols: File in wrong format
collect2: error: ld returned 1 exit status
make: *** [../bin/mips-openwrt-linux-g++/libsnap7.so] Error 1如果我是正确的,我认为它使用了错误的链接器,它应该使用位于: openwrt/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/bin/的工具链的链接器
我还尝试使用mips-openwrt-linux-g++编译该软件。现在又给出了另一个错误:
mips-openwrt-linux-g++ -shared -fPIC -o ../bin/mips-openwrt-linux-g++/libsnap7.so @"filelist.txt" -L. -lpthread -lrt -O3
openwrt/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/lib/gcc/mips-openwrt-linux-uclibc/4.8.3/../../../../mips-openwrt-linux-uclibc/bin/ld: ../temp/mips-openwrt-linux/sys_snap_msgsock.o: relocation R_MIPS_26 against `close' can not be used when making a shared object; recompile with -fPIC
../temp/mips-openwrt-linux/sys_snap_msgsock.o: could not read symbols: Bad value
collect2: error: ld returned 1 exit status
make: *** [../bin/mips-openwrt-linux-g++/libsnap7.so] Error 1我希望有人熟悉这个错误,并能帮助我。
提前谢谢。
edit1:有一些预编译的二进制文件。在makefile中,我将CC更改为我的g++目录。没有LD标志,所以我不能在那里设置链接器。
发布于 2014-06-06 03:03:33
你能交叉编译并运行一个"hello world“程序吗?
file ../temp/mips-openwrt-linux/sys_snap_msgsock.o的输出是什么
https://stackoverflow.com/questions/24056859
复制相似问题