{"id":412,"date":"2025-07-20T11:05:15","date_gmt":"2025-07-20T03:05:15","guid":{"rendered":"https:\/\/www.hgfwq.com\/blog\/?p=412"},"modified":"2025-07-20T11:05:15","modified_gmt":"2025-07-20T03:05:15","slug":"ubuntu-%e5%8d%87%e7%ba%a7-gcc-%e5%a6%82%e4%bd%95%e6%8f%90%e5%8d%87%e5%bc%80%e5%8f%91%e6%95%88%e7%8e%87%e5%92%8c%e7%b3%bb%e7%bb%9f%e6%80%a7%e8%83%bd%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/www.hgfwq.com\/blog\/412.html","title":{"rendered":"Ubuntu \u5347\u7ea7 GCC \u5982\u4f55\u63d0\u5347\u5f00\u53d1\u6548\u7387\u548c\u7cfb\u7edf\u6027\u80fd\uff1f"},"content":{"rendered":"\n<p><h1>Ubuntu \u5347\u7ea7 GCC\uff1a\u63d0\u5347\u670d\u52a1\u5668\u6027\u80fd\u7684\u5173\u952e\u4e00\u6b65<\/h1>\n<\/p>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/www.hgfwq.com\/blog\/wp-content\/uploads\/2025\/07\/8DICfCE.jpg\" alt=\"Ubuntu \u5347\u7ea7 GCC \u5982\u4f55\u63d0\u5347\u5f00\u53d1\u6548\u7387\u548c\u7cfb\u7edf\u6027\u80fd\uff1f\" title=\"Ubuntu \u5347\u7ea7 GCC \u5982\u4f55\u63d0\u5347\u5f00\u53d1\u6548\u7387\u548c\u7cfb\u7edf\u6027\u80fd\uff1f\"><\/p>\n<p><p>\u5168\u7bc7\u7cbe\u534e\uff1a\u672c\u6587\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u5728Ubuntu\u670d\u52a1\u5668\u4e0a\u5347\u7ea7GCC\u7f16\u8bd1\u5668\uff0c\u4ee5\u63d0\u5347\u7cfb\u7edf\u6027\u80fd\u548c\u7f16\u8bd1\u6548\u7387\uff0c\u4e3a\u5f00\u53d1\u8005\u63d0\u4f9b\u66f4\u5f3a\u5927\u7684\u5f00\u53d1\u73af\u5883\u3002<\/p>\n<\/p>\n<p><h2>\u4e3a\u4ec0\u4e48\u9700\u8981\u5347\u7ea7GCC<\/h2>\n<\/p>\n<p><p>\u968f\u7740\u6280\u672f\u7684\u53d1\u5c55\uff0c\u65b0\u7684\u7f16\u7a0b\u8bed\u8a00\u548c\u6846\u67b6\u4e0d\u65ad\u6d8c\u73b0\uff0c\u5bf9\u7f16\u8bd1\u5668\u7684\u6027\u80fd\u548c\u529f\u80fd\u63d0\u51fa\u4e86\u66f4\u9ad8\u7684\u8981\u6c42\u3002GCC\uff08GNU Compiler Collection\uff09\u4f5c\u4e3a\u5f00\u6e90\u7684\u7f16\u8bd1\u5668\uff0c\u5176\u7248\u672c\u66f4\u65b0\u8fed\u4ee3\u8fc5\u901f\uff0c\u6bcf\u4e2a\u65b0\u7248\u672c\u90fd\u5e26\u6765\u4e86\u6027\u80fd\u63d0\u5347\u3001\u65b0\u7279\u6027\u652f\u6301\u548c\u5b89\u5168\u6027\u6539\u8fdb\u3002\u56e0\u6b64\uff0c\u5b9a\u671f\u5347\u7ea7GCC\u5bf9\u4e8e\u670d\u52a1\u5668\u6027\u80fd\u4f18\u5316\u548c\u5f00\u53d1\u6548\u7387\u63d0\u5347\u81f3\u5173\u91cd\u8981\u3002<\/p>\n<\/p>\n<p><h2>\u5347\u7ea7GCC\u524d\u7684\u51c6\u5907\u5de5\u4f5c<\/h2>\n<\/p>\n<p><p>\u5728\u5f00\u59cb\u5347\u7ea7GCC\u4e4b\u524d\uff0c\u8bf7\u786e\u4fdd\u60a8\u7684Ubuntu\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u5df2\u5b89\u88c5gcc\u548cg++\u3002<\/li>\n<li>\u670d\u52a1\u5668\u7f51\u7edc\u8fde\u63a5\u7a33\u5b9a\uff0c\u53ef\u4ee5\u8bbf\u95eeGCC\u7684\u5b98\u65b9\u6e90\u3002<\/li>\n<li>\u5907\u4efd\u91cd\u8981\u6570\u636e\uff0c\u4ee5\u9632\u5347\u7ea7\u8fc7\u7a0b\u4e2d\u51fa\u73b0\u610f\u5916\u3002<\/li>\n<\/ul>\n<p><h2>\u5347\u7ea7GCC\u7684\u5177\u4f53\u6b65\u9aa4<\/h2>\n<\/p>\n<p><p>\u4ee5\u4e0b\u662f\u5347\u7ea7GCC\u7684\u8be6\u7ec6\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u66f4\u65b0\u7cfb\u7edf\u8f6f\u4ef6\u5305\uff1a<\/li>\n<p><pre><code>sudo apt update<\/p>\r\n<p>sudo apt upgrade<\/code><\/pre>\n<\/p>\n<li>\u79fb\u9664\u65e7\u7684GCC\u7248\u672c\uff08\u5982\u679c\u5b58\u5728\uff09\uff1a<\/li>\n<p><pre><code>sudo apt-get remove gcc g++<\/code><\/pre>\n<\/p>\n<li>\u6dfb\u52a0GCC\u7684\u5b98\u65b9\u6e90\uff1a<\/li>\n<p><pre><code>echo \"deb http:\/\/ubuntu.cn.archive.ubuntu.com\/ubuntu\/ $(lsb_release -cs) main\" | sudo tee \/etc\/apt\/sources.list.d\/gcc.list<\/p>\r\n<p>echo \"deb-src http:\/\/ubuntu.cn.archive.ubuntu.com\/ubuntu\/ $(lsb_release -cs) main\" | sudo tee -a \/etc\/apt\/sources.list.d\/gcc.list<\/code><\/pre>\n<\/p>\n<li>\u6dfb\u52a0GCC\u7684GPG\u5bc6\u94a5\uff1a<\/li>\n<p><pre><code>sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E3FF2839C048B95B<\/code><\/pre>\n<\/p>\n<li>\u66f4\u65b0\u8f6f\u4ef6\u5305\u5217\u8868\uff1a<\/li>\n<p><pre><code>sudo apt update<\/code><\/pre>\n<\/p>\n<li>\u5b89\u88c5\u6700\u65b0\u7248\u672c\u7684GCC\uff1a<\/li>\n<p><pre><code>sudo apt install gcc-11 g++-11<\/code><\/pre>\n<\/p>\n<li>\u8bbe\u7f6e\u65b0\u7684GCC\u7248\u672c\u4e3a\u9ed8\u8ba4\u7248\u672c\uff1a<\/li>\n<p><pre><code>sudo update-alternatives --install \/usr\/bin\/gcc gcc \/usr\/bin\/gcc-11 60<\/p>\r\n<p>sudo update-alternatives --install \/usr\/bin\/g++ g++ \/usr\/bin\/g++-11 60<\/code><\/pre>\n<\/p>\n<li>\u9a8c\u8bc1GCC\u7248\u672c\uff1a<\/li>\n<p><pre><code>gcc --version<\/p>\r\n<p>g++ --version<\/code><\/pre>\n<\/p>\n<\/ol>\n<p><h2>\u5347\u7ea7\u540e\u7684\u6ce8\u610f\u4e8b\u9879<\/h2>\n<\/p>\n<p><p>\u5347\u7ea7GCC\u540e\uff0c\u4ee5\u4e0b\u4e8b\u9879\u9700\u8981\u6ce8\u610f\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u68c0\u67e5\u7f16\u8bd1\u540e\u7684\u7a0b\u5e8f\u662f\u5426\u6b63\u5e38\u8fd0\u884c\u3002<\/li>\n<li>\u66f4\u65b0\u7f16\u8bd1\u5668\u76f8\u5173\u7684\u811a\u672c\u548c\u914d\u7f6e\u6587\u4ef6\uff0c\u786e\u4fdd\u5b83\u4eec\u6307\u5411\u65b0\u7684GCC\u7248\u672c\u3002<\/li>\n<li>\u5982\u679c\u9047\u5230\u517c\u5bb9\u6027\u95ee\u9898\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u5b89\u88c5\u65e7\u7248\u672c\u7684GCC\u6216\u4f7f\u7528\u591a\u7248\u672c\u7f16\u8bd1\u5668\u5de5\u5177\u3002<\/li>\n<\/ul>\n<p><h2>\u5e38\u89c1\u95ee\u9898\u89e3\u7b54<\/h2>\n<\/p>\n<p><p><strong>Q\uff1a\u5347\u7ea7GCC\u540e\uff0c\u5982\u4f55\u6062\u590d\u5230\u65e7\u7248\u672c\uff1f<\/strong><\/p>\n<\/p>\n<p><p>A\uff1a\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u5378\u8f7d\u65b0\u7248\u672c\u7684GCC\uff0c\u5e76\u91cd\u65b0\u5b89\u88c5\u65e7\u7248\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code>sudo apt-get remove gcc-11 g++-11<\/p>\r\n<p>sudo apt-get install gcc g++<\/code><\/pre>\n<\/p>\n<p><p><strong>Q\uff1a\u5982\u4f55\u67e5\u770b\u6240\u6709\u53ef\u7528\u7684GCC\u7248\u672c\uff1f<\/strong><\/p>\n<\/p>\n<p><p>A\uff1a\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770b\u6240\u6709\u53ef\u7528\u7684GCC\u7248\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code>apt-cache madison gcc<\/code><\/pre>\n<\/p>\n<p><p><strong>Q\uff1a\u5347\u7ea7GCC\u662f\u5426\u4f1a\u5f71\u54cd\u5230\u7cfb\u7edf\u7a33\u5b9a\u6027\uff1f<\/strong><\/p>\n<\/p>\n<p><p>A\uff1a\u4e00\u822c\u60c5\u51b5\u4e0b\uff0c\u5347\u7ea7GCC\u4e0d\u4f1a\u5f71\u54cd\u7cfb\u7edf\u7a33\u5b9a\u6027\u3002\u4f46\u8bf7\u786e\u4fdd\u5728\u5347\u7ea7\u524d\u5907\u4efd\u91cd\u8981\u6570\u636e\uff0c\u5e76\u5728\u5347\u7ea7\u540e\u6d4b\u8bd5\u7cfb\u7edf\u6027\u80fd\u3002<\/p>\n<\/p>\n<p><h2>\u603b\u7ed3<\/h2>\n<\/p>\n<p><p>\u901a\u8fc7\u672c\u6587\uff0c\u6211\u4eec\u4e86\u89e3\u4e86\u5982\u4f55\u5728Ubuntu\u670d\u52a1\u5668\u4e0a\u5347\u7ea7GCC\uff0c\u4ee5\u63d0\u5347\u7cfb\u7edf\u6027\u80fd\u548c\u7f16\u8bd1\u6548\u7387\u3002\u5b9a\u671f\u5347\u7ea7GCC\u53ef\u4ee5\u4e3a\u5f00\u53d1\u8005\u63d0\u4f9b\u66f4\u5f3a\u5927\u7684\u5f00\u53d1\u73af\u5883\uff0c\u5e76\u786e\u4fdd\u9879\u76ee\u80fd\u591f\u5145\u5206\u5229\u7528\u6700\u65b0\u7684\u7f16\u7a0b\u8bed\u8a00\u548c\u6846\u67b6\u3002\u5728\u5347\u7ea7\u8fc7\u7a0b\u4e2d\uff0c\u8bf7\u9075\u5faa\u672c\u6587\u63d0\u4f9b\u7684\u6b65\u9aa4\uff0c\u5e76\u6ce8\u610f\u76f8\u5173\u6ce8\u610f\u4e8b\u9879\uff0c\u4ee5\u786e\u4fdd\u5347\u7ea7\u8fc7\u7a0b\u987a\u5229\u8fdb\u884c\u3002<\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ubuntu \u5347\u7ea7 GCC\uff1a\u63d0\u5347\u670d\u52a1\u5668\u6027\u80fd\u7684\u5173\u952e\u4e00\u6b65 \u5168\u7bc7\u7cbe\u534e\uff1a\u672c\u6587\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u5728Ubuntu\u670d\u52a1\u5668\u4e0a\u5347\u7ea7GCC\u7f16\u8bd1\u5668\uff0c\u4ee5\u63d0\u5347\u7cfb\u7edf\u6027\u80fd\u548c\u7f16\u8bd1\u6548\u7387\uff0c\u4e3a\u5f00\u53d1\u8005\u63d0\u4f9b\u66f4\u5f3a\u5927\u7684\u5f00\u53d1\u73af\u5883\u3002 \u4e3a\u4ec0\u4e48\u9700\u8981\u5347\u7ea7GCC \u968f\u7740\u6280\u672f\u7684\u53d1\u5c55\uff0c\u65b0\u7684\u7f16\u7a0b\u8bed\u8a00\u548c\u6846\u67b6\u4e0d\u65ad&#8230;<\/p>\n","protected":false},"author":1,"featured_media":413,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[211,130,212],"topic":[],"class_list":["post-412","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-haiwai","tag-gcc","tag-ubuntu","tag-212"],"_links":{"self":[{"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/posts\/412","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/comments?post=412"}],"version-history":[{"count":1,"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/posts\/412\/revisions"}],"predecessor-version":[{"id":415,"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/posts\/412\/revisions\/415"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/media\/413"}],"wp:attachment":[{"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/media?parent=412"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/categories?post=412"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/tags?post=412"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/topic?post=412"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}