{"id":208053,"date":"2021-01-03T10:15:35","date_gmt":"2021-01-03T02:15:35","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=208053"},"modified":"2020-12-24T21:17:11","modified_gmt":"2020-12-24T13:17:11","slug":"ubuntu-debian-linux","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/ubuntu-debian-linux.html","title":{"rendered":"\u5982\u4f55\u5728Ubuntu\/Debian Linux\u7f16\u5199C\u7a0b\u5e8f"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u4f60\u662f\u5982\u4f55\u5728 Linux \u4e0a\u4f7f\u7528 C \u7f16\u5199\u4f60\u7684\u7a0b\u5e8f\u7684\uff1f\u5b83\u786e\u5b9e\u662f\u975e\u5e38\u7b80\u5355\u7684\uff0c\u7531\u4e09\u4e2a\u7b80\u5355\u7684\u6b65\u9aa4\u7ec4\u6210\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\"\"<\/p>\n

\u6b65\u9aa4 1:<\/strong> \u7f16\u5199\u4f60\u7684 C \u7a0b\u5e8f\uff0c\u5e76\u4f7f\u7528\u4e00\u4e2a .c \u7684\u6269\u5c55\u540d\u8fdb\u884c\u4fdd\u5b58\u3002\u4f8b\u5982\uff0cmy_program.c \u3002<\/p>\n

\u6b65\u9aa4 2:<\/strong> \u5728\u4e00\u4e2a\u7ec8\u7aef\u4e2d\u4f7f\u7528 gcc \u7f16\u8bd1\u5668\u6765\u7f16\u8bd1\u7a0b\u5e8f\u5e76\u751f\u6210\u76ee\u6807\u6587\u4ef6\uff0c\u50cf\u8fd9\u6837\uff1a<\/p>\n

\r\ngcc -o my_program my_program.c\r\n<\/pre>\n

\u6b65\u9aa4 3:<\/strong> \u5728 Linux \u4e2d\uff0c\u4f60\u53ef\u4ee5\u4ee5\u8fd0\u884c\u751f\u6210\u7684\u5bf9\u8c61\u6587\u4ef6\u7684\u65b9\u5f0f\u6765\u8fd0\u884c\u4f60\u7684 C \u7a0b\u5e8f\uff1a<\/p>\n

\r\n.\/my_program\r\n<\/pre>\n

\"\"<\/p>\n

\u8fd9\u53ea\u662f\u5982\u4f55\u5728 Linux \u4e2d\u7f16\u8bd1\u548c\u8fd0\u884c C \u7a0b\u5e8f\u7684\u7b80\u8981\u603b\u7ed3\u3002\u5047\u8bbe\u4f60\u662f C \u8bed\u8a00\u6216 Linux \u7cfb\u7edf\u7684\u65b0\u624b\uff0c\u6211\u5c06\u4ed4\u7ec6\u6f14\u793a\u8fd9\u4e9b\u6b65\u9aa4\uff0c\u4ee5\u4fbf\u4f60\u80fd\u5728 Linux \u73af\u5883\u4e2d\u8212\u670d\u5730\u7f16\u5199 C \u7a0b\u5e8f\u3002<\/p>\n

\u4e8b\u5b9e\u4e0a\uff0c\u6211\u5c06\u8ba8\u8bba\u5982\u4f55\u5728 Linux \u7ec8\u7aef\u4e2d\u4ee5\u53ca\u5728\u4ee3\u7801\u7f16\u8f91\u5668\u4e2d\u8fd0\u884c C \u7a0b\u5e8f\u7684\u4e24\u79cd\u65b9\u5f0f\u3002<\/p>\n

\u65b9\u6cd5 1: \u5728 Linux \u7ec8\u7aef\u4e2d\u8fd0\u884c C \u7a0b\u5e8f<\/strong><\/div>\n

\u4e3a\u4e86\u5728 Linux \u4e2d\u8fd0\u884c\u4e00\u4e2a C \u7a0b\u5e8f\uff0c\u4f60\u9700\u8981\u5728\u4f60\u7684\u7cfb\u7edf\u4e0a\u6709\u4e00\u4e2a C \u7f16\u8bd1\u5668\u3002\u6700\u6d41\u884c\u7684\u7f16\u8bd1\u5668\u662f gcc\uff08GNU \u7f16\u8bd1\u5668\u5957\u4ef6GNU Compiler Collection\uff09\u3002<\/p>\n

\u4f60\u53ef\u4ee5\u4f7f\u7528\u4f60\u53d1\u884c\u7248\u7684\u8f6f\u4ef6\u5305\u7ba1\u7406\u5668\u6765\u5b89\u88c5 gcc \u3002\u5728\u57fa\u4e8e Debian \u548c Ubuntu \u7684 Linux \u53d1\u884c\u7248\u4e2d\uff0c\u4f7f\u7528 apt \u547d\u4ee4\uff1a<\/p>\n

\r\nsudo apt install gcc\r\n<\/pre>\n

\u5207\u6362\u5230\u4fdd\u5b58\u4f60\u7684 C \u7a0b\u5e8f\u7684\u76ee\u5f55\uff08\u6216\u8005\u63d0\u4f9b\u8def\u5f84\uff09\uff0c\u7136\u540e\u901a\u8fc7\u7f16\u8bd1\u7a0b\u5e8f\u751f\u6210\u5bf9\u8c61\u6587\u4ef6\uff1a<\/p>\n

\r\ngcc -o my_program my_program.c\r\n<\/pre>\n

\u8bb0\u4f4f\uff0c\u63d0\u4f9b\u8f93\u51fa\u5bf9\u8c61\u6587\u4ef6\uff08-o my_program\uff09\u662f\u53ef\u9009\u7684\u3002\u5982\u679c\u4f60\u4e0d\u63d0\u4f9b\uff0c\u90a3\u4e48\u5c06\u81ea\u52a8\u751f\u6210\u4e00\u4e2a\u540d\u79f0\u4e3a a.out \u7684\u5bf9\u8c61\u6587\u4ef6\u3002\u4f46\u662f\u8fd9\u6837\u5e76\u4e0d\u597d\uff0c\u56e0\u4e3a\u7f16\u8bd1\u6bcf\u4e2a C \u7a0b\u5e8f\u90fd\u4f1a\u8986\u76d6\u5b83\uff0c\u800c\u4e14\u4f60\u4e5f\u4e0d\u77e5\u9053\u8fd9\u4e2a a.out \u5bf9\u8c61\u6587\u4ef6\u7a76\u7adf\u5c5e\u4e8e\u54ea\u4e2a\u7a0b\u5e8f\u3002<\/p>\n

\u5728\u4f60\u7684\u5bf9\u8c61\u6587\u4ef6\u751f\u6210\u540e\uff0c\u8fd0\u884c\u5b83\u6765\u8fd0\u884c C \u7a0b\u5e8f\u3002\u5b83\u5df2\u7ecf\u80fd\u591f\u6267\u884c\u4e86\u3002\u50cf\u8fd9\u6837\u7b80\u5355\u5730\u4f7f\u7528\u5b83\uff1a<\/p>\n

\r\n.\/my_program\r\n<\/pre>\n

\u63a5\u4e0b\u6765\uff0c\u5982\u679c\u4f60\u7684\u7a0b\u5e8f\u662f\u6b63\u786e\u7684\uff0c\u5b83\u5c06\u663e\u793a\u51fa\u4f60\u6240\u671f\u671b\u7684\u8f93\u51fa\u3002\u6b63\u5982\u4f60\u6240\u770b\u5230\u7684\uff0c\u8fd9\u548c \u5728 Linux \u4e2d\u8fd0\u884c C++ \u7a0b\u5e8f \u6ca1\u4ec0\u4e48\u4e0d\u540c\u3002<\/p>\n

\u6bcf\u66f4\u6539\u4e00\u6b21\u4f60\u7684\u7a0b\u5e8f\uff0c\u4f60\u90fd\u5fc5\u987b\u5148\u91cd\u65b0\u7f16\u8bd1\u5b83\uff0c\u7136\u540e\u518d\u6b21\u8fd0\u884c\u751f\u6210\u7684\u5bf9\u8c61\u6587\u4ef6\u6765\u8fd0\u884c\u8fd9\u4e2a\u65b0\u7684 C \u7a0b\u5e8f\u3002<\/p>\n

\u65b9\u6cd5 2: \u5982\u4f55\u5728 Linux \u4e2d\u4f7f\u7528\u4e00\u4e2a\u8bf8\u5982 VSCode \u4e4b\u7c7b\u7684\u4ee3\u7801\u7f16\u8f91\u5668\u6765\u8fd0\u884c C \u7a0b\u5e8f<\/strong><\/div>\n

\u5e76\u4e0d\u662f\u6bcf\u4e00\u4e2a\u4eba\u90fd\u80fd\u9002\u5e94\u547d\u4ee4\u884c\u548c\u7ec8\u7aef\uff0c\u6211\u5b8c\u5168\u7406\u89e3\u8fd9\u4e00\u70b9\u3002<\/p>\n

\u4f60\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e2a\u8bf8\u5982 Eclipse \u6216 Code Blocks \u4e4b\u7c7b\u7684\u771f\u6b63\u7684 C\/C++ IDE \uff0c\u4f46\u662f\u5b83\u4eec\u662f\u5f88\u91cd\u91cf\u7ea7\u7684\u7a0b\u5e8f\uff0c\u901a\u5e38\u66f4\u9002\u5408\u4e8e\u5927\u578b\u7684\u9879\u76ee\u3002<\/p>\n

\u6211\u5efa\u8bae\u4f7f\u7528\u4e00\u4e2a\u5f00\u6e90\u7684\u4ee3\u7801\u7f16\u8f91\u5668\uff0c\u50cf VSCode \u6216 Atom \u3002\u5b83\u4eec\u57fa\u672c\u4e0a\u662f\u6587\u672c\u7f16\u8f91\u5668\uff0c\u4f46\u662f\u4f60\u53ef\u4ee5\u901a\u8fc7\u5b89\u88c5\u9644\u52a0\u7ec4\u4ef6\u6765\u76f4\u63a5\u5728\u56fe\u5f62\u5316\u7684\u4ee3\u7801\u7f16\u8f91\u5668\u4e2d\u7f16\u8bd1\u548c\u8fd0\u884c\u7a0b\u5e8f\u3002<\/p>\n

\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4f7f\u7528 VSCode \u7f16\u8f91\u5668\u3002\u5b83\u662f\u4e00\u4e2a\u6765\u81ea\u5fae\u8f6f\u7684 \u975e\u5e38\u6d41\u884c\u7684\u5f00\u6e90\u7684\u4ee3\u7801\u7f16\u8f91\u5668 \u3002<\/p>\n

\u9996\u5148\uff0c\u5728 Ubuntu \u7684 \u8f6f\u4ef6\u4e2d\u5fc3\u4e2d\u5b89\u88c5 VSCode \u3002\u5bf9\u4e8e\u5176\u5b83\u53d1\u884c\u7248\u6765\u8bf4\uff0c\u8bf7\u68c0\u67e5\u4f60\u7684 Linux \u53d1\u884c\u7248\u7684\u8f6f\u4ef6\u5305\u7ba1\u7406\u5668\u6216\u8f6f\u4ef6\u4e2d\u5fc3\u3002\u4f60\u53ef\u4ee5\u53c2\u770b\u5b83\u7684\u5b98\u65b9\u7f51\u7ad9\u6765\u67e5\u770b\u66f4\u591a\u7684\u4fe1\u606f\u3002<\/p>\n

\u542f\u52a8 VSCode \uff0c\u6253\u5f00\u6216\u521b\u5efa\u4e00\u4e2a\u5de5\u7a0b\uff0c\u5728\u8fd9\u91cc\u521b\u5efa\u4f60\u7684 C \u7a0b\u5e8f\u3002\u6211\u4f7f\u7528\u4e00\u4e2a\u7b80\u5355\u7684 Hello World \u7a0b\u5e8f\u4f5c\u4e3a\u793a\u4f8b\u3002<\/p>\n

\"\"<\/p>\n

\u4f60\u5fc5\u987b\u786e\u4fdd\u4f60\u5df2\u7ecf\u5728\u4f60\u7684 Linux \u7cfb\u7edf\u4e0a\u5b89\u88c5\u4e86 gcc \u7f16\u8bd1\u5668\u3002<\/p>\n

\r\nsudo apt install gcc\r\n<\/pre>\n

\u63a5\u4e0b\u6765\u4f60\u8981\u505a\u7684\u4e8b\u662f\u4f7f\u7528\u4e00\u4e2a\u5141\u8bb8\u4f60\u8fd0\u884c C \u4ee3\u7801\u7684\u6269\u5c55\u3002\u5fae\u8f6f\u53ef\u80fd\u4f1a\u63d0\u793a\u4f60\u5b89\u88c5\u5b83\u7684 C\/C++ \u7a0b\u5e8f\u6269\u5c55\uff0c\u4f46\u5b83\u7684\u8bbe\u7f6e\u5f88\u590d\u6742\uff0c\u56e0\u6b64\u6211\u4e0d\u63a8\u8350\u3002<\/p>\n

\u76f8\u53cd\uff0c\u6211\u5efa\u8bae\u4f60\u4f7f\u7528 Code Runner \u6269\u5c55\u3002\u5b83\u662f\u4e00\u4e2a\u7b80\u5355\u76f4\u63a5\u7684\u6269\u5c55\uff0c\u4f60\u53ef\u4ee5\u5728\u4e0d\u4f7f\u7528\u989d\u5916\u914d\u7f6e\u7684\u60c5\u51b5\u4e0b\u8f7b\u677e\u5730\u8fd0\u884c C \u548c C++ \u4ee3\u7801\u3002<\/p>\n

\u8f6c\u5230\u6269\u5c55\u6807\u7b7e\u9875\uff0c\u5728\u5176\u4e2d\u641c\u7d22\u548c\u5b89\u88c5 \u201cCode Runner\u201d \u3002<\/p>\n

\"\"<\/p>\n

\u5b89\u88c5 Code Runner \u6269\u5c55\u6765\u8fd0\u884c C\/C++ \u7a0b\u5e8f<\/p>\n

\u91cd\u65b0\u542f\u52a8 VSCode \u3002\u73b0\u5728\uff0c\u4f60\u80fd\u591f\u4f7f\u7528\u4e0b\u9762\u65b9\u6cd5\u4e2d\u7684\u5176\u4e2d\u4e00\u4e2a\u6765\u8fd0\u884c C \u4ee3\u7801\uff1a<\/p>\n

  • \u4f7f\u7528\u5feb\u6377\u952e Ctrl+Alt+N \u3002<\/li>\n
  • \u6309\u4e0b F1 \uff0c\u63a5\u4e0b\u6765\u9009\u62e9\u6216\u8f93\u5165 \u201cRun Code\u201d \u3002<\/li>\n
  • \u5728\u6587\u672c\u7f16\u8f91\u5668\u4e2d\u53f3\u952e\u5355\u51fb\uff0c\u4ece\u4e0a\u4e0b\u6587\u83dc\u5355\u4e2d\u5355\u51fb \u201cRun code\u201d \u3002<\/li>\n

    \"\"<\/p>\n

    \u53f3\u952e\u5355\u51fb\u7a0b\u5e8f\u6587\u4ef6\uff0c\u7136\u540e\u9009\u62e9 Run Code<\/p>\n

    \u5f53\u4f60\u8fd0\u884c\u8fd9\u4e2a C \u7a0b\u5e8f\u65f6\uff0c\u5b83\u5c06\u4f1a\u88ab\u81ea\u52a8\u7f16\u8bd1\u548c\u8fd0\u884c\u3002\u4f60\u53ef\u4ee5\u5728\u7f16\u8f91\u5668\u5e95\u90e8\u6253\u5f00\u7684\u7ec8\u7aef\u4e2d\u770b\u5230\u8f93\u51fa\u3002\u8fd8\u6709\u6bd4\u8fd9\u66f4\u597d\u7684\u4e8b\u60c5\u5417\uff1f<\/p>\n

    \"\"<\/p>\n

    \u7a0b\u5e8f\u8f93\u51fa\u663e\u793a\u5728\u7f16\u8f91\u5668\u7684\u5e95\u90e8<\/p>\n

    \u4f60\u66f4\u559c\u6b22\u54ea\u4e00\u79cd\u65b9\u6cd5\uff1f<\/p>\n

    \u5728 Linux \u547d\u4ee4\u884c\u4e2d\u8fd0\u884c\u4e00\u4e9b C \u7a0b\u5e8f\u662f\u6ca1\u6709\u95ee\u9898\u7684\uff0c\u4f46\u662f\u4f7f\u7528\u4e00\u4e2a\u4ee3\u7801\u7f16\u8f91\u5668\u4f1a\u66f4\u5bb9\u6613\u4e00\u4e9b\uff0c\u800c\u4e14\u4f1a\u8282\u7701\u65f6\u95f4\u3002\u4f60\u4e0d\u89c9\u5f97\u5417\uff1f<\/p>\n

    \u4f60\u53ef\u4ee5\u81ea\u5df1\u51b3\u5b9a\u60f3\u4f7f\u7528\u54ea\u4e00\u79cd\u65b9\u6cd5\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

    \u6b65\u9aa4 1: \u7f16\u5199\u4f60\u7684 C \u7a0b\u5e8f\uff0c\u5e76\u4f7f\u7528\u4e00\u4e2a .c \u7684\u6269\u5c55\u540d\u8fdb\u884c\u4fdd\u5b58\u3002\u4f8b\u5982\uff0cmy_program.c \u3002 \u6b65\u9aa4 […]<\/p>\n","protected":false},"author":362,"featured_media":208061,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-208053","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/208053","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\/362"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=208053"}],"version-history":[{"count":8,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/208053\/revisions"}],"predecessor-version":[{"id":208083,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/208053\/revisions\/208083"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/208061"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=208053"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=208053"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=208053"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}