{"id":276941,"date":"2023-07-09T04:01:05","date_gmt":"2023-07-08T20:01:05","guid":{"rendered":"https:\/\/lrxjmw.cn\/llxazghgdbzh.html"},"modified":"2023-07-09T04:01:05","modified_gmt":"2023-07-08T20:01:05","slug":"llxazghgdbzh","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/llxazghgdbzh.html","title":{"rendered":"Linux\u79bb\u7ebf\u5b89\u88c5GCC\u548cG++\u7684\u6b65\u9aa4\u548c\u6b65\u9aa4"},"content":{"rendered":"
###\u56de\u7b541\uff1aLinux<\/a>\u79bb\u7ebf\u5b89\u88c5GCC\u548cG++\u7684\u6b65\u9aa4\u5982\u4e0b\uff1a1.\u4e0b\u8f7dGCC\u548cG++\u7684\u6e90\u4ee3\u7801\u5305linux\u8f6f\u4ef6\uff0c\u53ef\u4ee5\u4ece\u5b98\u65b9\u7f51\u7ad9\u6216\u955c\u50cf\u7ad9\u70b9\u4e0b\u8f7d\u30022.\u89e3\u538b\u6e90\u4ee3\u7801\u5305\uff0c\u6b65\u5165\u89e3\u538b\u540e\u7684\u76ee\u5f55\u30023.\u6267\u884cconfigure\u547d\u4ee4<\/a>\uff0c\u751f\u6210Makefile\u6587\u4ef6\u3002\u547d\u4ee4\u683c\u5f0f\u4e3a\uff1a.\/configure--prefix=\/usr\/local\/gcc--disable-multilib\u30024.\u6267\u884cmake\u547d\u4ee4\uff0c\u7f16\u8bd1\u6e90\u4ee3\u7801\u3002\u547d\u4ee4\u683c\u5f0f\u4e3a\uff1amake-j4\u30025.\u6267\u884cmakeinstall\u547d\u4ee4\uff0c\u5b89\u88c5GCC\u548cG++\u3002\u547d\u4ee4\u683c\u5f0f\u4e3a\uff1amakeinstall\u30026.\u914d\u7f6e\u73af\u5883\u53d8\u91cf\uff0c\u5c06GCC\u548cG++\u7684\u8def\u5f84\u6dfb\u52a0\u5230PATH\u73af\u5883\u53d8\u91cf\u4e2d\u3002\u53ef\u4ee5\u5728\/etc\/profile\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9\uff1aexportPATH=\/usr\/local\/gcc\/bin:$PATH7.\u9a8c\u8bc1\u5b89\u88c5\u662f\u5426\u6210\u529f\uff0c\u6267\u884cgcc-v\u548cg++-v\u547d\u4ee4\uff0c\u67e5\u770b\u7248\u672c\u4fe1\u606f\u3002\u4ee5\u4e0a\u5c31\u662fLinux\u79bb\u7ebf\u5b89\u88c5GCC\u548cG++\u7684\u6b65\u9aa4\u3002###\u56de\u7b542\uff1aLinux\u662f\u4e00\u6b3e\u5f00\u6e90\u7684\u64cd\u4f5c\u7cfb\u7edf<\/a>\uff0c\u7531\u4e8e\u5176\u5b8c\u5907\u7684\u5f00\u53d1\u5de5\u5177\u548c\u5e9e\u5927\u7684\u7528\u6237\u7fa4\u4f53\uff0c\u5b83\u6210\u4e3a\u4e86\u8bf8\u591a\u5f00\u53d1\u8005\u7684\u9996\u9009\u3002\u5728Linux\u7cfb\u7edf\u4e2dlinux\u683c\u5f0f\u5316\u547d\u4ee4\uff0cgcc\u548cg\u8fd9\u4e24\u4e2a\u5de5\u5177\u7684\u5b89\u88c5\u662f\u5341\u5206\u91cd\u8981\u7684\uff0c\u7531\u4e8e\u5b83\u4eec\u662f\u7f16\u8bd1\u548c\u8054\u63a5\u7a0b\u5e8f\u6240\u5fc5\u987b\u7684\u3002<\/p>\n \u5047\u5982\u4f60\u7684\u7cfb\u7edf\u6ca1\u6709\u8054\u63a5\u5230\u4e92\u8054\u7f51\uff0c\u8fd9\u4e48\u4f60\u987b\u8981\u8fdb\u884c\u79bb\u7ebf\u5b89\u88c5\u3002\u4e0b\u8fb9\u662f\u4e00\u4e9b\u6b65\u9aa4\uff0c\u5e2e\u52a9\u4f60\u79bb\u7ebf\u5b89\u88c5gcc\u548cg\u30021.\u83b7\u53d6\u5b89\u88c5\u5305\u9996\u5148\u987b\u8981\u83b7\u53d6gcc\u548cg\u7684\u5b89\u88c5\u5305\u3002\u4e00\u822c\uff0c\u8fd9\u79cd\u5b89\u88c5\u5305\u53ef\u4ee5\u4ece\u4f60\u7684Linux\u53d1\u884c\u7248\u7684\u5e93\u623f\u4e2d\u83b7\u5f97\u3002\u5047\u5982\u4f60\u6ca1\u6cd5\u901a\u8fc7\u4e92\u8054\u7f51\u83b7\u53d6\uff0c\u4f60\u5c31\u987b\u8981\u4ece\u5176\u4ed6\u7684\u6e20\u9053\u83b7\u53d6\uff0c\u6bd4\u5982\u4ece\u540c\u5b66\u7684\u7b14\u8bb0\u672c\u6216\u901a\u8fc7\u8054\u901a\u8bbe\u5907\u3002\u5b89\u88c5\u5305\u987b\u8981\u4e0b\u8f7d\u5e76\u50a8\u5b58\u5728\u672c\u5730\u30022.\u5b89\u88c5\u524d\u4f9d\u8d56\u5728Linux\u4e2d\u7f16\u8bd1\u5b89\u88c5linux<\/strong>\uff0c\u4e00\u4e9b\u8f6f\u4ef6\u5305\u7684\u5b89\u88c5\u987b\u8981\u5148\u5b89\u88c5\u5176\u4ed6\u7684\u8f6f\u4ef6\u5305\u6216\u5e93\uff0c\u8fd9\u79cd\u4f9d\u8d56\u7684\u8f6f\u4ef6\u5305\u987b\u8981\u5728\u5b89\u88c5\u524d\u5b89\u88c5\u3002\u4f60\u987b\u8981\u68c0\u6d4b\u4f60\u7684Linux\u53d1\u884c\u7248\u63d0\u4f9b\u4e86\u4ec0\u4e48\u4f9d\u8d56\u7684\u8f6f\u4ef6\u5305\uff0c\u4e4b\u540e\u5c06\u5b83\u4eec\u9010\u4e00\u5730\u5b89\u88c5\u30023.\u5b89\u88c5gcc\u548cg\u4e0b\u8f7d\u597d\u6240\u6709\u7684\u4f9d\u8d56\u5305\u4ee5\u540e\uff0c\u63a5\u51fa\u6765\u5c31\u987b\u8981\u5b89\u88c5gcc\u548cg\u4e86\u3002\u5728\u7ec8\u7aef\u4e2d\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6765\u5b89\u88c5gcc\u548cg\uff1a```tar-xfgcc_\u7248\u672c\u53f7.tar.gzcdgcc_\u7248\u672c\u53f7.\/configure--prefix=\/usr\/local\/gccmakemakeinstall```\u4ee5\u4e0a\u547d\u4ee4\u89e3\u91ca\uff1a-tar\u547d\u4ee4\u89e3\u538b\u7f29\u5b89\u88c5\u5305-cd\u547d\u4ee4\u6b65\u5165gcc\u7684\u76ee\u5f55\u4e0b-.\/configure\u662f\u8fd0\u884cconfigure\u811a\u672c\uff0c\u7528\u4e8e\u76d1\u6d4b\u7cfb\u7edf\u73af\u5883\u3002--prefix\u9009\u9879\u6307\u5b9a\u4e86\u5b89\u88c5\u7684\u76ee\u5f55\uff0c\u5728\u8fd9\u513f\u662f\/usr\/local\/gcc\u3002<\/p>\n -make\u547d\u4ee4\u7528\u4e8e\u7f16\u8bd1-makeinstall\u7528\u4e8e\u5b89\u88c54.\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u5728\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u987b\u8981\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\uff0c\u4fbf\u4e8e\u7cfb\u7edf\u4e2d\u4efb\u4f55\u5730\u65b9\u90fd\u53ef\u4ee5\u4f7f\u7528gcc\u548cg\u3002\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u884c\uff1a```echo\"exportPATH=\/usr\/local\/gcc\/bin:$PATH\">>~\/.bashrcsource~\/.bashrc```\u4ee5\u4e0a\u547d\u4ee4\u89e3\u91ca\uff1a-echo\"exportPATH=\/usr\/local\/gcc\/bin:$PATH\">>~\/.bashrc\uff0c\u8be5\u547d\u4ee4\u62ff\u6765\u5c06\u8def\u5f84\/usr\/local\/gcc\/bin\u52a0\u5165\u73af\u5883\u53d8\u91cf\u4e2d-source~\/.bashrc\u662f\u7528\u4e8e\u8bfb\u53d6.bashrc\u6587\u4ef6\u7684\u53d8\u52a8\uff0c\u5047\u82e5\u4e0d\u8fd9\u6837\u505a\uff0c\u6539\u53d8\u73af\u5883\u53d8\u91cf\u662f\u4e0d\u8d77\u4f5c\u7528\u7684\u3002\u8fd9\u79cd\u6b65\u9aa4\u5b8c\u6210\u540e\uff0c\u4f60\u7684\u7cfb\u7edf\u4e2d\u5c31\u65e9\u5df2\u6210\u529f\u5b89\u88c5\u4e86gcc\u548cg\uff0c\u4f60\u53ef\u4ee5\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165gcc\u6216g\u7684\u547d\u4ee4\u6765\u9a8c\u8bc1\u5b89\u88c5\u662f\u5426\u6210\u529f\u4e86\u3002\u5047\u5982\u4f60\u7684\u7cfb\u7edf\u4e0d\u80fd\u8054\u63a5\u5230\u4e92\u8054\u7f51\uff0c\u5982\u4eca\u5df2\u7136\u53ef\u4ee5\u4f7f\u7528gcc\u548cg\u6765\u7f16\u8bd1\u7a0b\u5e8f\u4e86\u3002###\u56de\u7b543\uff1aLinux\u662f\u4e00\u79cd\u5e38\u7528\u7684\u64cd\u4f5c\u7cfb\u7edf\uff0c\u5728\u5f00\u53d1\u8fc7\u7a0b\u4e2d\uff0c\u5e38\u5e38\u987b\u8981\u4f7f\u7528gcc\u7f16\u8bd1\u5668\u548cg++\u7f16\u8bd1\u5668\u6765\u8fdb\u884c\u4ee3\u7801\u7684\u7f16\u8bd1\u548c\u91cd\u6784\u3002\u5e76\u4e14\u5728\u4e2a\u522b\u60c5\u51b5\u4e0b\u7f16\u8bd1\u5b89\u88c5linux<\/strong>\uff0c\u6211\u4eec\u53ef\u80fd\u987b\u8981\u5728\u6ca1\u6709\u7f51\u8def\u8054\u63a5\u7684\u60c5\u51b5\u4e0b\u5b89\u88c5\u8fd9\u79cd\u5de5\u5177\u3002<\/p>\n <\/p>\n \u4e0b\u8fb9\u4ecb\u7ecd\u4e00\u4e0b\u5728Linux\u7cfb\u7edf\u4e2d\u79bb\u7ebf\u5b89\u88c5gcc\u548cg++\u7f16\u8bd1\u5668\u7684\u6280\u5de7\u3002\u9996\u5148\uff0c\u6211\u4eec\u987b\u8981\u6253\u7b97\u597dgcc\u548cg++\u7f16\u8bd1\u5668\u7248\u672c\u7684\u5b89\u88c5\u6587\u4ef6\uff0c\u53ef\u4ee5\u4ece\u5b98\u65b9\u7f51\u7ad9\u6216\u5219\u955c\u50cf\u7f51\u7ad9\u4e0b\u8f7d\u5bf9\u5e94\u7248\u672c\u7684\u5b89\u88c5\u6587\u4ef6\u3002\u4e0b\u8f7d\u5b8c\u6210\u540e\uff0c\u5c06\u5b89\u88c5\u6587\u4ef6\u4f20\u8f93\u5230Linux\u7cfb\u7edf\u4e2d\uff0c\u7f6e\u4e8e\u4e00\u4e2a\u76ee\u5f55\u4e0b\uff0c\u6bd4\u5982\/opt\/gcc\u3002\u63a5\u51fa\u6765\uff0c\u6211\u4eec\u987b\u8981\u5b89\u88c5\u4f9d\u8d56\u5e93\u548c\u5de5\u5177\u5305\u3002\u5728Linux\u7cfb\u7edf\u4e2d\uff0cgcc\u548cg++\u7f16\u8bd1\u5668\u987b\u8981\u4f9d\u8d56\u4e00\u4e9b\u5e93\u548c\u5de5\u5177\u5305\uff0c\u4f8b\u5982binutils\u3001libmpc\u3001libmpfr\u3001libgmp\u3001mpc-devel\u3001mpfr-devel\u548cgmp-devel\u7b49\u3002\u5728\u6ca1\u6709\u7f51\u8def\u8054\u63a5\u7684\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u987b\u8981\u81ea\u52a8\u5b89\u88c5\u8fd9\u79cd\u4f9d\u8d56\u5e93\u548c\u5de5\u5177\u5305\u3002\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5\u4f9d\u8d56\u5e93\u548c\u5de5\u5177\u5305\uff1ayuminstall-ygccgcc-c++binutilslibmpclibmpfrlibgmpmpc-develmpfr-develgmp-devel\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u5f00\u59cb\u79bb\u7ebf\u5b89\u88c5gcc\u548cg++\u7f16\u8bd1\u5668\u3002\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u6b65\u5165\/opt\/gcc\u76ee\u5f55\uff1acd\/opt\/gcc\u89e3\u538b\u5b89\u88c5\u6587\u4ef6\uff1atar-zxvfgcc-XX.X.tar.gz\u6b65\u5165\u89e3\u538b\u540e\u7684\u76ee\u5f55\uff1acdgcc-XX.X\u521b\u5efa\u4e00\u4e2a\u76ee\u5f55\uff0c\u7528\u4e8e\u7f16\u8bd1\u5b89\u88c5\uff1amkdirbuild\u6b65\u5165build\u76ee\u5f55\uff1acdbuild\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u914d\u7f6e\u5e76\u7f16\u8bd1\uff1a..\/configure--prefix=\/opt\/gcc--disable-multilib--enable-languages=c,c++makemakeinstall\u8fd9\u4e2a\u8fc7\u7a0b\u53ef\u80fd\u987b\u8981\u8017\u8d39\u6bd4\u8f83\u957f\u7684\u65f6\u95f4\uff0c\u5177\u4f53\u65f6\u95f4\u53d6\u51b3\u4e8e\u7cfb\u7edf\u786c\u4ef6\u914d\u7f6e\u548c\u7f16\u8bd1\u5668\u7248\u672c\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770bgcc\u548cg++\u7f16\u8bd1\u5668\u7248\u672c\uff1a\/opt\/gcc\/bin\/gcc-v\/opt\/gcc\/bin\/g++-v\u81f3\u6b64\uff0c\u6211\u4eec\u65e9\u5df2\u5b8c\u6210\u4e86Linux\u7cfb\u7edf\u4e2d\u79bb\u7ebf\u5b89\u88c5gcc\u548cg++\u7f16\u8bd1\u5668\u7684\u8fc7\u7a0b\u3002\u5728\u6ca1\u6709\u7f51\u8def\u8054\u63a5\u7684\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u81ea\u52a8\u5b89\u88c5\u4f9d\u8d56\u5e93\u548c\u5de5\u5177\u5305\uff0c\u5e76\u4e0b\u8f7d\u5b89\u88c5\u6587\u4ef6\u8fdb\u884c\u5b89\u88c5\uff0c\u6765\u4f7f\u7528\u8fd9\u79cd\u5de5\u5177\u8fdb\u884c\u4ee3\u7801\u7f16\u8bd1\u548c\u91cd\u6784\u3002<\/p>\n","protected":false},"excerpt":{"rendered":" \u4e0b\u9762\u662f\u4e00\u4e9b\u6b65\u9aa4\uff0c\u5e2e\u52a9\u4f60\u79bb\u7ebf\u5b89\u88c5gcc\u548cg\u3002\u83b7\u53d6\u5b89\u88c5\u5305\u9996\u5148\u9700\u8981\u83b7\u53d6gcc\u548cg\u7684\u5b89\u88c5\u5305\u3002gcc_\u7248\u672c\u53f7.gcc_\u7248\u672c\u53f7.\u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u51c6\u5907\u597dgcc\u548cg++\u7f16\u8bd1\u5668\u7248\u672c\u7684\u5b89\u88c5\u6587\u4ef6\uff0c\u53ef\u4ee5\u4ece\u5b98\u65b9\u7f51\u7ad9\u6216\u8005\u955c\u50cf\u7f51\u7ad9\u4e0b\u8f7d\u5bf9\u5e94\u7248\u672c\u7684\u5b89\u88c5\u6587\u4ef6\u3002gmp-devel\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u5f00\u59cb\u79bb\u7ebf\u5b89\u88c5gcc\u548cg++\u7f16\u8bd1\u5668\u3002build\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u914d\u7f6e\u5e76\u7f16\u8bd1\uff1a.-v\u81f3\u6b64\uff0c\u6211\u4eec\u5df2\u7ecf\u5b8c\u6210\u4e86Linux\u7cfb\u7edf\u4e2d\u79bb\u7ebf\u5b89\u88c5gcc\u548cg++\u7f16\u8bd1\u5668\u7684\u8fc7\u7a0b\u3002<\/p>\n","protected":false},"author":1,"featured_media":276942,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[988],"tags":[999],"class_list":["post-276941","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\/276941","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=276941"}],"version-history":[{"count":0,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/276941\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/276942"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=276941"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=276941"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=276941"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}