{"id":48222,"date":"2023-01-14T11:18:08","date_gmt":"2023-01-14T03:18:08","guid":{"rendered":"http:\/\/www.xyryd.com\/?p=48222"},"modified":"2023-01-14T11:18:22","modified_gmt":"2023-01-14T03:18:22","slug":"gcc%e5%91%bd%e4%bb%a4-c-c%e8%af%ad%e8%a8%80%e7%bc%96%e8%af%91%e5%99%a8","status":"publish","type":"post","link":"http:\/\/www.xyryd.com\/48222.html","title":{"rendered":"gcc\u547d\u4ee4 – C\/C++\u8bed\u8a00\u7f16\u8bd1\u5668"},"content":{"rendered":"\n

gcc\u547d\u4ee4\u6765\u81ea\u4e8e\u82f1\u6587\u8bcd\u7ec4\u201cGNU Compiler Collection\u201d\u7684\u7f29\u5199\uff0c\u5176\u529f\u80fd\u662f\u7528\u4e8eC\/C++\u8bed\u8a00\u7f16\u8bd1\u5668\u3002gcc\u662f\u5f00\u6e90\u9886\u57df\u4f7f\u7528\u6700\u5e7f\u6cdb\u7684\u7f16\u8bd1\u5de5\u5177\uff0c\u5177\u6709\u529f\u80fd\u5f3a\u5927\u3001\u517c\u5bb9\u6027\u5f3a\uff0c\u6548\u7387\u9ad8\u7b49\u7279\u70b9\u3002<\/p>\n\n\n\n

\u7f16\u8bd1\u5de5\u4f5c\u7684\u56db\u4e2a\u9636\u6bb5\uff1a\u9884\u7f16\u8bd1\uff08Preprocessing)\u3001\u7f16\u8bd1(Compilation)\u3001\u6c47\u7f16 (Assembly)\u3001\u8fde\u63a5(Linking)\u3002<\/p>\n\n\n\n

\u8bed\u6cd5\u683c\u5f0f\uff1a<\/strong>gcc [\u53c2\u6570] \u6e90\u6587\u4ef6<\/p>\n\n\n\n

\u5e38\u7528\u53c2\u6570\uff1a<\/strong><\/p>\n\n\n\n

\n\n\n\n\n\n\n\n
-o<\/td>\n\u6307\u5b9a\u751f\u6210\u7684\u8f93\u51fa\u6587\u4ef6<\/td>\n<\/tr>\n
-E<\/td>\n\u4ec5\u6267\u884c\u7f16\u8bd1\u9884\u5904\u7406<\/td>\n<\/tr>\n
-S<\/td>\n\u5c06C\u4ee3\u7801\u8f6c\u6362\u4e3a\u6c47\u7f16\u4ee3\u7801<\/td>\n<\/tr>\n
-wall<\/td>\n\u663e\u793a\u8b66\u544a\u4fe1\u606f<\/td>\n<\/tr>\n
-c<\/td>\n\u4ec5\u6267\u884c\u7f16\u8bd1\u64cd\u4f5c\uff0c\u4e0d\u8fdb\u884c\u8fde\u63a5\u64cd\u4f5c<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n\n\n\n

\u53c2\u8003\u5b9e\u4f8b<\/strong><\/p>\n\n\n\n

\u7f16\u8bd1\u6307\u5b9a\u7684\u6e90\u7801\u6587\u4ef6\uff1a<\/p>\n\n\n\n

[root@jiloc ~]# gcc linux.c<\/strong><\/pre>\n\n\n\n

\u7f16\u8bd1\u6307\u5b9a\u7684\u6e90\u7801\u6587\u4ef6\uff0c\u5e76\u751f\u6210\u51fa\u53ef\u6267\u884c\u6587\u4ef6\uff1a<\/p>\n\n\n\n

[root@jiloc ~]# gcc linux.c -o linux<\/strong><\/pre>\n\n\n\n

\u5bf9\u6307\u5b9a\u7684\u6e90\u7801\u6587\u4ef6\u8fdb\u884c\u9884\u5904\u7406\uff1a<\/p>\n\n\n\n

 [root@jiloc ~]# gcc -E linux.c -o linux.i<\/strong><\/pre>\n\n\n\n

\u5bf9\u6307\u5b9a\u9884\u5904\u7406\u540e\u7684\u6587\u4ef6\u8fdb\u884c\u6c47\u7f16\u64cd\u4f5c\uff1a<\/p>\n\n\n\n

[root@jiloc ~]# gcc -S linux.i -o linux.s<\/strong><\/pre>\n\n\n\n

\u5bf9\u6307\u5b9a\u6c47\u7f16\u5904\u7406\u540e\u7684\u6587\u4ef6\u8fdb\u884c\u7f16\u8bd1\u64cd\u4f5c\uff1a<\/p>\n\n\n\n

[root@jiloc ~]# gcc -c linux.s -o linux.o<\/strong><\/pre>\n\n\n\n

\u5bf9\u6307\u5b9a\u7f16\u8bd1\u5904\u7406\u540e\u7684\u6587\u4ef6\u8fdb\u884c\u8fde\u63a5\u64cd\u4f5c\uff1a<\/p>\n\n\n\n

[root@jiloc ~]# gcc linux.o -o linux<\/strong><\/pre>\n","protected":false},"excerpt":{"rendered":"

gcc\u547d\u4ee4\u6765\u81ea\u4e8e\u82f1\u6587\u8bcd\u7ec4\u201cGNU Compiler Collection\u201d\u7684\u7f29\u5199\uff0c\u5176\u529f\u80fd\u662f\u7528\u4e8eC\/C++\u8bed\u8a00\u7f16 […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"single-with-sidebar","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[386,17],"aioseo_notices":[],"_links":{"self":[{"href":"http:\/\/www.xyryd.com\/wp-json\/wp\/v2\/posts\/48222"}],"collection":[{"href":"http:\/\/www.xyryd.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.xyryd.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.xyryd.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.xyryd.com\/wp-json\/wp\/v2\/comments?post=48222"}],"version-history":[{"count":0,"href":"http:\/\/www.xyryd.com\/wp-json\/wp\/v2\/posts\/48222\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.xyryd.com\/wp-json\/wp\/v2\/media?parent=48222"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.xyryd.com\/wp-json\/wp\/v2\/categories?post=48222"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.xyryd.com\/wp-json\/wp\/v2\/tags?post=48222"}],"curies":[{"name":"wp","href":"http:\/\/api.w.org\/{rel}","templated":true}]}}