首页 文章

Clang / llvm:交叉编译时找不到crt1.o crti.o

提问于
浏览
0

我正在尝试使用clang / llvm在ARM上交叉编译示例hello world程序 .

我在连接方面遇到了一些问题 .

clang -target arm-none-linux-gnueabi hello.c

它显示了一些错误“ no such file or directory "stdio.h

所以为了避免错误,我给了以下命令 .

clang -target arm-none-linux-gnueabi -sysroot=/path/toolchain/ hello.c -I/path/toolchain/sysroot/usr/include/

然后我成功地过了错误,但我得到了链接错误 . 错误:“ no such file or directory crt1.o " " no such file or directory crti.o ”我导出了库路径,并在命令行中给出了路径,但没有任何对我有用 . 我发出以下命令 .

clang -target arm-none-linux-gnueabi -sysroot=/path/toolchain/ hello.c -I/path/toolchain/sysroot/usr/include/ -L/path/toolchain/sysroot/usr/lib

仍然是同样的错误“ no such file or directory crt1.o " " no such file or directory crti.o

期待任何帮助 . 我正在使用clang-3.0,后来我下载了预建的二进制文件并升级到了clang-3.3 . 提前致谢 . :)

1 回答

  • 0

    上述问题可以通过以下命令解决 .

    clang -target armv7-none-eabi -sysroot=/toolchain/path/to/sysroot/ hello.c -ccc-gcc-name arm-none-linux-gnueabi-gcc hello.c
    

    这里目标说clang编译器选择适当的目标 . sysroot说明了获取头文件和库的确切路径(无需提供包含和库路径)

相关问题