是 g++都是 c++编译器和链接器?
我正在查看 Eclipse 中构建的输出。我正在针对 ColdFire 处理器进行交叉编译。编译行如下所示:
m68k-elf-g++ -O2 -falign-functions=4 -IC:\nburn\include -IC:\nburn\MOD52...
后面是更多包含文件、明显的“编译器”标志,最后是我更改的一个源文件。下一行再次调用相同的工具:
m68k-elf-g++ src\main.o src\TouchPanelMediator.o src\Startup.o....
后面是更多 .o 文件、一些 .ld 文件和一些 .a 文件。这似乎将所有不同类型的目标文件链接在一起。
在Gnu家族中,g++是一些超级应用程序,可以根据参数确定是否需要编译或链接?它是否内置了这两种功能,或者只是将编译分派到 gcc 并链接到 ld 而我的日志没有显示这一点?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
g++
和gcc
是驱动程序。通常,它们运行预处理器 (cpp
)、编译器(对于 C++ 为cc1plus
,对于 C 为cc1
)和链接器(gold 或 GNU ld) )以及所有其他必要的东西。gcc
和g++
之间的区别在于后者包含一个额外的链接库 (libstdc++
)。根据调用它们的文件类型,它们可能会省略一些步骤或以不同的方式执行操作。例如,对于
.o
文件,它不需要运行适当的编译器或预处理器。如果将
-###
传递给它们,您可以看到它打印在执行的每个步骤中调用的工具。g++
andgcc
are drivers. Usually, they run the preprocessor (cpp
), compiler proper (cc1plus
for C++ andcc1
for C) and the linker (gold or GNU ld) and all other things necessary. The difference betweengcc
andg++
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.摘自这份小小的 GCC 指南:
根据文件扩展名,有一个很好的小流程图说明了 GCC 的具体功能:
Taken from this little GCC guide:
With a nice little flowchart of what GCC exactly does, depending on the file extensions:
它发送到 ld 的链接。
另请参阅此处:
如何获取 GCC 链接器命令?
It dispatches linking to ld.
Also see here:
How to get GCC linker command?