arm-linux-gnu-gcc致命错误:stdio.h:没有这样的文件或目录 [英] arm-linux-gnu-gcc fatal error: stdio.h: No such file or directory

查看:3028
本文介绍了arm-linux-gnu-gcc致命错误:stdio.h:没有这样的文件或目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这些是/ usr / bin中的文件

$ p $ [root @ xilinx bin]#ls -ld arm *
-rwxr-xr-x。 1 root root 691752 2013年2月5日arm-linux-gnu-addr2line
-rwxr-xr-x。 1 root root 721416 2013年2月5日arm-linux-gnu-ar
-rwxr-xr-x。 1 root root 1297632 Feb 5 2013 arm-linux-gnu-as
-rwxr-xr-x。 1根root 689168 2013年2月5日arm-linux-gnu-c ++ filt
-rwxr-xr-x。 1 root root 545664 Feb 6 2013 arm-linux-gnu-cpp
-rwxr-xr-x。 1 root root 34176 Feb 5 2013 arm-linux-gnu-elfedit
-rwxr-xr-x。 1 root root 544624 Feb 6 2013 arm-linux-gnu-gcc
-rwxr-xr-x。 1 root root 214400 Feb 6 2013 arm-linux-gnu-gcov
-rwxr-xr-x。 1根root 760640 2013年2月5日arm-linux-gnu-gprof
-rwxr-xr-x。 2 root root 1177528 Feb 5 2013 arm-linux-gnu-ld
-rwxr-xr-x。 2 root root 1177528 Feb 5 2013 arm-linux-gnu-ld.bfd
-rwxr-xr-x。 1根root 704672 2013年2月5日arm-linux-gnu-nm
-rwxr-xr-x。 1根root 875456 2013年2月5日arm-linux-gnu-objcopy
-rwxr-xr-x。 1 root root 1096992 2013年2月5日arm-linux-gnu-objdump
-rwxr-xr-x。 1 root root 721456 Feb 5 2013 arm-linux-gnu-ranlib
-rwxr-xr-x。 1 root root 389040 2013年2月5日arm-linux-gnu-readelf
-rwxr-xr-x。 1 root root 693608 Feb 5 2013 arm-linux-gnu-size
-rwxr-xr-x。 1 root root 691648 Feb 5 2013 arm-linux-gnu-strings
-rwxr-xr-x。 1 root root 875456 Feb 5 2013 arm-linux-gnu-strip

我正在关注本教程交叉编译一个简单的C程序:

  / * myinit.c 
*构建指令:
* $ {CROSS_COMPILE} gcc -static init.c -o init
* * /

#include< stdio.h>


main()
{
printf(\\\
);
printf(Hello world from%s!\\\
,__FILE__);
while(1){}
return 0;
}

现在我保存这个.c文件并尝试编译它;

  [root @ xilinx Xilinx-ZC702-14.7]#arm-linux-gnu-gcc myinit.c 
myinit .c:6:19:致命错误:stdio.h:没有这样的文件或目录
编译终止。

这只有在我使用arm-linux-gnu-gcc时才会发生。

但是当我使用gcc时,它工作正常。

为什么arm-linux *给出这个错误?

更新

  [root @ xilinx Xilinx-ZC702-14.7]#arm-linux-gnu-cpp -Wp,-v 
忽略不存在的目录/usr/lib/gcc/arm-linux-gnueabi/4.7.2/../ .. /../../arm-linux-gnueabi/sys-include
忽略不存在的目录/usr/lib/gcc/arm-linux-gnueabi/4.7.2/../../ .. /../arm-linux-gnueabi/include
#include...搜索从这里开始:
#include< ...>搜索从这里开始:
/usr/lib/gcc/arm-linux-gnueabi/4.7.2/include
/usr/lib/gcc/arm-linux-gnueabi/4.7.2/include-fixed
搜索列表结束。

详细

  [root @ xilinx Xilinx-ZC702-14.7]#arm-linux-gnu-gcc -v myinit.c 
使用内置规格。
COLLECT_GCC = arm-linux-gnu-gcc
COLLECT_LTO_WRAPPER = / usr / libexec / gcc / arm-linux-gnueabi / 4.7.2 / lto-wrapper
目标:arm-linux-gnueabi
配置为:../gcc-4.7.2-20121114-aarch64/configure --disable-dependency-tracking --disable-silent-rules --prefix = / usr --exec-prefix = / usr - -bindir = / usr / bin --sbindir = / usr / sbin --sysconfdir = / etc --datadir = / usr / share --includedir = / usr / include --libexecdir = / usr / libexec --localstatedir = / var --sharedstatedir = / var / lib --mandir = / usr / share / man --infodir = / usr / share / info --build = x86_64-redhat-linux-gnu --host = x86_64-redhat-linux- gnu --target = arm-linux-gnueabi --enable-targets = all --program-prefix = arm-linux-gnu- --enable-languages = c --with-newlib --without-headers --disable- sjlj-exceptions --with-system-libunwind --disable-nls --disable-threads --disable-shared --disable-libmudflap --disable-libssp --disable-libgomp --disable-libquadmath --disable-gold --disable-decimal-float --enable-checking = --enable-gnu-unique-object --enable-linker-build-id --disable-plugin --enable-nls --with-system-zlib --with-bugurl = http://bugzilla.redhat.com/bugzilla/ --enable-obsolete
线程模型:single
gcc version 4.7.2 20121105(Red Hat 4.7.2-2.aa.20121114svn)(GCC)
COLLECT_GCC_OPTIONS =' - v''-mtls-dialect = gnu'
/ usr / libexec /gcc/arm-linux-gnueabi/4.7.2/cc1 -quiet -v myinit.c -quiet -dumpbase myinit.c -mtls-dialect = gnu -auxbase myinit -version -o /tmp/ccZNNlzj.s
GNU C(GCC)版本4.7.2 20121105(Red Hat 4.7.2-2.aa.20121114svn)(arm-linux-gnueabi)
编译的GNU C版本4.4.6 20120305(Red Hat 4.4.6 -4),GMP版本4.3.1,MPFR版本2.4.1,MPC版本0.8
GGC启发式: - 参数ggc-min-expand = 100 - 参数ggc-min-heapsize = 131072
忽略不存在的目录/usr/lib/gcc/arm-linux-gnueabi/4.7.2/../../../../arm-linux-gnueabi/sys-include
忽略不存在的目录/usr/lib/gcc/arm-linux-gnueabi/4.7.2/../../../../arm-linux-gnueabi/include
#include...search从这里开始:
#include< ...>搜索从这里开始:
/usr/lib/gcc/arm-linux-gnueabi/4.7.2/include
/usr/lib/gcc/arm-linux-gnueabi/4.7.2/include-fixed
搜索列表结束。
GNU C(GCC)版本4.7.2 20121105(Red Hat 4.7.2-2.aa.20121114svn)(arm-linux-gnueabi)
由GNU C编译版本4.4.6 20120305(Red Hat 4.4.6-4),GMP版本4.3.1,MPFR版本2.4.1,MPC版本0.8
GGC启发式: - 参数ggc-min-expand = 100 - 参数ggc-min-heapsize = 131072
编译器可执行文件校验和:a19a7c6897fa348d9d5b59c718fa0648
myinit.c:6:19:致命错误:stdio.h:没有这样的文件或目录
编译终止。

主机配置

Redhat 6,64 bit

解决方案

这里的问题似乎是,你为目标安装了编译器工具链,但没有为目标安装标准库。您需要一个专门为您的目标平台编译的标准C库。您可以从您找到编译器工具链的相同位置找到预编译的代码,或者使用目标工具链下载并交叉编译。



当您有一个标准C库对于目标,使用标志 -I (即大写字母i)告诉编译器在哪里找到头文件, -L 标志来告诉链接器在哪里找到库,例如 -lc (这是小写的L)告诉链接器与库链接。就像

  $ arm-linux-gnu-gcc -I / usr / local / target / include myinit.c -L / usr / local / target / lib -lc 


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  721416 Feb  5  2013 arm-linux-gnu-ar
-rwxr-xr-x. 1 root root 1297632 Feb  5  2013 arm-linux-gnu-as
-rwxr-xr-x. 1 root root  689168 Feb  5  2013 arm-linux-gnu-c++filt
-rwxr-xr-x. 1 root root  545664 Feb  6  2013 arm-linux-gnu-cpp
-rwxr-xr-x. 1 root root   34176 Feb  5  2013 arm-linux-gnu-elfedit
-rwxr-xr-x. 1 root root  544624 Feb  6  2013 arm-linux-gnu-gcc
-rwxr-xr-x. 1 root root  214400 Feb  6  2013 arm-linux-gnu-gcov
-rwxr-xr-x. 1 root root  760640 Feb  5  2013 arm-linux-gnu-gprof
-rwxr-xr-x. 2 root root 1177528 Feb  5  2013 arm-linux-gnu-ld
-rwxr-xr-x. 2 root root 1177528 Feb  5  2013 arm-linux-gnu-ld.bfd
-rwxr-xr-x. 1 root root  704672 Feb  5  2013 arm-linux-gnu-nm
-rwxr-xr-x. 1 root root  875456 Feb  5  2013 arm-linux-gnu-objcopy
-rwxr-xr-x. 1 root root 1096992 Feb  5  2013 arm-linux-gnu-objdump
-rwxr-xr-x. 1 root root  721456 Feb  5  2013 arm-linux-gnu-ranlib
-rwxr-xr-x. 1 root root  389040 Feb  5  2013 arm-linux-gnu-readelf
-rwxr-xr-x. 1 root root  693608 Feb  5  2013 arm-linux-gnu-size
-rwxr-xr-x. 1 root root  691648 Feb  5  2013 arm-linux-gnu-strings
-rwxr-xr-x. 1 root root  875456 Feb  5  2013 arm-linux-gnu-strip

I am following this tutorial to cross compile a simple C program:

/* myinit.c
 * Build instructions:
 * ${CROSS_COMPILE}gcc -static init.c -o init
 * */

#include <stdio.h>

int
main ()
{
    printf ("\n");
    printf ("Hello world from %s!\n", __FILE__);
    while (1) { }
    return 0;
}

Now I save this is a .c file and try to compile it;

[root@xilinx Xilinx-ZC702-14.7]# arm-linux-gnu-gcc myinit.c 
myinit.c:6:19: fatal error: stdio.h: No such file or directory
compilation terminated.

This is hapening only when I am using arm-linux-gnu-gcc.

But when I am using gcc, it works fine.

Why is arm-linux* giving this error?

Update

[root@xilinx Xilinx-ZC702-14.7]# arm-linux-gnu-cpp -Wp,-v
ignoring nonexistent directory "/usr/lib/gcc/arm-linux-gnueabi/4.7.2/../../../../arm-linux-gnueabi/sys-include"
ignoring nonexistent directory "/usr/lib/gcc/arm-linux-gnueabi/4.7.2/../../../../arm-linux-gnueabi/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/arm-linux-gnueabi/4.7.2/include
 /usr/lib/gcc/arm-linux-gnueabi/4.7.2/include-fixed
End of search list.

Verbose

[root@xilinx Xilinx-ZC702-14.7]# arm-linux-gnu-gcc -v myinit.c 
Using built-in specs.
COLLECT_GCC=arm-linux-gnu-gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/arm-linux-gnueabi/4.7.2/lto-wrapper
Target: arm-linux-gnueabi
Configured with: ../gcc-4.7.2-20121114-aarch64/configure --disable-dependency-tracking --disable-silent-rules --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include --libexecdir=/usr/libexec --localstatedir=/var --sharedstatedir=/var/lib --mandir=/usr/share/man --infodir=/usr/share/info --build=x86_64-redhat-linux-gnu --host=x86_64-redhat-linux-gnu --target=arm-linux-gnueabi --enable-targets=all --program-prefix=arm-linux-gnu- --enable-languages=c --with-newlib --without-headers --disable-sjlj-exceptions --with-system-libunwind --disable-nls --disable-threads --disable-shared --disable-libmudflap --disable-libssp --disable-libgomp --disable-libquadmath --disable-gold --disable-decimal-float --enable-checking= --enable-gnu-unique-object --enable-linker-build-id --disable-plugin --enable-nls --with-system-zlib --with-bugurl=http://bugzilla.redhat.com/bugzilla/ --enable-obsolete
Thread model: single
gcc version 4.7.2 20121105 (Red Hat 4.7.2-2.aa.20121114svn) (GCC) 
COLLECT_GCC_OPTIONS='-v' '-mtls-dialect=gnu'
 /usr/libexec/gcc/arm-linux-gnueabi/4.7.2/cc1 -quiet -v myinit.c -quiet -dumpbase myinit.c -mtls-dialect=gnu -auxbase myinit -version -o /tmp/ccZNNlzj.s
GNU C (GCC) version 4.7.2 20121105 (Red Hat 4.7.2-2.aa.20121114svn) (arm-linux-gnueabi)
    compiled by GNU C version 4.4.6 20120305 (Red Hat 4.4.6-4), GMP version 4.3.1, MPFR version 2.4.1, MPC version 0.8
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/lib/gcc/arm-linux-gnueabi/4.7.2/../../../../arm-linux-gnueabi/sys-include"
ignoring nonexistent directory "/usr/lib/gcc/arm-linux-gnueabi/4.7.2/../../../../arm-linux-gnueabi/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/arm-linux-gnueabi/4.7.2/include
 /usr/lib/gcc/arm-linux-gnueabi/4.7.2/include-fixed
End of search list.
GNU C (GCC) version 4.7.2 20121105 (Red Hat 4.7.2-2.aa.20121114svn) (arm-linux-gnueabi)
    compiled by GNU C version 4.4.6 20120305 (Red Hat 4.4.6-4), GMP version 4.3.1, MPFR version 2.4.1, MPC version 0.8
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: a19a7c6897fa348d9d5b59c718fa0648
myinit.c:6:19: fatal error: stdio.h: No such file or directory
compilation terminated.

Host configuration

Redhat 6, 64 bit

解决方案

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

这篇关于arm-linux-gnu-gcc致命错误:stdio.h:没有这样的文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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