简体   繁体   中英

Cross compiling raspberry pi

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)

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?

Thanks for helping!

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

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

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...)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM