Я получаю ответ /root/gcc-4.8.2/bin: нет такого файла или каталога, когда я устанавливаю путь в bash.rc

592
a_sid

У меня уже был gcc 4.4.7 в моей системе. Моя система RHEL 6.6.

[root@gksrv Desktop]# gcc --version gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-18) Copyright (C) 2010 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 

Я хочу обновить до gcc-4.8.2, и я прошел все шаги для установки его в моей системе.

Последняя часть вывода, который я получил после ввода, make installвыглядит следующим образом:

 Libraries have been installed in: /root/gcc-4.8.2/lib/../lib64  If you ever happen to want to link against installed libraries in a given directory, LIBDIR, you must either use libtool, and specify the full pathname of the library, or use the `-LLIBDIR' flag during linking and do at least one of the following: - add LIBDIR to the `LD_LIBRARY_PATH' environment variable during execution - add LIBDIR to the `LD_RUN_PATH' environment variable during linking - use the `-Wl,-rpath -Wl,LIBDIR' linker flag - have your system administrator add LIBDIR to `/etc/ld.so.conf'  See any operating system documentation about shared libraries for more information, such as the ld(1) and ld.so(8) manual pages. ---------------------------------------------------------------------- test -z "/root/gcc-4.8.2/share/info" || /bin/mkdir -p "/root/gcc-4.8.2/share/info" /usr/bin/install -c -m 644 /root/Downloads/objdir/../gcc-4.8.2/libgomp/libgomp.info '/root/gcc-4.8.2/share/info' install-info --info-dir='/root/gcc-4.8.2/share/info' '/root/gcc-4.8.2/share/info/libgomp.info' test -z "/root/gcc-4.8.2/lib/gcc/x86_64-unknown-linux-gnu/4.8.2/finclude" || /bin/mkdir -p "/root/gcc-4.8.2/lib/gcc/x86_64-unknown-linux-gnu/4.8.2/finclude" /usr/bin/install -c -m 644 omp_lib.h omp_lib.f90 omp_lib.mod omp_lib_kinds.mod '/root/gcc-4.8.2/lib/gcc/x86_64-unknown-linux-gnu/4.8.2/finclude' test -z "/root/gcc-4.8.2/lib/gcc/x86_64-unknown-linux-gnu/4.8.2/include" || /bin/mkdir -p "/root/gcc-4.8.2/lib/gcc/x86_64-unknown-linux-gnu/4.8.2/include" /usr/bin/install -c -m 644 omp.h '/root/gcc-4.8.2/lib/gcc/x86_64-unknown-linux-gnu/4.8.2/include' make[4]: Leaving directory `/root/Downloads/objdir/x86_64-unknown-linux-gnu/libgomp' make[3]: Leaving directory `/root/Downloads/objdir/x86_64-unknown-linux-gnu/libgomp' make[2]: Leaving directory `/root/Downloads/objdir/x86_64-unknown-linux-gnu/libgomp' make[2]: Entering directory `/root/Downloads/objdir/x86_64-unknown-linux-gnu/libitm' Making install in testsuite make[3]: Entering directory `/root/Downloads/objdir/x86_64-unknown-linux-gnu/libitm/testsuite' make[4]: Entering directory `/root/Downloads/objdir/x86_64-unknown-linux-gnu/libitm/testsuite' make[4]: Nothing to be done for `install-exec-am'. make[4]: Nothing to be done for `install-data-am'. make[4]: Leaving directory `/root/Downloads/objdir/x86_64-unknown-linux-gnu/libitm/testsuite' make[3]: Leaving directory `/root/Downloads/objdir/x86_64-unknown-linux-gnu/libitm/testsuite' make[3]: Entering directory `/root/Downloads/objdir/x86_64-unknown-linux-gnu/libitm' true DO=all multi-do # make make[4]: Entering directory `/root/Downloads/objdir/x86_64-unknown-linux-gnu/libitm' true DO=install multi-do # make test -z "/root/gcc-4.8.2/lib/../lib64" || /bin/mkdir -p "/root/gcc-4.8.2/lib/../lib64" /usr/bin/install -c -m 644 libitm.spec '/root/gcc-4.8.2/lib/../lib64' test -z "/root/gcc-4.8.2/lib/../lib64" || /bin/mkdir -p "/root/gcc-4.8.2/lib/../lib64" /bin/sh ./libtool --mode=install /usr/bin/install -c libitm.la '/root/gcc-4.8.2/lib/../lib64' libtool: install: /usr/bin/install -c .libs/libitm.so.1.0.0 /root/gcc-4.8.2/lib/../lib64/libitm.so.1.0.0 libtool: install: (cd /root/gcc-4.8.2/lib/../lib64 && { ln -s -f libitm.so.1.0.0 libitm.so.1 || { rm -f libitm.so.1 && ln -s libitm.so.1.0.0 libitm.so.1; }; }) libtool: install: (cd /root/gcc-4.8.2/lib/../lib64 && { ln -s -f libitm.so.1.0.0 libitm.so || { rm -f libitm.so && ln -s libitm.so.1.0.0 libitm.so; }; }) libtool: install: /usr/bin/install -c .libs/libitm.lai /root/gcc-4.8.2/lib/../lib64/libitm.la libtool: install: /usr/bin/install -c .libs/libitm.a /root/gcc-4.8.2/lib/../lib64/libitm.a libtool: install: chmod 644 /root/gcc-4.8.2/lib/../lib64/libitm.a libtool: install: ranlib /root/gcc-4.8.2/lib/../lib64/libitm.a libtool: finish: PATH="/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-1.b13.el6.x86_64/bin:/usr/lib64/qt-3.3/bin:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-1.b13.el6.x86_64/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/usr/apache/apache-ant-1.9.9/bin:/root/bin:/usr/apache/apache-ant-1.9.9/bin:/sbin" ldconfig -n /root/gcc-4.8.2/lib/../lib64 ldconfig: /root/gcc-4.8.2/lib/../lib64/libstdc++.so.6.0.18-gdb.py is not an ELF file - it has the wrong magic bytes at the start.  ---------------------------------------------------------------------- Libraries have been installed in: /root/gcc-4.8.2/lib/../lib64  If you ever happen to want to link against installed libraries in a given directory, LIBDIR, you must either use libtool, and specify the full pathname of the library, or use the `-LLIBDIR' flag during linking and do at least one of the following: - add LIBDIR to the `LD_LIBRARY_PATH' environment variable during execution - add LIBDIR to the `LD_RUN_PATH' environment variable during linking - use the `-Wl,-rpath -Wl,LIBDIR' linker flag - have your system administrator add LIBDIR to `/etc/ld.so.conf'  See any operating system documentation about shared libraries for more information, such as the ld(1) and ld.so(8) manual pages. ---------------------------------------------------------------------- test -z "/root/gcc-4.8.2/share/info" || /bin/mkdir -p "/root/gcc-4.8.2/share/info" /usr/bin/install -c -m 644 /root/Downloads/objdir/../gcc-4.8.2/libitm/libitm.info '/root/gcc-4.8.2/share/info' install-info --info-dir='/root/gcc-4.8.2/share/info' '/root/gcc-4.8.2/share/info/libitm.info' make[4]: Leaving directory `/root/Downloads/objdir/x86_64-unknown-linux-gnu/libitm' make[3]: Leaving directory `/root/Downloads/objdir/x86_64-unknown-linux-gnu/libitm' make[2]: Leaving directory `/root/Downloads/objdir/x86_64-unknown-linux-gnu/libitm' make[1]: Leaving directory `/root/Downloads/objdir' 

Однако после ввода gcc -v я обнаружил, что компилятор не был заменен:

 [root@gksrv objdir]# gcc -v Using built-in specs. Target: x86_64-redhat-linux Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux Thread model: posix gcc version 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC)  

Я попытался установить путь как root. Я набрал vim .bashrcи я прибыл в это окно:

# .bashrc  # User specific aliases and functions  alias rm='rm -i' alias cp='cp -i' alias mv='mv -i'  # Source global definitions if [ -f /etc/bashrc ]; then . /etc/bashrc fi  if [ -d "/opt/intel/Compiler/11.0/083/bin" ] ; then PATH="/opt/intel/Compiler/11.0/083/bin:$PATH" fi  export ALTERAOCLSDKROOT="/home/altera/15.0/hld"  export QSYS_ROOTDIR="/home/altera/15.0/quartus/sopc_builder/bin"  PATH= /root/gcc-4.8.2/bin:$PATH export PATH 

Как видно выше, я добавил путь к этому сценарию следующим образом:

PATH= /root/gcc-4.8.2/bin:$PATH export PATH 

После ввода echo $PATHя получаю следующий ответ:

/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-1.b13.el6.x86_64/bin:/usr/lib64/qt-3.3/bin:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-1.b13.el6.x86_64/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/usr/apache/apache-ant-1.9.9/bin:/root/bin:/usr/apache/apache-ant-1.9.9/bin 

Путь для gcc-4.8.2 явно не был обнаружен.

Как я могу установить PATH, чтобы gcc-4.8.2он распознавался как компилятор по умолчанию, а не как gcc-4.4.7?

РЕДАКТИРОВАТЬ:

Я последовал совету Boxama, и мой путь обновился:

/root/gcc-4.8.2/bin:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-1.b13.el6.x86_64/bin:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-1.b13.el6.x86_64/bin:/usr/lib64/qt-3.3/bin:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-1.b13.el6.x86_64/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/usr/apache/apache-ant-1.9.9/bin:/root/bin:/usr/apache/apache-ant-1.9.9/bin:/usr/apache/apache-ant-1.9.9/bin 

Я получаю следующий вывод после ввода gcc -v:

Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/root/gcc-4.8.2/libexec/gcc/x86_64-unknown-linux-gnu/4.8.2/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: /root/Downloads/objdir/../gcc-4.8.2/configure --prefix=/root/gcc-4.8.2 --enable-languages=c,c++,fortran,go --disable-multilib Thread model: posix gcc version 4.8.2 (GCC)  
0
Вставьте свой `.bashrc` туда: http://www.shellcheck.net/ Cyrus 7 лет назад 1

3 ответа на вопрос

1
boxama

У вас не должно быть пробела после PATH=, и вы должны окружить значение "метками, чтобы их $PATHможно было правильно заменить:

export PATH="/root/gcc-4.8.2/bin:$PATH" 

Кроме того, не забудьте перезагрузить ваш .bashrc, чтобы ваши изменения действительно вступили в силу:

# source /root/.bashrc 

Предварительный путь к более новому gcc перед / usr / bin позволит ему иметь приоритет над более старой установкой.

Обратите внимание, что поскольку gcc был установлен в / root, другие пользователи не смогут получить к нему доступ или запустить его.

Я последовал вашему ответу, и теперь мой путь был обновлен. Я вижу gcc-4.8.2, когда набираю `gcc -v`. a_sid 7 лет назад 0
0
Knud Larsen

gcc-4.9.2 доступен в репозиториях: # yum install centos-release-scl-rh

# yum install devtoolset-3-gcc-c++ 

Включение gcc / g ++ версии 4.9.2: $ scl enable devtoolset-3 bash

0
Knud Larsen

gcc-4.9.2 доступен в репозиториях: # yum install centos-release-scl-rh

# yum install devtoolset-3-gcc-c++ 

Включение gcc / g ++ версии 4.9.2: $ scl enable devtoolset-3 bash


Доступно по адресу http://people.centos.org/tru/devtools-2 : gcc-4.8.2 → → → https://people.centos.org/tru/devtools-2/devtools-2.repo

# yum install devtoolset-2-gcc-c++ 

Включение 4.8.2: $ scl enable devtoolset-2 bash

Какие еще преимущества я получу после установки 4.9.2? a_sid 7 лет назад 0

Похожие вопросы