Is g++ both a c++ compiler and a linker?
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:nburninclude -IC:nburnMOD52...
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++ srcmain.o srcTouchPanelMediator.o srcStartup.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?
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.
Taken from this little GCC guide:
Based on the file extension that you gave your program, it selects the appropriate commands it needs to run to turn the source you gave it into the output file you specified.
With a nice little flowchart of what GCC exactly does, depending on the file extensions:
input extensions runs if output
It dispatches linking to ld.
Also see here: How to get GCC linker command?
链接地址: http://www.djcxy.com/p/85750.html上一篇: 在Ubuntu的Eclipse Juno CDT中编写“g ++ not found in path”
下一篇: g ++既是c ++编译器又是链接器?