Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is g++ both a c++ compiler and a linker?

Tags:

I was looking at the output from my build in Eclipse. I'm cross compiling for a ColdFire processor. The compilation line looks like this:

m68k-elf-g++ -O2 -falign-functions=4 -IC:\nburn\include -IC:\nburn\MOD52... 

followed by more include file, obvious "compiler" flags and finally the one source file I changed. The next line invokes the same tool again:

m68k-elf-g++ src\main.o src\TouchPanelMediator.o src\Startup.o.... 

followed by more .o files some .ld files and some .a files. This appears to be linking all the various types of object files together.

In the Gnu family is g++ some uber application that can determine based on arguments whether it needs to compile or link? Does it have both capabilities built-in or is it just dispatching compiling to gcc and linking to ld and my log just doesn't show that?

like image 585
Tod Avatar asked Apr 22 '11 19:04

Tod


People also ask

Is GCC A compiler and linker?

GNU Compiler Collection (GCC): a compiler suite that supports many languages, such as C/C++ and Objective-C/C++. GNU Make: an automation tool for compiling and building applications. GNU Binutils: a suite of binary utility tools, including linker and assembler. GNU Debugger (GDB).

Is G ++ a C compiler?

g++ will compile . c, . h and . i files as C++ unless the -x option is specified.

What is linker in C compiler?

In computing, a linker or link editor is a computer system program that takes one or more object files (generated by a compiler or an assembler) and combines them into a single executable file, library file, or another "object" file.

Is G ++ and GCC the same?

DIFFERENCE BETWEEN g++ & gccg++ is used to compile C++ program. gcc is used to compile C program.


1 Answers

g++ and gcc are drivers. Usually, they run the preprocessor (cpp), compiler proper (cc1plus for C++ and cc1 for C) and the linker (gold or GNU ld) and all other things necessary. The difference between gcc and g++ is that the latter includes one additional library to link against (libstdc++).

Depending on what type of file they are invoked on, they may omit some steps or do things differently. For .o files, it doesn't need to run the compiler proper or the preprocessor, for example.

If you pass -### to them, you can see it print the tools it invokes in each step of its execution.

like image 53
Johannes Schaub - litb Avatar answered Sep 20 '22 14:09

Johannes Schaub - litb