英文:
Can't cross compile using clang
问题
我正试图使用来自x86_64的clang为ARM编译GNU,但似乎无法获得正确的输出。在编译和运行'make'之后,我得到了ELF文件,但当我运行'file which'时,我得到了以下结果:
which: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter
/lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, with debug_info, not stripped
这表明它没有为正确的目标编译,因为当我使用gcc进行交叉编译时,我得到了以下结果:
ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter
/lib/ld-linux.so.3, BuildID[sha1]=077463715830376120e14ecd3b8ff9b80ba765cd, for GNU/Linux 3.2.0, with debug_info, not stripped
这是我目前正在使用的命令:
./configure CC=/home/anon/Documents/llvm/llvm-project/build/bin/clang
-target arm-linux-gnueabi LD=/home/anon/Documents/llvm/llvm-project/build/lib/LLVMgold.so
LDFLAGS='-fuse-ld=gold' RANLIB=/home/anon/Documents/llvm/llvm-project/build/bin/llvm-ranlib
我还尝试过使用-host,这是我在使用gcc进行交叉编译时使用的选项,但那也不起作用。我做错了什么?请帮助!
英文:
I'm trying to compile gnu which for ARM using clang from x86_64, but I can't seem to get the correct output. After compiling and running 'make' I get resulting ELF file, but when I run 'file which' I get the following:
which: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter
/lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, with debug_info, not stripped
which would indicate that it wasn't compiled for the correct target, because when I cross compile using gcc, I get the following:
ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter
/lib/ld-linux.so.3, BuildID[sha1]=077463715830376120e14ecd3b8ff9b80ba765cd, for GNU/Linux 3.2.0, with debug_info, not stripped
This is the command I'm using at the moment:
./configure CC=/home/anon/Documents/llvm/llvm-project/build/bin/clang
-target arm-linux-gnueabi LD=/home/anon/Documents/llvm/llvm-project/build/lib/LLVMgold.so
LDFLAGS='-fuse-ld=gold' RANLIB=/home/anon/Documents/llvm/llvm-project/build/bin/llvm-ranlib
I've also tried using -host which is what I used when cross compiling with gcc, but that doesn't work either. What am I doing wrong? Please help!
答案1
得分: 0
你可能需要将-target arm-linux-gnueabi
作为CFLAGS
/ CXXFLAGS
变量传递。或者,作为替代,你可以创建一个从clang
到arm-linux-gnueabi-clang
的符号链接。请注意,如果你的项目使用C++,那么你也需要覆盖CXX
。
英文:
You likely need to pass -target arm-linux-gnueabi
as CFLAGS
/ CXXFLAGS
variable. Or, alternatively, you can just create a symbolic link from clang
to arm-linux-gnueabi-clang
. Note that if your project uses C++, then you'd need to override CXX
as well.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论