首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >以OpenWrt为操作系统的MIPS交叉编译Snap7

以OpenWrt为操作系统的MIPS交叉编译Snap7
EN

Stack Overflow用户
提问于 2014-06-05 17:46:04
回答 1查看 749关注 0票数 1

目前,我正在做一个从西门子PLC中记录数据的项目。为了实现这一点,我使用了Snap7。Snap7 (http://snap7.sourceforge.net/)是一个通信库。

我已经设法让它在我的linux桌面上工作,但是当我试图交叉编译snap7库时,我得到了一些错误。

链接所有目标文件时会生成该错误。

代码语言:javascript
复制
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++编译该软件。现在又给出了另一个错误:

代码语言:javascript
复制
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标志,所以我不能在那里设置链接器。

EN

回答 1

Stack Overflow用户

发布于 2014-06-06 03:03:33

你能交叉编译并运行一个"hello world“程序吗?

file ../temp/mips-openwrt-linux/sys_snap_msgsock.o的输出是什么

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24056859

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档