无法 #include在 Solaris 上

发布于 2024-11-01 08:24:53 字数 757 浏览 2 评论 0原文

我正在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

撩动你心 2024-11-08 08:24:53

只需从命令行中删除 -I/opt/csw/include 即可。

Just remove -I/opt/csw/include from your command line.

南街女流氓 2024-11-08 08:24:53

尝试运行应该包含在 gcc 安装中的 fixheadersfixincludes 命令之一。根据名称为 Solaris 8 构建的 gcc 软件包与您正在运行的 Solaris 版本(可能是 Solaris 10 或更高版本)之间可能不匹配。

Try running one of the fixheaders or fixincludes 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.

铜锣湾横着走 2024-11-08 08:24:53

您需要安装系统标头。

sudo pkg install system/header

You need to install the system headers.

sudo pkg install system/header
压抑⊿情绪 2024-11-08 08:24:53

无论有或没有 -I,都无法在 Solaris 10 x86 上重现:

-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) 

Can't reproduce on Solaris 10 x86, neither with nor without -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) 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文