{"id":289497,"date":"2024-01-17T05:08:23","date_gmt":"2024-01-16T21:08:23","guid":{"rendered":"https:\/\/lrxjmw.cn\/lxtglzjdcdms.html"},"modified":"2024-01-17T05:08:23","modified_gmt":"2024-01-16T21:08:23","slug":"lxtglzjdcdms","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/lxtglzjdcdms.html","title":{"rendered":"Linux\u7cfb\u7edf\u7ba1\u7406\u4e13\u5bb6\u7684C\u4ee3\u7801\u5b9e\u7528\u5efa\u8bae"},"content":{"rendered":"

\u8eab\u4e3aLinux<\/a>\u7cfb\u7edf<\/a>\u7ba1\u7406\u4e13\u5bb6\uff0c\u6bcf\u65e5\u9700\u5e94\u5bf9\u5404\u79cd\u7f16\u7a0b\u9700\u6c42\uff0c\u7279\u522b\u662fC\u7a0b\u5e8f\u6267\u884c\u3002\u4eca\u5929redhat linux\uff0c\u6b23\u7136\u4e0e\u60a8\u5206\u4eab\u6211\u5728Linux\u73af\u5883\u4e2d\u8fd0\u7528C\u4ee3\u7801\u7684\u591a\u65b9\u9762\u89c1\u89e3\u548c\u5b9e\u7528\u5efa\u8bae\u3002<\/p>\n

1.\u786e\u4fdd\u5df2\u5b89\u88c5\u5fc5\u8981\u7684\u5f00\u53d1\u5de5\u5177<\/b><\/p>\n

\u656c\u7231\u7684\u8bfb\u8005\uff0c\u9996\u5148\uff0c\u6211\u4eec\u8981\u786e\u4fdd\u60a8\u5df2\u6b63\u786e\u5b89\u88c5\u5fc5\u8981\u7684\u5f00\u53d1\u5de5\u5177\uff0c\u5305\u62ecGCC\u7f16\u8bd1\u5668\u548cGDB\u8c03\u8bd5\u5668\u3002\u4e3a\u4e86\u6838\u5b9e\uff0c\u60a8\u53ef\u7528\u4e0b\u9762\u4e24\u4e2a\u529f\u80fd\u5f3a\u5927\u7684\u547d\u4ee4<\/a>\u6765\u68c0\u67e5\uff1a<\/p>\n

\n

shell\ngcc --version\ngdb --version\n<\/pre>\n<\/p>\n

\u5982\u679c\u60a8\u8fd8\u672a\u8fdb\u884c\u5b89\u88c5\uff0c\u656c\u8bf7\u4f7f\u7528\u60a8\u7cfb\u7edf\u9002\u7528\u7684Linux\u53d1\u884c\u7248\u7684\u5305\u7ba1\u7406\u5668\u6765\u83b7\u53d6\u5e76\u5b89\u88c5\u6240\u9700\u5de5\u5177\u3002<\/p>\n

2.\u521b\u5efa\u5e76\u7f16\u8f91C\u7a0b\u5e8f\u6587\u4ef6<\/b><\/p>\n

\u4e3a\u4e86\u8fd0\u884c C \u7a0b\u5e8flinux\u8fd0\u884cc\u7a0b\u5e8f<\/strong>\uff0c\u9700\u8981\u5148\u521b\u5efa\u4e00\u4efd\u540d\u4e3a'.c'\u7684\u6e90\u6587\u4ef6\u3002\u60a8\u53ef\u4ee5\u6311\u9009\u4efb\u4f55\u6587\u672c\u7f16\u8f91\u5668\u6765\u5b8c\u6210\u6b64\u4efb\u52a1\uff0c\u5e76\u4ee5\".c\"\u4e3a\u540e\u7f00\u4fdd\u5b58\u6587\u4ef6\u3002\u4f8b\u5982\uff0c\u4f7f\u7528vim\u8f6f\u4ef6\u5c31\u80fd\u76f4\u63a5\u521b\u5efa\u51fa\u540d\u79f0\u4e3a\"hello.c\"\u7684\u6587\u4ef6\u3002<\/p>\n

vim hello.c<\/p>\n

\u7136\u540e\uff0c\u5728\u6587\u4ef6\u4e2d\u7f16\u5199\u4f60\u7684C\u4ee3\u7801\u3002<\/p>\n

3.\u7f16\u8bd1C\u7a0b\u5e8f<\/b><\/p>\n

\u7a0b\u5e8f\u8fd0\u884c\u5feb\u6377\u952e_\u7a0b\u5e8f\u8fd0\u884c\u7684\u9ed1\u6846\u53eb\u4ec0\u4e48_linux\u8fd0\u884cc\u7a0b\u5e8f<\/p>\n

\u5728\u5199\u4e0b\u6700\u81ea\u7136\u7684\u4ee3\u7801\u540e\uff0c\u6fc0\u52a8\u4eba\u5fc3\u7684\u73af\u8282\u4fbf\u662f\u8ba9\u5b83\u4eec\u534e\u4e3d\u53d8\u4e3a\u53ef\u6267\u884c\u6587\u4ef6\u5566\uff01\u53ea\u9700\u8f7b\u6572\u51e0\u4e0b\u952e\u76d8\uff0c\u60a8\u4fbf\u53ef\u5c06\u90a3\u4e2a\u5e26\u6709\u201chello\u201d\u540d\u5b57\u7684C\u6e90\u4ee3\u7801\u6587\u4ef6\u7cbe\u5fc3\u6784\u5efa\u4e3a\u53ef\u76f4\u63a5\u8fd0\u884c\u7684Hello\u7a0b\u5e8f\u54df~<\/p>\n

gcc -o hello hello.c<\/p>\n

\u5982\u679c\u4ee3\u7801\u4e2d\u6709\u9519\u8bef\uff0c\u7f16\u8bd1\u5668\u5c06\u4f1a\u7ed9\u51fa\u76f8\u5e94\u7684\u9519\u8bef\u63d0\u793a\u3002<\/p>\n

4.\u8fd0\u884cC\u7a0b\u5e8f<\/b><\/p>\n

\u4eb2\u7231\u7684\u670b\u53cb\u4eec\uff0c\u8ba9\u6211\u4eec\u884c\u52a8\u8d77\u6765\u5427\uff01\u8fd0\u884c\u540d\u53eb\"hello\"\u7684 C \u7a0b\u5e8f\u53ea\u9700\u4ee5\u4e0b\u7b80\u5355\u6307\u4ee4\u5373\u53ef\uff1a<\/p>\n

.\/hello<\/p>\n

\u5982\u679c\u4e00\u5207\u987a\u5229\uff0c\u4f60\u5c06\u5728\u7ec8\u7aef\u4e0a\u770b\u5230\u7a0b\u5e8f\u8f93\u51fa\u7684\u7ed3\u679c\u3002<\/p>\n

5.\u8c03\u8bd5C\u7a0b\u5e8f<\/b><\/p>\n

\u5982\u9047\u7a0b\u5e8f\u9519\u8bef\u6216\u5f02\u5e38\u60c5\u51b5\uff0c\u65e0\u987b\u62c5\u5fe7\uff01GDB\u8c03\u8bd5\u5de5\u5177\u53ef\u4e3a\u60a8\u63d0\u4f9b\u5e2e\u52a9\uff0c\u5b9a\u4f4d\u96be\u70b9\u95ee\u9898\u3002\u4ee5\u4e0b\u6b65\u9aa4\u5c06\u534f\u52a9\u60a8\u8f7b\u677e\u89e3\u51b3hello\u53ef\u6267\u884c\u6587\u4ef6\u7684\u8c03\u8bd5\u95ee\u9898\uff1a<\/p>\n

gdb hello<\/p>\n

\u4e4b\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528GDB\u547d\u4ee4\u6765\u83b7\u53d6\u53d8\u91cf\u7684\u503c\u5e76\u8ddf\u8e2a\u7a0b\u5e8f\u7684\u8fd0\u884c\u8def\u5f84\u7b49\u7b49\u3002<\/p>\n

6.\u4f18\u5316C\u7a0b\u5e8f\u6027\u80fd<\/b><\/p>\n

\u5982\u679c\u89c9\u5f97\u60a8\u7684C\u4ee3\u7801\u7565\u5fae\u6709\u4e9b\u7f13\u6162\u6216\u8005\u5360\u7528\u4e86\u8fc7\u591a\u7cfb\u7edf\u8d44\u6e90\uff0c\u53ef\u80fd\u8fd8\u53ef\u4ee5\u8003\u8651\u8fdb\u884c\u4e00\u4e9b\u6027\u80fd\u65b9\u9762\u7684\u4f18\u5316\u3002\u8fd9\u79cd\u4f18\u5316\u4e3b\u8981\u5305\u62ec\u91c7\u7528\u66f4\u9ad8\u6548\u7684\u7b97\u6cd5\u548c\u8282\u7701\u5185\u5b58\u4f7f\u7528\u7b49\u65b9\u6cd5\u3002\u901a\u8fc7\u5bf9\u73b0\u6709\u4ee3\u7801\u8fdb\u884c\u6df1\u5165\u5206\u6790\u5e76\u8fdb\u884c\u76f8\u5e94\u6539\u8fdb\uff0c\u7406\u8bba\u4e0a\u662f\u53ef\u4ee5\u663e\u8457\u6539\u5584\u6574\u4e2a\u7a0b\u5e8f\u7684\u6027\u80fd\u548c\u6548\u7387\u7684\u3002<\/p>\n

7.\u5b66\u4e60\u548c\u638c\u63e1\u66f4\u591aLinux\u547d\u4ee4<\/b><\/p>\n

\u4f5c\u4e3aLinux\u7cfb\u7edf\u7ba1\u7406\u5458\uff0c\u719f\u7ec3\u638c\u63e1\u5e76\u8fd0\u7528\u5404\u79cdLinux\u547d\u4ee4\u5c06\u5927\u5927\u63d0\u9ad8\u60a8\u7684\u5de5\u4f5c\u6548\u7387\u3002\u8fd9\u4e9b\u5b9e\u7528\u547d\u4ee4\u6709\u52a9\u4e8e\u9ad8\u6548\u7ba1\u7406\u548c\u8fd0\u884cLinux\u4e0a\u7684C\u7a0b\u5e8f\uff0c\u4ece\u800c\u8fdb\u4e00\u6b65\u63d0\u5347\u60a8\u5728\u64cd\u4f5c\u7cfb\u7edf\u4e2d\u7684\u5de5\u4f5c\u6c34\u51c6\u3002<\/p>\n

\u7a0b\u5e8f\u8fd0\u884c\u5feb\u6377\u952e_\u7a0b\u5e8f\u8fd0\u884c\u7684\u9ed1\u6846\u53eb\u4ec0\u4e48_linux\u8fd0\u884cc\u7a0b\u5e8f<\/p>\n

8.\u53c2\u8003\u6587\u6863\u548c\u5728\u7ebf\u8d44\u6e90<\/b><\/p>\n

\u5728\u5b66\u4e60\u548c\u8fd0\u7528Linux\u64cd\u4f5c\u7cfb\u7edf\u7684\u65c5\u7a0b\u91cclinux\u8fd0\u884cc\u7a0b\u5e8f<\/strong>\uff0c\u5145\u5206\u5229\u7528\u5404\u79cd\u53c2\u8003\u6587\u732e\u548c\u5728\u7ebf\u8d44\u6e90\u4f1a\u5bf9\u60a8\u5927\u6709\u88e8\u76ca\u3002\u8bf7\u8be6\u7ec6\u7814\u8bfbLinux\u5b98\u65b9\u6587\u6863\uff0c\u79ef\u6781\u53c2\u4e0e\u7ebf\u4e0a\u8bba\u575b\u4ea4\u6d41\uff0c\u518d\u6216\u8005\u67e5\u627e\u76f8\u5173\u4e13\u4e1a\u4e66\u7c4d\uff0c\u8fd9\u5c06\u52a9\u60a8\u6269\u5927\u4fe1\u606f\u6765\u6e90\uff0c\u66f4\u597d\u5730\u83b7\u53d6\u548c\u5229\u7528\u6709\u6548\u5e2e\u52a9\u3002<\/p>\n

9.\u4e0d\u65ad\u5b9e\u8df5\u548c\u79ef\u7d2f\u7ecf\u9a8c<\/b><\/p>\n

\u5728\u638c\u63e1Linux\u4e0bC\u7f16\u7a0b\u77e5\u8bc6\u7684\u8fc7\u7a0b\u4e2d\uff0c\u6301\u7eed\u4e0d\u65ad\u5730\u4fdd\u6301\u8054\u7cfb\u548c\u5b9e\u8df5\u953b\u70bc\u81f3\u5173\u91cd\u8981\u3002\u552f\u6709\u79ef\u6781\u5e94\u5bf9\u73b0\u5b9e\u96be\u9898\u5e76\u6311\u6218\u81ea\u6211\uff0c\u65b9\u80fd\u4fc3\u4f7f\u4e2a\u4eba\u6280\u672f\u53ca\u7d20\u517b\u9010\u6b65\u63d0\u5347\u3002<\/p>\n

\u51ed\u501f\u591a\u5e74\u4e30\u5bcc\u7ecf\u9a8c\u548c\u624e\u5b9e\u4e13\u4e1a\u6280\u80fdlinux\u4e3b\u673a\uff0c\u6211\u5df2\u6210\u529f\u5728Linux\u73af\u5883\u4e0b\u7f16\u5199\u4e86\u591a\u79cdC\u7a0b\u5e8f\u3002\u611f\u8c22\u60a8\u7684\u9605\u8bfb\uff0c\u5e0c\u671b\u672c\u6587\u6240\u8ff0\u80fd\u4e3a\u60a8\u5e26\u6765\u4e9b\u8bb8\u542f\u793a\uff0c\u795d\u613f\u60a8\u5728\u8fd0\u7528Linux\u7cfb\u7edf\u8fdb\u884cC\u7f16\u7a0b\u8fc7\u7a0b\u4e2d\u987a\u5229\u6536\u83b7\u6210\u679c\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"

\u8eab\u4e3aLinux\u7cfb\u7edf\u7ba1\u7406\u4e13\u5bb6\uff0c\u6bcf\u65e5\u9700\u5e94\u5bf9\u5404\u79cd\u7f16\u7a0b\u9700\u6c42\uff0c\u7279\u522b\u662fC\u7a0b\u5e8f\u6267\u884c\u3002\u53ea\u9700\u8f7b\u6572\u51e0\u4e0b\u952e\u76d8\uff0c\u60a8\u4fbf\u53ef\u5c06\u90a3\u4e2a\u5e26\u6709\u201chello\u201d\u540d\u5b57\u7684C\u6e90\u4ee3\u7801\u6587\u4ef6\u7cbe\u5fc3\u6784\u5efa\u4e3a\u53ef\u76f4\u63a5\u8fd0\u884c\u7684Hello\u7a0b\u5e8f\u54df~\u8fd9\u4e9b\u5b9e\u7528\u547d\u4ee4\u6709\u52a9\u4e8e\u9ad8\u6548\u7ba1\u7406\u548c\u8fd0\u884cLinux\u4e0a\u7684C\u7a0b\u5e8f\uff0c\u4ece\u800c\u8fdb\u4e00\u6b65\u63d0\u5347\u60a8\u5728\u64cd\u4f5c\u7cfb\u7edf\u4e2d\u7684\u5de5\u4f5c\u6c34\u51c6\u3002<\/p>\n","protected":false},"author":1,"featured_media":289498,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[988],"tags":[999],"class_list":["post-289497","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tougao","tag-999"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/289497","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=289497"}],"version-history":[{"count":0,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/289497\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/289498"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=289497"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=289497"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=289497"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}