1

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にアップグレードしました。前もって感謝します。:)

4

1 に答える 1

1

上記の質問は、次のコマンドで解決できます。

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

ここで target は、clang コンパイラが適切なターゲットを選択することを示します。sysroot は、ヘッダーとライブラリを取得するための正確なパスを示します (インクルードとライブラリのパスを提供する必要はありません)

于 2014-06-18T06:31:37.763 に答える