我正在 Solaris x86 上工作,并使用 OpenCSW 软件包安装了 gcc4。下面的简单测试程序将无法编译:
#include <stdio.h>
#include <stdlib.h>
main()
{
printf("Hello, world\n");
}
如果我没有包含 stdlib.h,它可以正常构建和运行。当 stdlib.h 存在时,我收到以下错误:
bash-3.00$ g++ -I/opt/csw/include test.cpp
In file included from /opt/csw/gcc4/lib/gcc/i386-pc-solaris2.8/4.3.3/include- fixed/stdlib.h:27,
from test.cpp:2:
/usr/include/iso/stdlib_iso.h:107: error: expected initializer before '__NORETURN'
/usr/include/iso/stdlib_iso.h:124: error: expected initializer before '__NORETURN'
/usr/include/iso/stdlib_iso.h:132: error: multiple parameters named '_RESTRICT_KYWD'
我认为这可能是 OpenCSW 和默认库之间的某种冲突,但我不确定如何修复它。有人可以帮忙吗?
只需从命令行中删除
-I/opt/csw/include
。
尝试运行应包含在 gcc 安装中的
fixheaders
或 fixincludes
命令之一。根据名称为 Solaris 8 构建的 gcc 软件包与您正在运行的 Solaris 版本(可能是 Solaris 10 或更高版本)之间可能不匹配。
无法在 Solaris 10 x86 上重现,无论有无
-I
:
-bash-3.00$ /opt/csw/gcc4/bin/g++ test.cpp
-bash-3.00$ /opt/csw/gcc4/bin/g++ -v
Using built-in specs.
Target: i386-pc-solaris2.10
Configured with: ../gcc-4.3.3/configure --prefix=/opt/csw/gcc4 --exec-prefix=/opt/csw/gcc4 --with-gnu-as --with-as=/opt/csw/bin/gas --without-gnu-ld --with-ld=/usr/ccs/bin/ld --enable-nls --with-included-gettext --with-libiconv-prefix=/opt/csw --with-x --with-mpfr=/opt/csw --with-gmp=/opt/csw --enable-java-awt=xlib --enable-libada --enable-libssp --enable-objc-gc --enable-threads=posix --enable-stage1-languages=c --enable-languages=ada,c,c++,fortran,java,objc
Thread model: posix
gcc version 4.3.3 (GCC)
您需要安装标头:
sudo pkg install system/header