交叉编译树莓派 [英] Cross compiling raspberry pi

查看:197
本文介绍了交叉编译树莓派的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为我的树莓派交叉编译一个程序。我决定使用arm-linux-gnueabihf-gcc-7编译器,将/ usr和/ lib /复制到我的主机到目录〜/ raspberrypi / rootfs中,并设置一个配置如下的cmake:

i want to cross-compile a program for my raspberry pi. I decided to use the arm-linux-gnueabihf-gcc-7 compiler, copy /usr and /lib/ to my host into the directory ~/raspberrypi/rootfs and set up a cmake configurated as follows:

SET(CMAKE_SYSTEM_NAME Linux)
SET(CMAKE_SYSTEM_VERSION 1)

SET(CMAKE_FIND_ROOT_PATH $ENV{HOME}/raspberrypi/rootfs)
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

# Specify the cross compiler
SET(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc-7)
SET(CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++-7)

一切正常,直到我运行make,然后出现错误:

everything is working fine until i run make, then i get the error:

/usr/arm-linux-gnueabihf/include/sys/cdefs.h:467:49: error: missing binary operator before token "("
#if __GNUC_PREREQ (4,8) || __glibc_clang_prereq (3,5)
                                                 ^

以及更多相同类型的东西...

and some more of the same type...

任何人都知道那里出了什么问题吗?

Does anyone has an idea of what is going wrong there?

感谢您的帮助!

推荐答案

也许您的包含路径缺少(正确的)功能.h

Maybe your include paths is missing the (correct) features.h

使用Qt 5.15为Raspberry Pi交叉编译witgh QTCreator时遇到了相同的错误。

I ran into the same error when cross compiling witgh QTCreator using Qt 5.15 for Raspberry Pi.

添加pro文件中的 INCLUDEPATH + = somepath / sysroot / usr / include 对其进行了修复。也就是说,将目标计算机的 / usr / include 添加到包含路径。 (当然,请在您的系统上使用正确的sysroot路径...)

Adding INCLUDEPATH += somepath/sysroot/usr/include in the pro file fixed it. That is, add the /usr/include of the target machine to your include path. (Use the correct sysroot path on your system, of course...)

这篇关于交叉编译树莓派的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆