C编译器的Mac? [英] C compiler for mac?
问题描述
我正在处理关于链接的文本,并希望与上述文本中的一些示例一起工作。
为了更好地理解当调用 gcc
驱动程序时发生了什么,我正在调查所有的旧编译-school by hand;
- 使用
cpp
预处理$ b $与 - 使用
ld
编译为 编译 cc1
> 链接不幸的是,我的Mac似乎无法直接引用 cc1
(在<$ c $中没有列出 cc1
C>人)。我的选择是什么?
阅读关于GCC内部的一些资料。首先在,由我完成,CC BY SA
.s
程序集文件; 作为
(由 gcc
开头)将它转换为 .o
。 ld
链接器(由 gcc
开头)将生成一个库或一个可执行文件。
PS。我有一个Linux系统,但MacOSX上的东西非常相似。
关于链接的参考
一本好书关于链接是 Levine's Linkers&装载机书。
I'm working through a text on linking, and wanted to work along with some examples in said text.
To better understand whats going on when I invoke the gcc
driver, I was looking into doing all the compilation old-school by hand;
- preprocessing using
cpp
- compiling with
cc1
- assembling with
as
- linking using
ld
Unfortunately, on my Mac I don't seem to be able to reference cc1
directly (no listing of cc1
in man
). What are my options?
Read some material about GCC internals. First the wikipage on GCC. Then, you could play with the MELT probe (you may want a Linux system to use it). Then read the GCC manual. And the GCC resource center
Use gcc -v -Wall
to compile, it will show what cc1
is running (and -Wall
is always useful). So try compiling with gcc -v -Wall hello.c -o helloworld.bin
the cc1
program don't sit in your PATH
or in /usr/bin/
but -on my system- in /usr/lib/gcc/x86_64-linux-gnu/4.8/cc1
The command gcc -print-prog-name=cc1
will tell you which cc1
is used by your gcc
. See GCC debugging options for more.
The preprocessing is now inside cc1
.
The gcc
program is just a driver, starting cc1
(which does most of the compiling work), then as
, ld
etc...
The MELT site contains some documentation, and some slides explaining GCC, which you could find interesting. MELT is a domain specific language to extend GCC.
See also the picture on http://gcc-melt.org/cc1-internals.svg and the below picture
picture from http://gcc-melt.org/gcc-MELT-inside.png, done by me, CC BY SA
The cc1
is producing a .s
assembly file; the as
(started by gcc
) is transforming it into .o
. The ld
linker (started by gcc
) will produce a library or an executable.
PS. I have a Linux system, but things are very similar on MacOSX.
reference on linking
A good book about linking is Levine's Linkers & loaders book.
这篇关于C编译器的Mac?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!