简体   繁体   English

如何在centos 6上恢复系统gcc编译器

[英]How to recover system gcc compiler on centos 6

I am running centos 6 on a cluster. 我在群集上运行centos 6。 I installed the latest gcc-8.2.0. 我安装了最新的gcc-8.2.0。 and made a link "ln -sf /usr/bin/gcc-8.2 gcc". 并建立了一个链接“ ln -sf /usr/bin/gcc-8.2 gcc”。 I did the same for g++ and gfortran. 我对g ++和gfortran做了同样的事情。 I wanted to reinstall gcc-8.2.0 and went ahead to 我想重新安装gcc-8.2.0并继续

make clean

in the gcc-8.2 directory. 在gcc-8.2目录中。 When I try 当我尝试

./configure

I get that C compiler cannot create executables The links I made are broken. 我知道C编译器无法创建可执行文件我建立的链接已损坏。 The system gcc-4.4.7 cannot be found 找不到系统gcc-4.4.7

which gcc

gives no gcc 没有给出gcc

sudo yum install gcc gcc-c++

gives gcc is already installed. 给出gcc已经安装。 I tried to install an rpm, which fails because of dependencies. 我尝试安装rpm,但由于依赖关系而失败。 I have pg compilers installed in /opt/pgi When I configure with 我在/ opt / pgi中安装了pg编译器

CC=/path to/pgi/bin/pgcc FC=/path to/pgi/bin/pgfortran ./configure

I still get C compiler cannot create executables I tried the following c++ programm 我仍然得到C编译器无法创建可执行文件我尝试了以下C ++程序

#include <iostream>
using namespace std;
int main() {
cout << "Hello world!" << endl;
return 0;
}

With the command 用命令

/opt/pgi/linux_86_64/12.08/bin/pgcpp hello.cpp -o hello

It gives compilation error that float.h not found. 它给出了未找到float.h的编译错误。 On another linux PC with working gcc, the program works with the command 在另一台运行gcc的linux PC上,该程序可以使用以下命令

g++ hello.cpp -o hello

I will appreciate any assistance to either find the systemgcc or use pg compilers to compile gcc if possible 如果可以的话,我将不胜感激地协助您找到systemgcc或使用pg编译器来编译gcc

I admit it is a big mess which will require OS reinstallation and reconfiguration. 我承认这是一个大混乱,需要重新安装和重新配置操作系统。 But then I did 但是后来我做到了

sudo yum install compat-gcc-34

Now I have gcc34 and configure of gcc-8.2 goes through without "c compiler cannot create executables". 现在我有了gcc34并完成了gcc-8.2的配置,而没有“ c编译器无法创建可执行文件”。 (Note that the ./configure referred to in earlier post was actually (请注意,先前文章中提到的./configure实际上是

../gcc_8_2_release/configure

inside "gcc_8_2_release_build, so gcc was not being built in its source directory. The problem I have now is with make, which needs g++, giving error 在“ gcc_8_2_release_build”内部,因此gcc尚未在其源目录中构建。我现在遇到的问题是make,它需要g ++,给出错误

uint_t(64) or int_t(64) not found.

Thanks all who have gone through this post, for your patience. 感谢所有通过这篇文章的人的耐心配合。 Any assistance will be appreciated. 任何帮助将不胜感激。

Here is how I got out of this mess. 这就是我摆脱困境的方法。 With the following two commands 用以下两个命令

sudo yum install compat-gcc-34-c++
sudo yum install compat-gcc-34-g77

I was able to install the older version of gcc, c++ and g77. 我能够安装旧版本的gcc,c ++和g77。 Then I was able to build gcc-8.2. 然后,我能够构建gcc-8.2。 Now I have a functional system with the latest gcc, yes it may need re-installation/re-configuring but it is fully functional. 现在,我有了一个带有最新gcc的功能系统,是的,它可能需要重新安装/重新配置,但功能齐全。 I have learnt a lot and very much appreciate the comments and guidelines of @Basile. 我学到了很多东西,非常感谢@Basile的评论和指南。 However, at one point he was rather negative and discouraging. 但是,有一点他很消极并且沮丧。 But thanks to my belief and perseverance, and more importantly browsing the knowledge shared by others, I have been able to recover what I was beginning to be convinced was a lost cause. 但是由于我的信念和毅力,更重要的是浏览了其他人共享的知识,我才得以恢复我开始被认为是失败的事业。 Thanks all. 谢谢大家

This is more a sysadmin question than a programming one. 这比编程问题更多是系统管理员问题。

My recommendations: 我的建议:

  • don't mess your /usr/bin/ . 不要弄乱您的/usr/bin/ Leave your package manager yum to fill it -and never add anything inside it without yum ; 让软件包管理器yum填充它-切勿在没有yum情况下在其中添加任何东西; so remove manually any symlinks you made there (by mistake) 因此,请手动删除您在此处所做的任何符号链接(错误)

  • reinstall the old system gcc 4.4 and g++ 4.4 (using yum ) 重新安装旧系统gcc 4.4和g++ 4.4(使用yum

  • rebuild your GCC 8 from scratch from its source code. 从源代码重新构建GCC 8。 Configure it with --program-suffix=-8 (but no --prefix , or a --prefix=$HOME/soft/ if you don't have root access). 使用--program-suffix=-8 (但没有--prefix--prefix=$HOME/soft/如果没有root访问权限)来配置它。 So it will install /usr/local/bin/gcc-8 and /usr/local/bin/g++-8 etc... (or, if you have given --prefix=$HOME/soft/ , a $HOME/soft/bin/gcc-8 etc...) 因此它将安装/usr/local/bin/gcc-8/usr/local/bin/g++-8等...(或者,如果给定--prefix=$HOME/soft/$HOME/soft/bin/gcc-8等...)

  • create a $HOME/bin/ if you don't have already one 如果您还没有一个,创建一个$HOME/bin/

  • be sure to have $HOME/bin/ early in your $PATH (before /usr/bin/ ) 确保在$PATH 早期 (在/usr/bin/ )有$HOME/bin/

  • add a symlink ln -sv /usr/local/bin/gcc-8 $HOME/bin/gcc and likewise for g++ etc.. 添加一个符号链接ln -sv /usr/local/bin/gcc-8 $HOME/bin/gcc ,同样对于g++等。

Then, when you type gcc you are getting that symlink to /usr/local/bin/gcc-8 etc. 然后,当您键入gcc您将获得指向/usr/local/bin/gcc-8等的符号链接。

If you cannot write to /usr/local/ (eg because you don't have root permission...) you could pass --prefix=$HOME/soft/ to GCC 8 .../configure then replace /usr/local/ above with $HOME/soft/ 如果您无法写入/usr/local/ (例如,因为您没有root权限...),则可以将--prefix=$HOME/soft/传递给GCC 8 .../configure然后替换/usr/local/以上使用$HOME/soft/

If you are the sysadmin and can write to /usr/local/ and have to set up things for many users: add a symlink ln -s /usr/local/bin/gcc-8 /usr/local/bin/gcc etc and ask your users to put /usr/local/bin/ in their $PATH before /usr/bin/ 如果您是sysadmin,并且可以写到/usr/local/并且必须为许多用户进行设置:添加一个符号链接ln -s /usr/local/bin/gcc-8 /usr/local/bin/gcc等,然后要求您的用户将/usr/local/bin/放在 $PATH之前的/usr/bin/

BTW, notice that it is explicitly documented that GCC 8 (or others) need to be built outside of its source tree: in Installing GCC you can read: 顺便说一句,请注意, 明确记录了GCC 8(或其他)需要其源代码树之外构建:在安装GCC中,您可以阅读:

First, we highly recommend that GCC be built into a separate directory from the sources which does not reside within the source tree. 首先,我们强烈建议将GCC建在与源代码不同的目录中,该目录不位于源代码树中。

(the "highly recommend" should be considered as a polite way to say "you absolutely should") (“强烈推荐”应被视为礼貌地说“您绝对应该”)

So your ./configure was another mistake. 因此,您的./configure是另一个错误。

It could happen that you messed up your system more seriously than you thought (and perhaps you need to reinstall, or to call Redhat support). 您可能会以比您想象的更严重的方式弄乱系统 (也许您需要重新安装或致电Redhat支持人员)。

PS. PS。 I don't know Redhat (used it only in the previous century). 我不知道Redhat(仅在上个世纪使用过)。 My favorite distro is Debian/testing or Debian/unstable (and my computers are desktops, not clusters). 我最喜欢的发行版是Debian / testing或Debian / unstable(我的计算机是台式机,而不是群集)。

This problem was solved by the following commands 通过以下命令解决了该问题

sudo yum install compat-gcc-34-c++
sudo yum install compat-gcc-34-g77

Once this older version of gcc is installed, the latest version, gcc-8.2 was built and the system is no longer messed terribly. 一旦安装了较旧版本的gcc,便会构建最新版本的gcc-8.2,并且系统不会再变得混乱不堪。 It is very healthy and fit. 这是非常健康和健康。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM