I am running centos 6 on a cluster. I installed the latest gcc-8.2.0. and made a link "ln -sf /usr/bin/gcc-8.2 gcc". I did the same for g++ and gfortran. I wanted to reinstall gcc-8.2.0 and went ahead to
make clean
in the gcc-8.2 directory. When I try
./configure
I get that C compiler cannot create executables The links I made are broken. The system gcc-4.4.7 cannot be found
which gcc
gives no gcc
sudo yum install gcc gcc-c++
gives gcc is already installed. I tried to install an rpm, which fails because of dependencies. I have pg compilers installed in /opt/pgi When I configure with
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
#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. On another linux PC with working gcc, the program works with the command
g++ hello.cpp -o hello
I will appreciate any assistance to either find the systemgcc or use pg compilers to compile gcc if possible
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". (Note that the ./configure referred to in earlier post was actually
../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
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. Then I was able to build 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. I have learnt a lot and very much appreciate the comments and guidelines of @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/
. Leave your package manager yum
to fill it -and never add anything inside it without yum
; so remove manually any symlinks you made there (by mistake)
reinstall the old system gcc
4.4 and g++
4.4 (using yum
)
rebuild your GCC 8 from scratch from its source code. Configure it with --program-suffix=-8
(but no --prefix
, or a --prefix=$HOME/soft/
if you don't have root access). 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...)
create a $HOME/bin/
if you don't have already one
be sure to have $HOME/bin/
early in your $PATH
(before /usr/bin/
)
add a symlink ln -sv /usr/local/bin/gcc-8 $HOME/bin/gcc
and likewise for g++
etc..
Then, when you type gcc
you are getting that symlink to /usr/local/bin/gcc-8
etc.
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/
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/
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:
First, we highly recommend that GCC be built into a separate directory from the sources which does not reside within the source tree.
(the "highly recommend" should be considered as a polite way to say "you absolutely should")
So your ./configure
was another mistake.
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).
PS. I don't know Redhat (used it only in the previous century). My favorite distro is Debian/testing or Debian/unstable (and my computers are desktops, not clusters).
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. It is very healthy and fit.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.