在 Oracle Solaris 11 上安装 GCC

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4664472/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 03:00:42  来源:igfitidea点击:

Installing GCC on Oracle Solaris 11

oraclegccsolaris

提问by killercode

i recently got Oracle Solaris on my VM to test some code on it, i was unable to install gcc since i dont really know how, i googled alot but all info is about oracle compilers, i needed GCC, any idea where can i get GCC or how to install it?

我最近在我的 VM 上安装了 Oracle Solaris 来测试它的一些代码,我无法安装 gcc,因为我真的不知道如何安装,我在谷歌上搜索了很多但所有信息都是关于 oracle 编译器的,我需要 GCC,知道在哪里可以获得 GCC或者如何安装它?

thanks

谢谢

回答by wkl

The original answer applied to Solaris 11 Express/non-official release - if you're doing this today with a full release of Solaris 11.x, use the pkg installcommand like you see in xavier'sresponse.

最初的答案适用于 Solaris 11 Express/非官方版本 - 如果您今天使用完整版本的 Solaris 11.x 执行此操作,请使用pkg install您在xavier 的回复中看到的命令。

Run this command from your terminal to install GCC.

从终端运行此命令以安装 GCC。

For GCC 3.4.x

对于 GCC 3.4.x

pkg install gcc-3

For GCC 4.5.x

对于 GCC 4.5.x

pkg install gcc-45

For GCC 4.7.x

对于 GCC 4.7.x

pkg install gcc-47

For GCC 4.8.x

对于 GCC 4.8.x

pkg install gcc-48

The gcccommand should then already be placed in your path /usr/bin/gcc, which is a symlink).

gcc命令应该已经放置在您的路径中/usr/bin/gcc,这是一个符号链接)。



Old AnswerSolaris 11 should already have gcc installed in /usr/sfw/bin/, but it's probably not in your PATH. Try this at the prompt: /usr/sfw/bin/gcc

旧答案Solaris 11 中应该已经安装了 gcc/usr/sfw/bin/,但它可能不在您的PATH. 在提示符下试试这个:/usr/sfw/bin/gcc

回答by xavier

Two steps:

两个步骤:

  1. pkg install gcc-45
  2. pkg install system/header
  1. pkg 安装 gcc-45
  2. pkg 安装系统/头文件

that is all

就这些

if you see more info http://blog.csdn.net/zjg555543/article/details/8217769

如果你看到更多信息 http://blog.csdn.net/zjg555543/article/details/8217769

回答by Fei

Just download gcc from its homepage, follow one of the mirror links to fetch the latest binary package (in .tar.gz or tar.bz2 format), and use traditional steps to build:

只需从其主页下载 gcc,按照镜像链接之一获取最新的二进制包(.tar.gz 或 tar.bz2 格式),并使用传统步骤构建:

  1. ./configure --<> // give your options
  2. make
  3. make install
  1. ./configure --<> // 给出你的选择
  2. 制作
  3. 进行安装

The good news is you can customize what you need and always stay with the latest, while bad part is you may lose the power to debug with mdb/adb - we are facing such problems with latest GCC 4.6.x

好消息是您可以自定义您需要的内容并始终使用最新版本,而不好的部分是您可能无法使用 mdb/adb 进行调试 - 我们在最新的 GCC 4.6.x 中面临此类问题

回答by 2sb

Solaris 10 and prior version :

Solaris 10 及之前的版本:

/usr/sfw/bin/gcc works.

/usr/sfw/bin/gcc 有效。

Solaris 11 :

Solaris 11:

pkg install gcc-3

pkg 安装 gcc-3

回答by jumping_monkey

My Solaris 2.11 does NOT have internet access:/

我的 Solaris 2.11无法访问互联网:/

What work for me:

什么对我有用:

(1) I use this linkas guideline
(2) From my windows machine, download gcc at one of their mirror sites, i used here, normally the closer the better
(3) Upload gcc-9.2.0.tar.gz to target /tmpdirectory using WinSCP
(4) tar -xvf gcc-9.2.0.tar.gz
(5) cd gcc-9.2.0
(6) mkdir /usr/local/gcc
(7) cd /usr/local/gcc
(8) /tmp/gcc-9.2.0/configure -v --program-suffix=9.2

(1) 我使用这个链接作为指导
(2) 从我的 windows 机器,在他们的镜像站点之一下载 gcc ,我在这里使用,通常越近越好
(3) 上传 gcc-9.2.0.tar.gz 到目标/tmp目录使用 WinSCP
(4) tar -xvf gcc-9.2.0.tar.gz
(5) cd gcc-9.2.0
(6) mkdir /usr/local/gcc
(7) cd /usr/local/gcc
( 8) /tmp/gcc-9.2.0/configure -v --program-suffix=9.2

At this point, you might get this error:
Building GCC requires GMP 4.2+, MPFR 2.4.0+ and MPC 0.8.0+.

此时,您可能会收到此错误:
构建 GCC 需要 GMP 4.2+、MPFR 2.4.0+ 和 MPC 0.8.0+。

(9) Manually download the required files here.
Note: To know what files are required, check contrib/download_prerequisites
(10)Copy over the files in (9) to /tmp/gcc-9.2.0
(11)Extract, then create shortcuts: ln -s gmp-6.1.0 gmp, ln -s mpc-1.0.3 mpc, ln -s mpfr-3.1.4 mpfr, ln -s isl-0.18 isl
(12)/tmp/gcc-9.2.0/configure -v --program-suffix=9.2 --enable-languages=c,c++ -v
(13) nohup gmake & (At this point it's going to take some time...mine took ~6 hours. Use -j option if you can, to gmake it faster )
(14) gmake install
(15) /usr/local/bin# ./gcc9.2 --version
gcc9.2 (GCC) 9.2.0 Copyright (C) 2019 Free Software Foundation, Inc.

(9)在这里手动下载所需的文件。
注意:要知道需要哪些文件,查看contrib/download_prerequisites
(10)Copy over the files in (9) to /tmp/gcc-9.2.0
(11)Extract,然后创建快捷方式:ln -s gmp-6.1.0 gmp, ln -s mpc-1.0.3 mpc, ln -s mpfr-3.1.4 mpfr, ln -s isl-0.18 isl
(12)/tmp/gcc-9.2.0/configure -v --program-suffix= 9.2 --enable-languages=c,c++ -v
(13) nohup gmake &(此时需要一些时间...我的需要大约 6 小时。如果可以,请使用 -j 选项,以使其更快)
(14) gmake install
(15) /usr/local/bin# ./gcc9.2 --version
gcc9.2 (GCC) 9.2.0 版权所有 (C) 2019 Free Software Foundation, Inc.

Voila! :-)

瞧!:-)

回答by Gene Vincent

You can install gcc 4.3 from OpenCSW:

您可以从 OpenCSW 安装 gcc 4.3:

pkg-get -i gcc4code gcc4g++

I also had to run mkheaders manually after the install.

安装后我还必须手动运行 mkheaders。

回答by Vijay Yande

pkg install gcc 

worked for me

对我来说有效

This will install entire gcc collection on your machine. Which anyways will be required

这将在您的机器上安装整个 gcc 集合。无论如何都需要

回答by Chamila Wijayarathna

I had the same problem and 'pkg install gcc-3' worked for me.

我遇到了同样的问题,“pkg install gcc-3”对我有用。

回答by peterh

I'll quote the answer from unix.stackexchange.com.

我将引用unix.stackexchange.com的答案。

On Solaris 11 gccis not installed by default. Normally you'll want more than just the compiler itself so my answer will include allthe usual suspects for building open source software on Solaris that you've downloaded from somewhere in source code format.

gcc默认情况下不安装Solaris 11 。通常,您需要的不仅仅是编译器本身,因此我的回答将包括在 Solaris 上构建开源软件的所有常见问题,这些软件是您从某处以源代码格式下载的。

By far the easiest is to use IPS to install it using the commands below (while being root or other superuser):

到目前为止,最简单的是使用 IPS 使用以下命令安装它(同时是 root 或其他超级用户):

pkg install pkg://solaris/developer/build/gnu-make \
            pkg://solaris/developer/build/make \
            pkg://solaris/developer/gcc \
            pkg://solaris/system/header \
            pkg://solaris/developer/build/autoconf \
            pkg://solaris/developer/build/automake

(I use fully qualified package names here, that is not really necessary)

(我在这里使用完全限定的包名,这不是必需的)

Note that some of the packages are available in the official repo in various versions. If you just reference developer/gccthen you'll at the time of writing this get GNU C v4.8.2, but you may explicitly ask for a prior version, e.g. by using package name such as developer/gcc-45.

请注意,某些软件包在各种版本的官方 repo 中可用。如果您只是参考,developer/gcc那么在撰写本文时您将获得 GNU C v4.8.2,但您可以明确要求提供先前版本,例如通过使用诸如developer/gcc-45.