Where is the gcc executable under Linux? - linux

I installed gcc 4.7.0 as a new version, but the result of gcc --version did not change. I learned that I should set a link in /usr/bin/ to the gcc executable. However, under the index of 4.7.0 I installed there are 6 indexes:
bin include lib lib64 libexec share
I am not sure where I can find the gcc executable. Where should the gcc executable be commonly?
Thank you!

It should be under the /usr/bin directory. If it is not, try to find with:
$ which gcc

Related

How to remove gcc 7.3 from RHEL 7?

RHEL 7 comes with built-in gcc of version 4.8.
If I do
yum remove gcc
then it removes gcc 4.8. How can I remove gcc 7.3 from the system completely?
I have tried to find the solution for the above problem but most of the solution is for Ubuntu. Can someone help to figure out a solution for CentOS/RHEL?
Thanks.
Note:
which gcc
/usr/local/bin/gcc
gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-pc-linux-gnu/7.3.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ./configure --disable-multilib --enable-languages=c,c++
Thread model: posix
gcc version 7.3.0 (GCC)
Try to give version number in package name to yum:
yum remove gcc-7.3.0

Installing GCC from source on Alpine

While trying to install GCC 6.4.0 on Alpine, I run into:
checking for the correct version of gmp.h... yes
checking for the correct version of mpfr.h... yes
checking for the correct version of mpc.h... yes
checking for the correct version of the gmp/mpfr/mpc libraries... no
But in /usr/lib, which seems to be the standard lookup directory, I have:
libgmp.a
libgmp.so
libgmp.so.10
libgmp.so.10.3.2
libmpc.so.3
libmpc.so.3.0.0
libmpfr.so.4
libmpfr.so.4.1.5
What could be wrong?
The quickest way to install GCC on Alpine Linux is by issuing the following command:
apk add build-base
source: https://wiki.alpinelinux.org/wiki/GCC
The best way to install all necessary libraries to compile gcc is using ./contrib/download_prerequisites script in the gcc source directory. That will download the support libraries and create symlinks, causing them to be built automatically as part of the gcc build process.
The steps to compile gcc version 6.4.0 on Alpine linux are:
apk add --no-cache make build-base
wget https://ftp.gnu.org/gnu/gcc/gcc-6.4.0/gcc-6.4.0.tar.gz
tar -xzvf gcc-6.4.0.tar.gz
cd gcc-6.4.0
./contrib/download_prerequisites
cd ..
mkdir objdir
cd objdir
./../gcc-6.4.0/configure --prefix=$HOME/GCC-6.4.0 --disable-multilib
make all-gcc
make all-target-libgcc
make install-gcc
make install-target-libgcc
It turns out that in this particular case one needs to install mpc1-dev, gmp-dev or mpfr-dev. I was missing out on mpc1-dev.
sudo apk add mpc1-dev

How to change the GCC version

I just install a kali-linux, and trying to play with it.
I did use ubuntu before. That cause some problems with different gcc version when I am trying to use some code what I build in my old Ubuntu.
I check the gcc -v; the kali give me
gcc version 6.1.1 20160802(Debian 6.1.1-11)
and ubuntu give me
gcc version 5.4.0 20160609 (ubuntu 5.4.0-6ubuntu1~16.04.2)
I am not sure if my code doesn't compile because of this or not. But just want to check.
how can I remove Debian's gcc and switch to ubuntu one?
May be i'm not much familiar with debian. But with Ubuntu, i've followed this and changed the gcc version. May be this will help.
Change default gcc version
You can use this command to install gcc versions.
sudo apt-get install gcc-4.3 gcc-4.4
Once installed, you have to update the alternatives with the variant gcc versions. Using
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.3 10
You can choose which version of gcc, you can use by this command.
sudo update-alternatives --config gcc

gcc available, but not installed in fedora

I installed gcc using sudo yum install gcc then I try compile c program it say gcc command not found then I try to update the gcc using sudo yum update gcc then it say Page(s) gcc available, but not installed I try to find an answer in google, but I'm unable to fined the solution. please can anyone help me ?
These steps might help check what the cause could be.
rpm -q gcc --> check if gcc is installed and managed by yum/rpm
which gcc --> check if gcc is in your search path for executables
gcc --version --> check if gcc works in the simplest way (perhaps the error came from incorrect source file path passed to it)
Finally I found the answer, first I did yum update audit then I install gcc using yum install gcc it works fine, thank you for your help

Formats Error (could not find ldd binary)!

I'm using CentOS5 and trying to install a script that requires ldd.
I've tried:
yum install gcc glibc glibc-common
yum update gcc glibc glibc-common
Yum reinstall yum gcc glibc glibc-common
The first two say it's already installed, the latter obviously just reinstalls without error.
So my problem is the script I'm using (AVS) still claims the ldd binary is missing.
Is there a default directory where it should be installed? I have the following files:
ld
ldd
lddlibc4
In both /usr/bin and /usr/local/bin
Any help is greatly appreciated.
ldd is not a binary, it is a Text file, with bash script inside. You should debug your script (AVS) or contact with its author.
You may have removed ldd executable manually and yum/rpm can not detect that. You can download the "glibc-common" rpm package from some mirror and reinstall it by force.

Resources