C语言的编译器及编译过程
2016-03-01 12:59
639 查看
编译器
GCCGNU组织开发的开源免费的编译器。
MinGW
Windows操作系统下的GCC。
Clang
Clang 是一个 C++ 编写、基于 LLVM、发布于 LLVM BSD 许可证下的 C/C++/Objective C/Objective C++ 编译器,其目标(之一)就是超越 GCC。Mac系统已去掉GCC,Xcode自带Clang。
Visual C++ :: cl.exe
Microsoft VC++自带的编译器。
MinGW(GCC)的命令
一段hello world// helloworld.c #include <stdio.h> int main() { printf("hello world\n"); return 0; }
一步到位的编译指令
gcc helloworld.c -o helloworld gcc helloworld.c -o helloworld.exe
会在当前目录生成
helloworld.exe可执行文件。
如果不使用
-o,默认生成
a.exe可执行文件
gcc helloworld.c
会在当前目录生成
a.exe可执行文件。
实际上,上述编译过程是分为四个阶段进行的,即预处理(也称预编译,Preprocessing)、编译(Compilation)、汇编 (Assembly)和链接(Linking)。
(1) 预处理
gcc -E helloworld.c -o helloworld.i
会在当前目录生成
helloworld.i文件。
如果不使用
-o,则会把预处理后的内容(即上面helloworld.i中的内容)输出到命令行窗口中。
gcc -E helloworld.c
预处理主要做两件事:
一是把预处理语句中的内容替换过来;
二是宏替换。
helloworld.i仍是C代码,下面把
helloworld.i中的内容粘贴过来
# 1 "helloworld.c" # 1 "<built-in>" # 1 "<command-line>" # 1 "helloworld.c" # 1 "c:\\mingw\\include\\stdio.h" 1 3 # 19 "c:\\mingw\\include\\stdio.h" 3 # 1 "c:\\mingw\\include\\_mingw.h" 1 3 # 41 "c:\\mingw\\include\\_mingw.h" 3 # 42 "c:\\mingw\\include\\_mingw.h" 3 # 20 "c:\\mingw\\include\\stdio.h" 2 3 # 1 "c:\\mingw\\lib\\gcc\\mingw32\\4.9.3\\include\\stddef.h" 1 3 4 # 212 "c:\\mingw\\lib\\gcc\\mingw32\\4.9.3\\include\\stddef.h" 3 4 typedef unsigned int size_t; # 324 "c:\\mingw\\lib\\gcc\\mingw32\\4.9.3\\include\\stddef.h" 3 4 typedef short unsigned int wchar_t; # 353 "c:\\mingw\\lib\\gcc\\mingw32\\4.9.3\\include\\stddef.h" 3 4 typedef short unsigned int wint_t; # 27 "c:\\mingw\\include\\stdio.h" 2 3 # 1 "c:\\mingw\\lib\\gcc\\mingw32\\4.9.3\\include\\stdarg.h" 1 3 4 # 40 "c:\\mingw\\lib\\gcc\\mingw32\\4.9.3\\include\\stdarg.h" 3 4 typedef __builtin_va_list __gnuc_va_list; # 29 "c:\\mingw\\include\\stdio.h" 2 3 # 130 "c:\\mingw\\include\\stdio.h" 3 typedef struct _iobuf { char* _ptr; int _cnt; char* _base; int _flag; int _file; int _charbuf; int _bufsiz; char* _tmpfname; } FILE; # 155 "c:\\mingw\\include\\stdio.h" 3 extern __attribute__ ((__dllimport__)) FILE _iob[]; FILE* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fopen (const char*, const char*); FILE* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) freopen (const char*, const char*, FILE*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fflush (FILE*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fclose (FILE*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) remove (const char*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) rename (const char*, const char*); FILE* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) tmpfile (void); char* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) tmpnam (char*); char* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _tempnam (const char*, const char*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _rmtmp(void); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _unlink (const char*); char* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) tempnam (const char*, const char*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) rmtmp(void); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) unlink (const char*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) setvbuf (FILE*, char*, int, size_t); void __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) setbuf (FILE*, char*); # 203 "c:\\mingw\\include\\stdio.h" 3 extern int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) __mingw_fprintf(FILE*, const char*, ...); extern int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) __mingw_printf(const char*, ...); extern int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) __mingw_sprintf(char*, const char*, ...); extern int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) __mingw_snprintf(char*, size_t, const char*, ...); extern int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) __mingw_vfprintf(FILE*, const char*, __gnuc_va_list); extern int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) __mingw_vprintf(const char*, __gnuc_va_list); extern int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) __mingw_vsprintf(char*, const char*, __gnuc_va_list); extern int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) __mingw_vsnprintf(char*, size_t, const char*, __gnuc_va_list); # 292 "c:\\mingw\\include\\stdio.h" 3 int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fprintf (FILE*, const char*, ...); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) printf (const char*, ...); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) sprintf (char*, const char*, ...); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) vfprintf (FILE*, const char*, __gnuc_va_list); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) vprintf (const char*, __gnuc_va_list); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) vsprintf (char*, const char*, __gnuc_va_list); # 307 "c:\\mingw\\include\\stdio.h" 3 int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) __msvcrt_fprintf(FILE*, const char*, ...); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) __msvcrt_printf(const char*, ...); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) __msvcrt_sprintf(char*, const char*, ...); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) __msvcrt_vfprintf(FILE*, const char*, __gnuc_va_list); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) __msvcrt_vprintf(const char*, __gnuc_va_list); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) __msvcrt_vsprintf(char*, const char*, __gnuc_va_list); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _snprintf (char*, size_t, const char*, ...); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _vsnprintf (char*, size_t, const char*, __gnuc_va_list); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _vscprintf (const char*, __gnuc_va_list); # 330 "c:\\mingw\\include\\stdio.h" 3 int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) snprintf (char *, size_t, const char *, ...); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) vsnprintf (char *, size_t, const char *, __gnuc_va_list); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) vscanf (const char * __restrict__, __gnuc_va_list); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) vfscanf (FILE * __restrict__, const char * __restrict__, __gnuc_va_list); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) vsscanf (const char * __restrict__, const char * __restrict__, __gnuc_va_list); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fscanf (FILE*, const char*, ...); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) scanf (const char*, ...); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) sscanf (const char*, const char*, ...); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fgetc (FILE*); char* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fgets (char*, int, FILE*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fputc (int, FILE*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fputs (const char*, FILE*); char* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) gets (char*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) puts (const char*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) ungetc (int, FILE*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _filbuf (FILE*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _flsbuf (int, FILE*); extern __inline__ int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) getc (FILE* __F) { return (--__F->_cnt >= 0) ? (int) (unsigned char) *__F->_ptr++ : _filbuf (__F); } extern __inline__ int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) putc (int __c, FILE* __F) { return (--__F->_cnt >= 0) ? (int) (unsigned char) (*__F->_ptr++ = (char)__c) : _flsbuf (__c, __F); } extern __inline__ int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) getchar (void) { return (--(&_iob[0])->_cnt >= 0) ? (int) (unsigned char) *(&_iob[0])->_ptr++ : _filbuf ((&_iob[0])); } extern __inline__ int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) putchar(int __c) { return (--(&_iob[1])->_cnt >= 0) ? (int) (unsigned char) (*(&_iob[1])->_ptr++ = (char)__c) : _flsbuf (__c, (&_iob[1]));} # 411 "c:\\mingw\\include\\stdio.h" 3 size_t __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fread (void*, size_t, size_t, FILE*); size_t __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fwrite (const void*, size_t, size_t, FILE*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fseek (FILE*, long, int); long __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) ftell (FILE*); void __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) rewind (FILE*); # 454 "c:\\mingw\\include\\stdio.h" 3 typedef long long fpos_t; int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fgetpos (FILE*, fpos_t*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fsetpos (FILE*, const fpos_t*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) feof (FILE*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) ferror (FILE*); # 479 "c:\\mingw\\include\\stdio.h" 3 void __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) clearerr (FILE*); void __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) perror (const char*); FILE* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _popen (const char*, const char*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _pclose (FILE*); FILE* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) popen (const char*, const char*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) pclose (FILE*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _flushall (void); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _fgetchar (void); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _fputchar (int); FILE* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _fdopen (int, const char*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _fileno (FILE*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _fcloseall (void); FILE* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _fsopen (const char*, const char*, int); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _getmaxstdio (void); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _setmaxstdio (int); # 526 "c:\\mingw\\include\\stdio.h" 3 unsigned int __attribute__((__cdecl__)) __mingw_get_output_format (void); unsigned int __attribute__((__cdecl__)) __mingw_set_output_format (unsigned int); int __attribute__((__cdecl__)) __mingw_get_printf_count_output (void); int __attribute__((__cdecl__)) __mingw_set_printf_count_output (int); # 553 "c:\\mingw\\include\\stdio.h" 3 extern __inline__ __attribute__((__always_inline__)) unsigned int __attribute__((__cdecl__)) _get_output_format (void) { return __mingw_get_output_format (); } extern __inline__ __attribute__((__always_inline__)) unsigned int __attribute__((__cdecl__)) _set_output_format (unsigned int __style) { return __mingw_set_output_format (__style); } # 579 "c:\\mingw\\include\\stdio.h" 3 extern __inline__ __attribute__((__always_inline__)) int __attribute__((__cdecl__)) _get_printf_count_output (void) { return 0 ? 1 : __mingw_get_printf_count_output (); } extern __inline__ __attribute__((__always_inline__)) int __attribute__((__cdecl__)) _set_printf_count_output (int __mode) { return 0 ? 1 : __mingw_set_printf_count_output (__mode); } int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fgetchar (void); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fputchar (int); FILE* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fdopen (int, const char*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fileno (FILE*); # 599 "c:\\mingw\\include\\stdio.h" 3 # 1 "c:\\mingw\\include\\sys\\types.h" 1 3 # 35 "c:\\mingw\\include\\sys\\types.h" 3 # 36 "c:\\mingw\\include\\sys\\types.h" 3 # 45 "c:\\mingw\\include\\sys\\types.h" 3 # 1 "c:\\mingw\\lib\\gcc\\mingw32\\4.9.3\\include\\stddef.h" 1 3 4 # 147 "c:\\mingw\\lib\\gcc\\mingw32\\4.9.3\\include\\stddef.h" 3 4 typedef int ptrdiff_t; # 46 "c:\\mingw\\include\\sys\\types.h" 2 3 # 1 "c:\\mingw\\include\\parts\\time.h" 1 3 # 64 "c:\\mingw\\include\\parts\\time.h" 3 typedef long __time32_t; typedef long long __time64_t; # 74 "c:\\mingw\\include\\parts\\time.h" 3 typedef __time32_t time_t; # 50 "c:\\mingw\\include\\sys\\types.h" 2 3 typedef long _off_t; typedef _off_t off_t; typedef unsigned int _dev_t; typedef _dev_t dev_t; typedef short _ino_t; typedef _ino_t ino_t; typedef int _pid_t; typedef _pid_t pid_t; typedef unsigned short _mode_t; typedef _mode_t mode_t; typedef int _sigset_t; typedef _sigset_t sigset_t; typedef int _ssize_t; typedef _ssize_t ssize_t; typedef long long fpos64_t; typedef long long off64_t; typedef unsigned long useconds_t __attribute__ ((__deprecated__)); # 600 "c:\\mingw\\include\\stdio.h" 2 3 extern __inline__ FILE* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fopen64 (const char* filename, const char* mode) { return fopen (filename, mode); } int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fseeko64 (FILE*, off64_t, int); extern __inline__ off64_t __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) ftello64 (FILE * stream) { fpos_t pos; if (fgetpos(stream, &pos)) return -1LL; else return ((off64_t) pos); } # 628 "c:\\mingw\\include\\stdio.h" 3 int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fwprintf (FILE*, const wchar_t*, ...); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) wprintf (const wchar_t*, ...); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _snwprintf (wchar_t*, size_t, const wchar_t*, ...); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) vfwprintf (FILE*, const wchar_t*, __gnuc_va_list); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) vwprintf (const wchar_t*, __gnuc_va_list); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _vsnwprintf (wchar_t*, size_t, const wchar_t*, __gnuc_va_list); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _vscwprintf (const wchar_t*, __gnuc_va_list); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fwscanf (FILE*, const wchar_t*, ...); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) wscanf (const wchar_t*, ...); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) swscanf (const wchar_t*, const wchar_t*, ...); wint_t __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fgetwc (FILE*); wint_t __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fputwc (wchar_t, FILE*); wint_t __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) ungetwc (wchar_t, FILE*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) swprintf (wchar_t*, const wchar_t*, ...); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) vswprintf (wchar_t*, const wchar_t*, __gnuc_va_list); wchar_t* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fgetws (wchar_t*, int, FILE*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fputws (const wchar_t*, FILE*); wint_t __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) getwc (FILE*); wint_t __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) getwchar (void); wchar_t* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _getws (wchar_t*); wint_t __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) putwc (wint_t, FILE*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _putws (const wchar_t*); wint_t __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) putwchar (wint_t); FILE* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _wfdopen(int, const wchar_t *); FILE* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _wfopen (const wchar_t*, const wchar_t*); FILE* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _wfreopen (const wchar_t*, const wchar_t*, FILE*); FILE* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _wfsopen (const wchar_t*, const wchar_t*, int); wchar_t* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _wtmpnam (wchar_t*); wchar_t* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _wtempnam (const wchar_t*, const wchar_t*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _wrename (const wchar_t*, const wchar_t*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _wremove (const wchar_t*); void __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _wperror (const wchar_t*); FILE* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _wpopen (const wchar_t*, const wchar_t*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) snwprintf (wchar_t* s, size_t n, const wchar_t* format, ...); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) vsnwprintf (wchar_t* s, size_t n, const wchar_t* format, __gnuc_va_list arg); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) vwscanf (const wchar_t * __restrict__, __gnuc_va_list); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) vfwscanf (FILE * __restrict__, const wchar_t * __restrict__, __gnuc_va_list); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) vswscanf (const wchar_t * __restrict__, const wchar_t * __restrict__, __gnuc_va_list); # 690 "c:\\mingw\\include\\stdio.h" 3 FILE* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) wpopen (const wchar_t*, const wchar_t*); wint_t __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _fgetwchar (void); wint_t __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _fputwchar (wint_t); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _getw (FILE*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _putw (int, FILE*); wint_t __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fgetwchar (void); wint_t __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fputwchar (wint_t); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) getw (FILE*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) putw (int, FILE*); # 2 "helloworld.c" 2 int main() { printf("hello world\n"); return 0; }
(2) 编译
预处理之后,对生成的
helloworld.i文件编译,生成汇编代码
gcc -S helloworld.i -o helloworld.s
helloworld.s中的内容如下
.file "helloworld.c" .def ___main; .scl 2; .type 32; .endef .section .rdata,"dr" LC0: .ascii "hello world\0" .text .globl _main .def _main; .scl 2; .type 32; .endef _main: LFB10: .cfi_startproc pushl %ebp .cfi_def_cfa_offset 8 .cfi_offset 5, -8 movl %esp, %ebp .cfi_def_cfa_register 5 andl $-16, %esp subl $16, %esp call ___main movl $LC0, (%esp) call _puts movl $0, %eax leave .cfi_restore 5 .cfi_def_cfa 4, 4 ret .cfi_endproc LFE10: .ident "GCC: (GNU) 4.9.3" .def _puts; .scl 2; .type 32; .endef
(3) 汇编
把
helloworld.s编译为目标文件
gcc -c helloworld.s -o helloworld.o
helloworld.o已是二进制文件,无法查看了。
(4) 链接
将目标文件与所需的所有附加的目标文件连接起来,最终生成可执行文件。附加的目标文件包括静态连接库和动态连接库。
这里
helloworld.o将与C标准输入输出库进行链接
gcc helloworld.o -o helloworld
生成
helloworld.exe可执行文件。
乱了,来张图
相关文章推荐
- 跨平台C++服务器程序开发 (1)了解跨平台开发
- Sublime Text3 C++及Java开发环境配置
- 【C++11】30分钟了解C++11新特性
- c++ 获取外网ip地址
- C++之pair(粘的别人的帖子)
- C语言之memcpy函数
- GeekBand学习笔记:C++三大函数:拷贝构造、拷贝赋值、析构函数
- C语言的宏定义
- C++第一次上机报告
- C++ template —— 函数对象和回调(十四)
- 第一次c++
- C++实验1-计算两个数的和与差
- c++项目试验(一)——求两数的和与差
- C++第一次上机实验项目2----计算两个整数的和及差
- c++作业1
- C++上机报告(示例)
- 第一次项目二-1c++上机报告
- C++ Super-FAQ 『Operator Overloading』
- C++ Super-FAQ 『Assignment Operators』
- 老赖学iOS开发--<2>--C语言运算符/表达式