arm-linux-gnu-gcc fatal error: stdio.h: No such file or directory

前端 未结 3 941
我在风中等你
我在风中等你 2020-12-18 00:23

These are the files in /usr/bin

[root@xilinx bin]# ls -ld arm*
-rwxr-xr-x. 1 root root  691752 Feb  5  2013 arm-linux-gnu-addr2line
-rwxr-xr-x. 1 root root          


        
相关标签:
3条回答
  • 2020-12-18 00:37

    The problem here, it seems, is that you installed the compiler toolchain for the target, but didn't install a standard library for the target. You need a standard C library compiled specifically for your target platform. Either find a pre-compiled from the same place you found the compiler toolchain, or download one and cross-compile using the target toolchain.

    When you have a standard C library for the target, use the flag -I (that's uppercase i) to tell the compiler where to find the header files, and the -L flag to tell the linker where to find the libraries, and e.g. -lc (that's the lower-case L) to tell the linker to link with the library. Something like

    $ arm-linux-gnu-gcc -I/usr/local/target/include myinit.c -L/usr/local/target/lib -lc
    
    0 讨论(0)
  • 2020-12-18 00:47

    This got fixed for me by installing "arm-none-eabi-newlib"

    $ sudo yum install arm-none-eabi-newlib
    

    It contained the required files in the right path.

    0 讨论(0)
  • 2020-12-18 01:02

    The most likely issue here is that the sysroot path wasn't set when this cross compiler was generated. The toolchain developers have their own reasons for doing so. You can confirm by doing

    $ arm-linux-gnu-gcc -print-sysroot
     /not/exist
    

    The toolchain developers expect us to use the standard environment variables such as ${CXX} ${CC} to cross compile. They would usually have a script provided for this purpose that among other things does the following.

    $ export SDKTARGETSYSROOT=/path/to/sysroots/armv7at2hf-neon-fslc-linux-gnueabi
    
    $ export CC="arm-linux-gnu-gcc -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard --sysroot=$SDKTARGETSYSROOT"
    

    So, for compiling your *.c program, in this case, myinit.c, you would do.

    $ ${CC} myinit.c
    

    Or if you like me are old school would do

    $ arm-linux-gnu-gcc -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard --sysroot=$SDKTARGETSYSROOT myinit.c
    
    0 讨论(0)
提交回复
热议问题