{"id":1784,"date":"2018-12-28T09:05:01","date_gmt":"2018-12-28T01:05:01","guid":{"rendered":"https:\/\/www.yusian.com\/blog\/?p=1784"},"modified":"2020-12-02T09:09:36","modified_gmt":"2020-12-02T01:09:36","slug":"gcc%e7%9a%84%e5%9f%ba%e6%9c%ac%e4%bd%bf%e7%94%a8","status":"publish","type":"post","link":"https:\/\/www.yusian.com\/blog\/cpp\/2018\/12\/28\/0905011784.html","title":{"rendered":"gcc\u7684\u57fa\u672c\u4f7f\u7528"},"content":{"rendered":"<h4>1\u3001gcc\u7684\u7f16\u8bd1\u8fc7\u7a0b ( \u53c2\u6570\u5206\u522b\u4e3a\uff1aE  S  c , \u8f93\u51fa\u6587\u4ef6\u53c2\u6570-o )<\/h4>\n<ul>\n<li>\u9884\u5904\u7406\uff1a.c \u2014> .i  C\u6587\u4ef6\uff0c\u5934\u6587\u4ef6\u5c55\u5f00\u3001\u5b8f\u66ff\u6362\u3001\u53bb\u6ce8\u91ca<br \/>\n<code>gcc -E sum.c -o sum.i<\/code>\/\/ \u5c06sum.c\u9884\u5904\u7406\u751f\u6210sum.i\u6587\u4ef6<\/p>\n<\/li>\n<li>\n<p>\u7f16\u8bd1\u5668\uff1a.i \u2014> .s  \u6c47\u7f16\u6587\u4ef6\uff0cC\u8bed\u8a00\u4ee3\u7801\u53d8\u6210\u6c47\u7f16\u4ee3\u7801<br \/>\n<code>gcc -S sum.i -o sum.s<\/code> \/\/ \u5c06\u9884\u5904\u7406\u6587\u4ef6\u7f16\u8bd1\u6210\u6c47\u7f16\u6587\u4ef6<\/p>\n<\/li>\n<li>\n<p>\u6c47\u7f16\u5668\uff1a.s \u2014> .o \u4e8c\u8fdb\u5236\u6587\u4ef6\uff0c\u6c47\u7f16\u4ee3\u7801\u53d8\u6210\u4e8c\u8fdb\u5236\u4ee3\u7801<br \/>\n<code>gcc -c sum.s -o sum.o<\/code> \/\/ \u5c06\u6c47\u7f16\u4ee3\u7801\u6c47\u7f16\u6210\u4e8c\u8fdb\u5236\u6587\u4ef6<\/p>\n<\/li>\n<li>\n<p>\u94fe\u63a5\u5668\uff1a.o \u2014> .out \u53ef\u6267\u884c\u6587\u4ef6\uff0c\u5c06\u51fd\u6570\u5e93\u4e2d\u7684\u4ee3\u7801\u7ec4\u5408\u5230\u76ee\u6807\u6587\u4ef6\u4e2d<br \/>\n<code>gcc sum.o -o sum.out<\/code> \/\/ \u5c06\u94fe\u63a5\u6587\u4ef6\u94fe\u63a5\u6210\u53ef\u6267\u884c\u6587\u4ef6<\/p>\n<\/li>\n<li>\n<p>\u4e00\u6b65\u5230\u4f4d\uff1a<\/p>\n<p><code>gcc sum.c -o sum.out<\/code> \/\/ \u94fe\u63a5\u5668->\u6c47\u7f16\u5668->\u7f16\u8bd1\u5668->\u9884\u5904\u7406\u5668\uff0c\u4e00\u5c42\u5c42\u5f80\u4e0a\u8c03\u7528\u6700\u7ec8\u627e\u5230\u6e90\u6587\u4ef6\uff0c\u4e2d\u95f4\u8fc7\u7a0b\u4e0d\u4f1a\u7701\u7565\uff0c\u53ea\u662f\u8fc7\u7a0b\u53ea\u4ea7\u751f\u4e34\u65f6\u6587\u4ef6\u4e0d\u4f1a\u4fdd\u5b58\u4e0b\u6765\u3002<\/p>\n<\/li>\n<\/ul>\n<h4>2\u3001gcc\u7684\u4e00\u4e9b\u53c2\u6570<\/h4>\n<ul>\n<li>I \u2014> <code>gcc sum.c -I include -o sum.out<\/code> \/\/ -I\u53c2\u6570\u8868\u660e\u5934\u6587\u4ef6\u76ee\u5f55\u5305\u542b\u8be5\u76ee\u5f55<\/li>\n<li>D \u2014> <code>gcc sum.c -D DEBUG -o sum.out<\/code> \/\/ -D\u53c2\u6570\u8868\u660e\u7f16\u8bd1\u65f6\u52a0\u5b8f\u5b9a\u4e49<\/li>\n<li>O \u2014> <code>gcc sum.c -O -o sum.out<\/code> \/\/ -O\u53c2\u6570\u53ef\u7528\u6765\u4f18\u5316\u4ee3\u7801\uff0c\u6709O1\\O2\\O3<\/li>\n<li>Wall \u2014> <code>gcc sum.c -Wall -o sum.ou<\/code>t \/\/ -Wall \u53c2\u6570\u63d0\u793a\u8b66\u544a<\/li>\n<li>g \u2014><code>gcc sum.c -g -o sum.out<\/code> \/\/ -g\u5728\u7a0b\u5e8f\u4e2d\u6dfb\u52a0\u8c03\u8bd5\u4fe1\u606f\uff0c\u751f\u6210\u7684\u53ef\u6267\u884c\u6587\u4ef6\u4f1a\u53d8\u5927<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>1\u3001gcc\u7684\u7f16\u8bd1\u8fc7\u7a0b ( \u53c2\u6570\u5206\u522b\u4e3a\uff1aE S c , \u8f93\u51fa\u6587\u4ef6\u53c2\u6570-o ) \u9884\u5904\u7406\uff1a.c \u2014> .i C\u6587\u4ef6\uff0c\u5934\u6587\u4ef6\u5c55\u5f00\u3001\u5b8f\u66ff\u6362\u3001\u53bb\u6ce8\u91ca gcc -E sum.c -o sum.i\/\/ \u5c06sum.c\u9884\u5904\u7406\u751f\u6210sum.i\u6587\u4ef6 \u7f16\u8bd1\u5668\uff1a.i \u2014> .s \u6c47\u7f16\u6587\u4ef6\uff0cC\u8bed\u8a00\u4ee3\u7801\u53d8\u6210\u6c47\u7f16\u4ee3\u7801 gcc -S sum.i -o sum.s \/\/ \u5c06\u9884\u5904\u7406\u6587\u4ef6\u7f16\u8bd1\u6210\u6c47\u7f16\u6587\u4ef6 \u6c47\u7f16\u5668\uff1a.s \u2014> .o \u4e8c\u8fdb\u5236\u6587\u4ef6\uff0c\u6c47\u7f16\u4ee3\u7801\u53d8\u6210\u4e8c\u8fdb\u5236\u4ee3\u7801 gcc -c sum.s -o sum.o \/\/ \u5c06\u6c47\u7f16\u4ee3\u7801\u6c47\u7f16\u6210\u4e8c\u8fdb\u5236\u6587\u4ef6 \u94fe\u63a5\u5668\uff1a.o \u2014> .out \u53ef\u6267\u884c\u6587\u4ef6\uff0c\u5c06\u51fd\u6570\u5e93\u4e2d\u7684\u4ee3\u7801\u7ec4\u5408\u5230\u76ee\u6807\u6587\u4ef6\u4e2d gcc sum.o -o sum.out \/\/ \u5c06\u94fe\u63a5\u6587\u4ef6\u94fe\u63a5\u6210\u53ef\u6267\u884c\u6587\u4ef6 \u4e00\u6b65\u5230\u4f4d\uff1a gcc sum.c -o sum.out [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[88],"tags":[221,307],"class_list":["post-1784","post","type-post","status-publish","format-standard","hentry","category-cpp","tag-gcc","tag-307"],"_links":{"self":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/posts\/1784","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/comments?post=1784"}],"version-history":[{"count":0,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/posts\/1784\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/media?parent=1784"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/categories?post=1784"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/tags?post=1784"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}