我已经在一段时间内开发了一个C++项目,但想将其移植到我的ARM处理器上。我已经拥有所有的交叉编译工具(我正在使用CodeSourcery),并认为只需更改我的makefile以指向该编译器即可。它使用默认的g++进行编译,但是当我尝试使用交叉编译器进行编译时,出现了重定位错误:
/home/oryan/CodeSourcery/bin/../lib/gcc/arm-none-linux-gnueabi/4.5.2/../../../../arm-none-linux-gnueabi/bin/ld: ServerSocket.o: Relocations in generic ELF (EM: 3) ServerSocket.o: could not read symbols: File in wrong format collect2: ld returned 1 exit status make: *** [simple_server] Error 1
看起来我没有正确设置链接或者链接指向了错误的位置。我对makefile不太熟悉,可能会遗漏一些显而易见的东西。我一直在使用的makefile来自于这里:http://tldp.org/LDP/LG/issue74/tougher.html,已经删除了客户端部分。
/home/oryan/CodeSourcery/bin/../lib/gcc/arm-none-linux-gnueabi/4.5.2/../../../../arm-none-linux-gnueabi/bin/ld: ServerSocket.o: Relocations in generic ELF (EM: 3) ServerSocket.o: could not read symbols: File in wrong format collect2: ld returned 1 exit status make: *** [simple_server] Error 1
看起来我没有正确设置链接或者链接指向了错误的位置。我对makefile不太熟悉,可能会遗漏一些显而易见的东西。我一直在使用的makefile来自于这里:http://tldp.org/LDP/LG/issue74/tougher.html,已经删除了客户端部分。
# Makefile for the socket programming example
#
simple_server_objects = ServerSocket.o Socket.o simple_server_main.o
all : simple_server
simple_server: $(simple_server_objects)
/home/matt/CodeSourcery/bin/arm-none-linux-gnueabi-g++ -o simple_server $(simple_server_objects)
Socket: Socket.cpp
ServerSocket: ServerSocket.cpp
simple_server_main: simple_server_main.cpp
clean:
rm -f *.o simple_server
目前我正在手动编译每个文件,效果很好,但我想进一步了解这里的情况。
谢谢!
g++ -print-prog-name=ld
来显示它正在使用哪一个,但我不记得如何指定一个了。我认为它会从与 cc1plus 相同的目录中选择一个 - 你在那个目录中有一个 ld 吗(可能是 CodeSourcery/libexec/gcc/arm-none-linux-gnueabi/4.5.2/)?你确定已经为交叉编译器安装了 binutils 吗? - Rup