使用LLVM在桌面上进行到ARM的交叉编译

3
我正在我的笔记本电脑上编写C代码,并希望使用llvm-clang工具链将其交叉编译到ARM v7架构。 我正在遵循此网站http://llvm.org/docs/HowToCrossCompileLLVM.html,使用以下命令配置cmake: 我正在使用以下命令,并收到以下错误(见下文)。 有任何想法是出了什么问题吗? 谢谢 开始
cmake -G Ninja /home/user/Desktop/llvm/llvm -DCMAKE_CROSSCOMPILING=True -DCMAKE_INSTALL_PREFIX=/home/user/Desktop/llvm/llvm/new_build -DLLVM_TABLEGEN=/usr/bin/host/llvm-tblgen -DCLANG_TABLEGEN=/usr/bin/host/clang-tblgen -DLLVM_DEFAULT_TARGET_TRIPLE=arm-linux-gnueabihf -DLLVM_TARGET_ARCH=ARM -DLLVM_TARGETS_TO_BUILD=ARM -DCMAKE_CXX_FLAGS='-target armv7a-linux-gnueabihf -mcpu=cortex-a9 -I/usr/arm-linux-gnueabihf/include/c++/4.7.2/arm-linux-gnueabihf/ -I/usr/arm-linux-gnueabihf/include/ -mfloat-abi=hard -ccc-gcc-name arm-linux-gnueabihf-gcc'
错误信息:

-- CXX编译器的标识是Clang 3.5.0 -- 使用Ninja检查工作的CXX编译器 -- 使用Ninja检查工作的CXX编译器 - 失败 CMakeTestCXXCompiler.cmake模块在第54行报错,提示C++编译器"/usr/bin/clang++"无法编译一个简单的测试程序。

以下是它的输出:

更改目录:/home/user/Desktop/llvm/llvm/new_build/CMakeFiles/CMakeTmp

运行构建命令:/usr/bin/ninja cmTryCompileExec1541562247

[1/2]构建CXX对象

CMakeFiles/cmTryCompileExec1541562247.dir/testCXXCompiler.cxx.o

[2/2] 链接 CXX 可执行文件 cmTryCompileExec1541562247

失败: : && /usr/bin/clang++ -target armv7a-linux-gnueabihf

-mcpu=cortex-a9

-I/usr/arm-linux-gnueabihf/include/c++/4.7.2/arm-linux-gnueabihf/

-I/usr/arm-linux-gnueabihf/include/ -mfloat-abi=hard -ccc-gcc-name

arm-linux-gnueabihf-gcc

CMakeFiles/cmTryCompileExec1541562247.dir/testCXXCompiler.cxx.o -o

cmTryCompileExec1541562247 -rdynamic && :

/usr/bin/ld: unrecognised emulation mode: armelf_linux_eabi

Supported emulations: elf_x86_64 elf32_x86_64 elf_i386 i386linux elf_l1om

elf_k1om i386pep i386pe

clang: error: linker command failed with exit code 1 (use -v to see

invocation)

ninja: build stopped: subcommand failed.

CMake将无法正确生成此项目。

调用堆栈(最近的调用在最上面):

CMakeLists.txt:19(project)

-- 配置不完整,出现错误!

------------------------------END-------------------------------------------------

1个回答

3
你使用了错误的指南。
你链接的网页是关于如何使用LLVM和Clang进行交叉编译的指南。但你不想编译LLVM本身,你只想使用它。对于这个问题,需要查看的指南是:http://clang.llvm.org/docs/CrossCompilation.html

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接