我安装gcc-3.4
到Debian 7.8
并创建了符号链接/usr/bin/gcc
。当我输入时,gcc --version
我得到:
gcc (GCC) 3.4.6 (Debian 3.4.6.-9)
然后我写了简单的 C 程序。
#include <stdio.h>
int main(int argc, char **argv)
{
printf("hello");
return 0;
}
但我收到大量错误消息。我认为问题在于gcc-3.4
使用gcc-4.7
(系统上的默认 gcc)头文件。我gcc-3.4
从以下位置下载gcc 网站并输入:
gcc untitled.c -I/home/asd/Desktop/gcc-3.4
但不起作用。如何gcc-3.4
在编译时使用头文件?
错误开始如下
In file included from /usr/include/stdio.h:28,
from untitled.c:1:
/usr/include/features.h:323:26: bits/predefs.h: No such file or directory
/usr/include/features.h:356:25: sys/cdefs.h: No such file or directory
/usr/include/features.h:388:23: gnu/stubs.h: No such file or directory
In file included from /usr/include/stdio.h:34,
from untitled.c:1:
/usr/lib/gcc/i486-linux-gnu/3.4.6/include/stddef.h:213: error: syntax error before "typedef"
In file included from untitled.c:1:
/usr/include/stdio.h:36:25: bits/types.h: No such file or directory
In file included from untitled.c:1:
/usr/include/stdio.h:49: error: syntax error before "typedef"
/usr/include/stdio.h:54: error: syntax error before "__USING_NAMESPACE_STD"
/usr/include/stdio.h: In function `__USING_NAMESPACE_STD':
/usr/include/stdio.h:65: error: storage class specified for parameter `__FILE'
In file included from /usr/include/_G_config.h:20,
from /usr/include/libio.h:32,
from /usr/include/stdio.h:75,
from untitled.c:1:
/usr/include/wchar.h:95: error: storage class specified for parameter `__mbstate_t'
In file included from /usr/include/libio.h:32,
from /usr/include/stdio.h:75,
from untitled.c:1:
/usr/include/_G_config.h:24: error: syntax error before "__off_t"
/usr/include/_G_config.h:29: error: syntax error before "__off64_t"
/usr/include/_G_config.h:53: error: storage class specified for parameter `_G_int16_t'
/usr/include/_G_config.h:54: error: storage class specified for parameter `_G_int32_t'
/usr/include/_G_config.h:55: error: storage class specified for parameter `_G_uint16_t'
/usr/include/_G_config.h:56: error: storage class specified for parameter `_G_uint32_t'
In file included from /usr/include/libio.h:53,
from /usr/include/stdio.h:75,
from untitled.c:1:
/usr/lib/gcc/i486-linux-gnu/3.4.6/include/stdarg.h:43: error: storage class specified for parameter `__gnuc_va_list'
In file included from /usr/include/stdio.h:75,
from untitled.c:1:
/usr/include/libio.h:180: error: storage class specified for parameter `_IO_lock_t'
/usr/include/libio.h:300: error: syntax error before "__off_t"
/usr/include/libio.h:310: error: syntax error before "_IO_lock_t"
/usr/include/libio.h:338: error: syntax error before '}' token
/usr/include/libio.h:341: error: storage class specified for parameter `_IO_FILE'
/usr/include/libio.h:346: error: storage class specified for parameter `_IO_2_1_stdin_'
/usr/include/libio.h:347: error: storage class specified for parameter `_IO_2_1_stdout_'
/usr/include/libio.h:348: error: storage class specified for parameter `_IO_2_1_stderr_'
/usr/include/libio.h:364: error: storage class specified for parameter `__ssize_t'
/usr/include/libio.h:364: error: syntax error before "__io_read_fn"
/usr/include/libio.h:372: error: storage class specified for parameter `__ssize_t'
/usr/include/libio.h:372: error: redefinition of parameter '__ssize_t'
/usr/include/libio.h:364: error: previous definition of '__ssize_t' was here
运行 gcc 的完整输出可以在以下位置找到:http://pastebin.com/jFRihqUw
答案1
安装 gcc & g++ 例如在 linux kali 中在终端运行此命令
apt-get 安装 gcc g++
然后用正确的路径替换路径在我的情况下正确的路径是
arm-linux-gnueabihf/bits/predefs.h
答案2
安装 gcc & g++ 例如在 linux kali 中在终端运行此命令
apt-get 安装 gcc g++
对于 ubuntu,在 apt 之前使用 sudo 然后将路径替换为正确的路径 就我而言arm-linux-gnueabihf/bits/predefs.h>
因为我有 arm 基座设备请按照此操作以查找下一个路径错误但这样做会得到几个路径问题所以最好的方法是
复制asm、位、系统 &如果获取路径错误则其他文件夹包括文件夹来自arm-linux-gnueabihf文件夹