当前位置: 技术问答>linux和unix
ubuntu11.10的gcc版本降级后
来源: 互联网 发布时间:2017-02-14
本文导语: 原来的gcc版本是4.6.1,我换了一个3.4.6的,结果编译c文件的时候出问题了。比如我在一个test.c里包含string.h,编译后: /usr/include/string.h:44: error: syntax error before "extern" /usr/include/string.h:46: error: syntax error before ...
原来的gcc版本是4.6.1,我换了一个3.4.6的,结果编译c文件的时候出问题了。比如我在一个test.c里包含string.h,编译后:
/usr/include/string.h:44: error: syntax error before "extern"
/usr/include/string.h:46: error: syntax error before "__THROW"
/usr/include/string.h:50: error: syntax error before "__THROW"
/usr/include/string.h:57: error: syntax error before "extern"
/usr/include/string.h:59: error: syntax error before "__THROW"
/usr/include/string.h:65: error: syntax error before "extern"
/usr/include/string.h:65: error: syntax error before "__THROW"
/usr/include/string.h:69: error: syntax error before "__THROW"
/usr/include/string.h:96: error: syntax error before "__THROW"
/usr/include/string.h:128: error: syntax error before "extern"
/usr/include/string.h:129: error: syntax error before "__THROW"
/usr/include/string.h:133: error: syntax error before "__THROW"
/usr/include/string.h:137: error: syntax error before "__THROW"
/usr/include/string.h:140: error: syntax error before "__THROW"
/usr/include/string.h:144: error: syntax error before "__THROW"
/usr/include/string.h:147: error: syntax error before "__THROW"
/usr/include/string.h:151: error: syntax error before "__THROW"
/usr/include/string.h:155: error: syntax error before "__THROW"
本来这之前还有错了,说是有3个头文件不存在,然后我网上找了下放进去了。后来再没有说过这3个头文件的问题了,不过后面还有一些错误提示信息说有一些头文件是不存在的。
除了string.h,我们常用的stdio.h等文件也有和string.h同样的问题。
我看了一下我的gcc-3.4.6的配置:
administrator@ubuntu:/windows/sda7$ gcc -v
Reading specs from /usr/lib/gcc/i486-linux-gnu/3.4.6/specs
Configured with: ../src/configure -v --enable-languages=c,c++,f77,pascal --prefix=/usr --libexecdir=/usr/lib --with-gxx-include-dir=/usr/include/c++/3.4 --enable-shared --with-system-zlib --enable-nls --without-included-gettext --program-suffix=-3.4 --enable-__cxa_atexit --enable-clocale=gnu --enable-libstdcxx-debug --with-tune=pentium4 i486-linux-gnu
Thread model: posix
gcc version 3.4.6 (Ubuntu 3.4.6-6ubuntu3)
administrator@ubuntu:/windows/sda7$
看不出有什么毛病。。
这个该怎么解决呢?
/usr/include/string.h:44: error: syntax error before "extern"
/usr/include/string.h:46: error: syntax error before "__THROW"
/usr/include/string.h:50: error: syntax error before "__THROW"
/usr/include/string.h:57: error: syntax error before "extern"
/usr/include/string.h:59: error: syntax error before "__THROW"
/usr/include/string.h:65: error: syntax error before "extern"
/usr/include/string.h:65: error: syntax error before "__THROW"
/usr/include/string.h:69: error: syntax error before "__THROW"
/usr/include/string.h:96: error: syntax error before "__THROW"
/usr/include/string.h:128: error: syntax error before "extern"
/usr/include/string.h:129: error: syntax error before "__THROW"
/usr/include/string.h:133: error: syntax error before "__THROW"
/usr/include/string.h:137: error: syntax error before "__THROW"
/usr/include/string.h:140: error: syntax error before "__THROW"
/usr/include/string.h:144: error: syntax error before "__THROW"
/usr/include/string.h:147: error: syntax error before "__THROW"
/usr/include/string.h:151: error: syntax error before "__THROW"
/usr/include/string.h:155: error: syntax error before "__THROW"
本来这之前还有错了,说是有3个头文件不存在,然后我网上找了下放进去了。后来再没有说过这3个头文件的问题了,不过后面还有一些错误提示信息说有一些头文件是不存在的。
除了string.h,我们常用的stdio.h等文件也有和string.h同样的问题。
我看了一下我的gcc-3.4.6的配置:
administrator@ubuntu:/windows/sda7$ gcc -v
Reading specs from /usr/lib/gcc/i486-linux-gnu/3.4.6/specs
Configured with: ../src/configure -v --enable-languages=c,c++,f77,pascal --prefix=/usr --libexecdir=/usr/lib --with-gxx-include-dir=/usr/include/c++/3.4 --enable-shared --with-system-zlib --enable-nls --without-included-gettext --program-suffix=-3.4 --enable-__cxa_atexit --enable-clocale=gnu --enable-libstdcxx-debug --with-tune=pentium4 i486-linux-gnu
Thread model: posix
gcc version 3.4.6 (Ubuntu 3.4.6-6ubuntu3)
administrator@ubuntu:/windows/sda7$
看不出有什么毛病。。
这个该怎么解决呢?
|
gcc 向下兼容还可以,你试试4.x应该也能编译
你的问题是libstdc++的版本比gcc高太多了,这两个货是一个包里的,跨版本可能有问题
你真想用3.4.6,那就烦请自己制定c++头文件的目录
你的问题是libstdc++的版本比gcc高太多了,这两个货是一个包里的,跨版本可能有问题
你真想用3.4.6,那就烦请自己制定c++头文件的目录