无法 #include在 Solaris 上
我正在 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'm working on Solaris x86 and have installed gcc4 using the OpenCSW packages. A simple test program below will not compile:
#include <stdio.h>
#include <stdlib.h>
main()
{
printf("Hello, world\n");
}
It builds and runs fine if I don't have the stdlib.h include. When stdlib.h is in I get the following errors:
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'
I think this might be some sort of conflict between OpenCSW and the default libraries, but I'm not sure how to fix it. Can anybody help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
只需从命令行中删除
-I/opt/csw/include
即可。Just remove
-I/opt/csw/include
from your command line.尝试运行应该包含在 gcc 安装中的
fixheaders
或fixincludes
命令之一。根据名称为 Solaris 8 构建的 gcc 软件包与您正在运行的 Solaris 版本(可能是 Solaris 10 或更高版本)之间可能不匹配。Try running one of the
fixheaders
orfixincludes
commands that should be part of your gcc installation. There is likely a mismatch between the gcc package which is built for Solaris 8 according to its name and the Solaris release you are running, presumably Solaris 10 or newer.您需要安装系统标头。
You need to install the system headers.
无论有或没有
-I
,都无法在 Solaris 10 x86 上重现:Can't reproduce on Solaris 10 x86, neither with nor without
-I
: