I'm using ubuntu18.04 on the server. I have already installed gcc-4.9 under the root, but now I want to install gcc-7.4 under my own directory, so I did the following things.
First I downloaded gcc-7.4.0.tar.gz
, and extracted it.Then cd gcc-7.4.0/
and then download prerequisites using command ./contrib/download_prerequisites
, then I run
mkdir build
and
cd build
I want to install gcc-7.4 under my directory without root, so I assigned prefix=/home/myusername/bin/
to compile. The complete command is as follow.
../configure --prefix=/home/xxx/bin --enable-shared --enable-threads=posix --enable-languages=c,c++,fortran --disable-multilib
but then I got an error.So I looked into the config.log
file ,which says:
Thread model: posix
gcc version 4.9.3 (Ubuntu 4.9.3-13ubuntu2)
configure:4314: $? = 0
configure:4303: gcc -V >&5
gcc: error: unrecognized command line option '-V'
gcc: fatal error: no input files
compilation terminated.
configure:4314: $? = 4
configure:4303: gcc -qversion >&5
gcc: error: unrecognized command line option '-qversion'
gcc: fatal error: no input files
compilation terminated.
configure:4314: $? = 4
configure:4334: checking for C compiler default output file name
configure:4356: gcc conftest.c >&5
gcc: error trying to exec 'cc1': execvp: No such file or directory
configure:4360: $? = 1
configure:4397: result:
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME ""
| #define PACKAGE_TARNAME ""
| #define PACKAGE_VERSION ""
| #define PACKAGE_STRING ""
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| /* end confdefs.h. */
|
| int
| main ()
| {
|
| ;
| return 0;
| }
configure:4403: error: in `/home/zxw/gcc-7.4.0/build':
configure:4407: error: C compiler cannot create executables
See `config.log' for more details.
it says C compiler cannot create executables
,and also trying to exec 'cc1': execvp: No such file or directory
. I searched both issues and referred to this one,but it doesn't help.
I am new to this and don't know exactly what's going on. Can anyone helps me? If you need more information, please tell me, I don't know what can I do to check it further.
update:
1.I can't install both versions system-wide, because I am preparing an environment on my lab's server which I don't have the root access. So this is why I tried to install the particular gcc version I need under my directory.
2. The reason why I need gcc-7.4.0 is because I'm preparing an environment for the detectron2
project, which is a project provided by Facebook and is used to learn object detection. And from the installation requirements of detectron2
, I need to prepare cuda
and gcc
first, I now have cuda-10.1
,ubuntu-18.04
,so I searched for which version of gcc do I need, and from the nvidia official website, it says the gcc version that matches cuda-10.1
and ubuntu-18.04
is and only is gcc-7.4
, so I am installing this particular version of gcc.
3.I'm sorry I don't know how the gcc-4.9
installed, the reason is the same as point 1, I am just a user of my lab's server, it has already been here since I joined the lab.
second update.
I followed this and tried again, the command I used are as below.
tar xzf gcc-7.4.0.tar.gz
cd gcc-7.4.0
./contrib/download_prerequisites
cd ..
mkdir objdir
cd objdir
/home/xxx/gcc-7.4.0/configure --prefix=/home/xxx/GCC-7.4.0
and then received the same error report.
I doubt there is something wrong with the existing gcc version, so I can't build a new version based on the previous gcc.