Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the relationship between binutils and gcc?

Tags:

c++

linux

As titled, is binutils contained in gcc for Centos Linux? If I install gcc rpm package, is there need to install binutils also? What's more, are gcc and g++ both installed by default in Centos?

like image 803
jiafu Avatar asked Jan 19 '14 06:01

jiafu


People also ask

Is gcc part of binutils?

The GNU Binutils are typically used in conjunction with compilers such as the GNU Compiler Collection ( gcc), build tools like make, and the GNU Debugger ( gdb).

Does gcc depend on glibc?

Is it possible to compile a program using gcc without depending on glibc? Yes, there are alternative libc versions, such as Musl, uClibc, dietLibc, etc. See their documentation on how to use them. Your problem does not appear to be a GLIBC dependency, but rather a mismatch between your build and your target hosts.

Is Libstdc ++ part of gcc?

Libstdc++ is part of the GCC sources. You should first unpack the GCC tarball and change to the gcc-9.2.


1 Answers

The gcc package probably contains the compiler proper, e.g. files /usr/bin/gcc and directory /usr/lib/gcc/x86_64-linux-gnu/4.8/ (which contains the cc1 executable).

The /usr/bin/gcc program starts cc1 (or cc1plus etc...) to compile your source code *.c, and also as to translate cc1-generated assembly code (produced by cc1) into object file *.o, and at last ld to link.

Compile once with gcc -v to understand what is happening, it would show the really executed binaries. Notice that gcc is only a driving program (starting other executables like cc1, as, ld ...)

The as and ld programs are provided by binutils -which is needed to compile.

So the binutils package is a required dependency for the gcc package (with many other dependencies, probably including libc and libc-devel, but if you really want you could use some other libc like MUSL libc; the libc is generally providing the dynamic linker like /lib/ld-linux.so*).

Learn how to use rpm (on Centos, or dpkg on Ubuntu & Debian) to query the dependencies between packages.

For development you probably want some other packages. Debian has the build-essential virtual package. Probably CentOS has an equivalent. And you'll surely want to use some libraries (and you want the development packages for them, e.g. on Debian libcurl4-gnutls-dev to develop with the libcurl HTTP client library). See also this answer (for Ubuntu and Debian, but you can adapt it for CentOS).

In 2021 you want to use GCC 10 at least, as g++ -Wall -Wextra -g and you could decide to code your own GCC plugin (checking some coding rules in your C++ code; you also want to document your coding conventions by writing). Be aware of the rule of five.

like image 165
Basile Starynkevitch Avatar answered Oct 06 '22 14:10

Basile Starynkevitch