');display:flex;inset:0;justify-content:center;position:absolute}.copy-to-clipboard-button[data-copy-state=copy-success]:before{content:url('data:image/svg+xml;utf8, ')}.kg-bookmark-card figcaption,.kg-gallery-card figcaption,.kg-image-card figcaption,.kg-video-card figcaption{padding-top:2px;text-align:center;--tw-text-opacity:1;color:rgb(71 85 105/var(--tw-text-opacity,1))}.kg-bookmark-card figcaption:is(.dark *),.kg-gallery-card figcaption:is(.dark *),.kg-image-card figcaption:is(.dark *),.kg-video-card figcaption:is(.dark *){--tw-text-opacity:1;color:rgb(203 213 225/var(--tw-text-opacity,1))}.kg-code-card figcaption{padding-top:2px;text-align:center;--tw-text-opacity:1;color:rgb(71 85 105/var(--tw-text-opacity,1))}.kg-code-card figcaption:is(.dark *){--tw-text-opacity:1;color:rgb(15 23 42/var(--tw-text-opacity,1))}.toc{overflow-y:auto}.toc>.toc-list{overflow:hidden;position:relative}.toc>.toc-list li{list-style:none}.js-toc{overflow-y:hidden}.toc-list{margin:0;padding-left:1.5rem}a.toc-link{color:currentColor;height:100%}.is-collapsible{max-height:1000px;overflow:hidden;transition:all .3s ease-in-out}.is-collapsed{max-height:0}.is-position-fixed{position:fixed!important;top:0}.is-active-link{font-weight:700}.toc-link:before{background-color:#eee;content:" ";display:inline-block;height:inherit;left:0;margin-top:-1px;position:absolute;width:2px}.is-active-link:before{background-color:#54bc4b}.toc-list-item{font-size:.95rem;margin-bottom:.5rem}.toc-link{border-radius:.25rem;color:#333;display:block;padding:.25rem .5rem;text-decoration:none;transition:color .2s ease}.toc-link:hover{background-color:#f3f4f6;color:#1e40af}.toc-link.is-active-link{background-color:#e0e7ff;color:#1e40af;font-weight:600}.toc-link.node-name--H2{font-size:1rem}.content img[width="20"],.content img[width="25"]{display:inline;margin-left:.25rem;margin-right:.25rem}.content table td[colspan="2"]{text-align:center}.content table td img{margin:auto}.first-letter\:uppercase:first-letter{text-transform:uppercase}.hover\:scale-110:hover{--tw-scale-x:1.1;--tw-scale-y:1.1;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.hover\:border-blue-400:hover{--tw-border-opacity:1;border-color:rgb(96 165 250/var(--tw-border-opacity,1))}.hover\:border-secondary-300:hover{--tw-border-opacity:1;border-color:rgb(203 213 225/var(--tw-border-opacity,1))}.hover\:bg-blue-700:hover{--tw-bg-opacity:1;background-color:rgb(29 78 216/var(--tw-bg-opacity,1))}.hover\:bg-gray-100:hover{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity,1))}.hover\:bg-gray-50:hover{--tw-bg-opacity:1;background-color:rgb(249 250 251/var(--tw-bg-opacity,1))}.hover\:bg-primary-100:hover{--tw-bg-opacity:1;background-color:rgb(224 242 254/var(--tw-bg-opacity,1))}.hover\:bg-primary-200:hover{--tw-bg-opacity:1;background-color:rgb(186 230 253/var(--tw-bg-opacity,1))}.hover\:bg-primary-50:hover{--tw-bg-opacity:1;background-color:rgb(240 249 255/var(--tw-bg-opacity,1))}.hover\:bg-primary-50\/80:hover{background-color:rgba(240,249,255,.8)}.hover\:bg-primary-700:hover{--tw-bg-opacity:1;background-color:rgb(29 78 216/var(--tw-bg-opacity,1))}.hover\:bg-red-100:hover{--tw-bg-opacity:1;background-color:rgb(254 226 226/var(--tw-bg-opacity,1))}.hover\:bg-secondary-100:hover{--tw-bg-opacity:1;background-color:rgb(241 245 249/var(--tw-bg-opacity,1))}.hover\:from-blue-600:hover{--tw-gradient-from:#2563eb var(--tw-gradient-from-position);--tw-gradient-to:rgba(37,99,235,0) var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-from),var(--tw-gradient-to)}.hover\:to-blue-700:hover{--tw-gradient-to:#1d4ed8 var(--tw-gradient-to-position)}.hover\:text-accent-600:hover{--tw-text-opacity:1;color:rgb(217 119 6/var(--tw-text-opacity,1))}.hover\:text-blue-600:hover{--tw-text-opacity:1;color:rgb(37 99 235/var(--tw-text-opacity,1))}.hover\:text-blue-800:hover{--tw-text-opacity:1;color:rgb(30 64 175/var(--tw-text-opacity,1))}.hover\:text-gray-400:hover{--tw-text-opacity:1;color:rgb(156 163 175/var(--tw-text-opacity,1))}.hover\:text-gray-700:hover{--tw-text-opacity:1;color:rgb(55 65 81/var(--tw-text-opacity,1))}.hover\:text-green-600:hover{--tw-text-opacity:1;color:rgb(22 163 74/var(--tw-text-opacity,1))}.hover\:text-primary-600:hover{--tw-text-opacity:1;color:rgb(37 99 235/var(--tw-text-opacity,1))}.hover\:text-primary-700:hover{--tw-text-opacity:1;color:rgb(29 78 216/var(--tw-text-opacity,1))}.hover\:text-secondary-700:hover{--tw-text-opacity:1;color:rgb(51 65 85/var(--tw-text-opacity,1))}.hover\:opacity-90:hover{opacity:.9}.hover\:shadow-lg:hover{--tw-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);--tw-shadow-colored:0 10px 15px -3px var(--tw-shadow-color),0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.focus\:border-transparent:focus{border-color:transparent}.focus\:bg-primary-50:focus{--tw-bg-opacity:1;background-color:rgb(240 249 255/var(--tw-bg-opacity,1))}.focus\:text-primary-600:focus{--tw-text-opacity:1;color:rgb(37 99 235/var(--tw-text-opacity,1))}.focus\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus\:ring-1:focus{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus\:ring-blue-500:focus{--tw-ring-opacity:1;--tw-ring-color:rgb(59 130 246/var(--tw-ring-opacity,1))}.focus\:ring-gray-500:focus{--tw-ring-opacity:1;--tw-ring-color:rgb(107 114 128/var(--tw-ring-opacity,1))}.focus\:ring-offset-2:focus{--tw-ring-offset-width:2px}.group:focus-within .group-focus-within\:opacity-100{opacity:1}.group:hover .group-hover\:visible,.group\/level2:hover .group-hover\/level2\:visible{visibility:visible}.group:hover .group-hover\:block{display:block}.group\/item:hover .group-hover\/item\:translate-x-1{--tw-translate-x:0.25rem}.group\/item:hover .group-hover\/item\:translate-x-1,.group\/level2:hover .group-hover\/level2\:translate-x-0{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.group\/level2:hover .group-hover\/level2\:translate-x-0{--tw-translate-x:0px}.group\/level2:hover .group-hover\/level2\:translate-x-1{--tw-translate-x:0.25rem}.group:hover .group-hover\:-translate-x-1,.group\/level2:hover .group-hover\/level2\:translate-x-1{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.group:hover .group-hover\:-translate-x-1{--tw-translate-x:-0.25rem}.group:hover .group-hover\:translate-x-1{--tw-translate-x:0.25rem}.group:hover .group-hover\:rotate-180,.group:hover .group-hover\:translate-x-1{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.group:hover .group-hover\:rotate-180{--tw-rotate:180deg}.group\/bookmark:hover .group-hover\/bookmark\:fill-current,.group\/comment:hover .group-hover\/comment\:fill-current,.group\/like:hover .group-hover\/like\:fill-current{fill:currentColor}.group:hover .group-hover\:fill-black\/75{fill:rgba(0,0,0,.75)}.group:hover .group-hover\:fill-current{fill:currentColor}.group:hover .group-hover\:text-primary-600{--tw-text-opacity:1;color:rgb(37 99 235/var(--tw-text-opacity,1))}.group:hover .group-hover\:opacity-100,.group\/level2:hover .group-hover\/level2\:opacity-100{opacity:1}.dark\:border-primary-400:is(.dark *){--tw-border-opacity:1;border-color:rgb(56 189 248/var(--tw-border-opacity,1))}.dark\:border-secondary-200:is(.dark *){--tw-border-opacity:1;border-color:rgb(226 232 240/var(--tw-border-opacity,1))}.dark\:border-secondary-600:is(.dark *){--tw-border-opacity:1;border-color:rgb(71 85 105/var(--tw-border-opacity,1))}.dark\:border-secondary-700:is(.dark *){--tw-border-opacity:1;border-color:rgb(51 65 85/var(--tw-border-opacity,1))}.dark\:bg-blue-900\/20:is(.dark *){background-color:rgba(30,58,138,.2)}.dark\:bg-gray-800:is(.dark *){--tw-bg-opacity:1;background-color:rgb(31 41 55/var(--tw-bg-opacity,1))}.dark\:bg-gray-800\/95:is(.dark *){background-color:rgba(31,41,55,.95)}.dark\:bg-gray-900:is(.dark *){--tw-bg-opacity:1;background-color:rgb(17 24 39/var(--tw-bg-opacity,1))}.dark\:bg-gray-900\/80:is(.dark *){background-color:rgba(17,24,39,.8)}.dark\:bg-primary-900:is(.dark *){--tw-bg-opacity:1;background-color:rgb(30 58 138/var(--tw-bg-opacity,1))}.dark\:bg-secondary-700:is(.dark *){--tw-bg-opacity:1;background-color:rgb(51 65 85/var(--tw-bg-opacity,1))}.dark\:bg-secondary-800:is(.dark *){--tw-bg-opacity:1;background-color:rgb(30 41 59/var(--tw-bg-opacity,1))}.dark\:bg-secondary-900:is(.dark *){--tw-bg-opacity:1;background-color:rgb(15 23 42/var(--tw-bg-opacity,1))}.dark\:bg-slate-400:is(.dark *){--tw-bg-opacity:1;background-color:rgb(148 163 184/var(--tw-bg-opacity,1))}.dark\:fill-white\/60:is(.dark *){fill:hsla(0,0%,100%,.6)}.dark\:fill-white\/70:is(.dark *){fill:hsla(0,0%,100%,.7)}.dark\:stroke-white\/60:is(.dark *){stroke:hsla(0,0%,100%,.6)}.dark\:text-\[rgba\(255\2c 255\2c 255\2c 0\.5\)\]:is(.dark *){color:hsla(0,0%,100%,.5)}.dark\:text-blue-400:is(.dark *){--tw-text-opacity:1;color:rgb(96 165 250/var(--tw-text-opacity,1))}.dark\:text-gray-100:is(.dark *){--tw-text-opacity:1;color:rgb(243 244 246/var(--tw-text-opacity,1))}.dark\:text-gray-200:is(.dark *){--tw-text-opacity:1;color:rgb(229 231 235/var(--tw-text-opacity,1))}.dark\:text-gray-300:is(.dark *){--tw-text-opacity:1;color:rgb(209 213 219/var(--tw-text-opacity,1))}.dark\:text-gray-400:is(.dark *){--tw-text-opacity:1;color:rgb(156 163 175/var(--tw-text-opacity,1))}.dark\:text-primary-400:is(.dark *){--tw-text-opacity:1;color:rgb(56 189 248/var(--tw-text-opacity,1))}.dark\:text-secondary-100:is(.dark *){--tw-text-opacity:1;color:rgb(241 245 249/var(--tw-text-opacity,1))}.dark\:text-secondary-300:is(.dark *){--tw-text-opacity:1;color:rgb(203 213 225/var(--tw-text-opacity,1))}.dark\:text-secondary-400:is(.dark *){--tw-text-opacity:1;color:rgb(148 163 184/var(--tw-text-opacity,1))}.dark\:text-secondary-600:is(.dark *){--tw-text-opacity:1;color:rgb(71 85 105/var(--tw-text-opacity,1))}.dark\:text-slate-200:is(.dark *){--tw-text-opacity:1;color:rgb(226 232 240/var(--tw-text-opacity,1))}.dark\:text-white:is(.dark *){--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity,1))}.dark\:shadow-gray-800\/50:is(.dark *){--tw-shadow-color:rgba(31,41,55,.5);--tw-shadow:var(--tw-shadow-colored)}.dark\:shadow-gray-900\/50:is(.dark *){--tw-shadow-color:rgba(17,24,39,.5);--tw-shadow:var(--tw-shadow-colored)}.dark\:ring-gray-700:is(.dark *){--tw-ring-opacity:1;--tw-ring-color:rgb(55 65 81/var(--tw-ring-opacity,1))}.dark\:ring-secondary-600:is(.dark *){--tw-ring-opacity:1;--tw-ring-color:rgb(71 85 105/var(--tw-ring-opacity,1))}.dark\:hover\:border-secondary-600:hover:is(.dark *){--tw-border-opacity:1;border-color:rgb(71 85 105/var(--tw-border-opacity,1))}.dark\:hover\:bg-gray-700:hover:is(.dark *){--tw-bg-opacity:1;background-color:rgb(55 65 81/var(--tw-bg-opacity,1))}.dark\:hover\:bg-gray-700\/80:hover:is(.dark *){background-color:rgba(55,65,81,.8)}.dark\:hover\:bg-gray-800:hover:is(.dark *){--tw-bg-opacity:1;background-color:rgb(31 41 55/var(--tw-bg-opacity,1))}.dark\:hover\:bg-secondary-700:hover:is(.dark *){--tw-bg-opacity:1;background-color:rgb(51 65 85/var(--tw-bg-opacity,1))}.dark\:hover\:text-accent-400:hover:is(.dark *){--tw-text-opacity:1;color:rgb(251 191 36/var(--tw-text-opacity,1))}.dark\:hover\:text-gray-200:hover:is(.dark *){--tw-text-opacity:1;color:rgb(229 231 235/var(--tw-text-opacity,1))}.dark\:hover\:text-green-400:hover:is(.dark *){--tw-text-opacity:1;color:rgb(74 222 128/var(--tw-text-opacity,1))}.dark\:hover\:text-primary-300:hover:is(.dark *){--tw-text-opacity:1;color:rgb(125 211 252/var(--tw-text-opacity,1))}.dark\:hover\:text-primary-400:hover:is(.dark *){--tw-text-opacity:1;color:rgb(56 189 248/var(--tw-text-opacity,1))}.dark\:hover\:text-secondary-300:hover:is(.dark *){--tw-text-opacity:1;color:rgb(203 213 225/var(--tw-text-opacity,1))}.dark\:focus\:bg-gray-700:focus:is(.dark *){--tw-bg-opacity:1;background-color:rgb(55 65 81/var(--tw-bg-opacity,1))}.dark\:focus\:bg-gray-800:focus:is(.dark *){--tw-bg-opacity:1;background-color:rgb(31 41 55/var(--tw-bg-opacity,1))}.dark\:focus\:text-primary-400:focus:is(.dark *){--tw-text-opacity:1;color:rgb(56 189 248/var(--tw-text-opacity,1))}.dark\:focus\:ring-offset-gray-800:focus:is(.dark *){--tw-ring-offset-color:#1f2937}.dark\:focus\:ring-offset-gray-900:focus:is(.dark *){--tw-ring-offset-color:#111827}.dark\:focus\:ring-offset-secondary-800:focus:is(.dark *){--tw-ring-offset-color:#1e293b}.dark\:focus\:ring-offset-secondary-900:focus:is(.dark *){--tw-ring-offset-color:#0f172a}.group:hover .dark\:group-hover\:fill-white\/75:is(.dark *){fill:hsla(0,0%,100%,.75)}.group:hover .dark\:group-hover\:text-primary-400:is(.dark *){--tw-text-opacity:1;color:rgb(56 189 248/var(--tw-text-opacity,1))}@media (min-width:640px){.sm\:col-span-1{grid-column:span 1/span 1}.sm\:mx-1{margin-left:.25rem;margin-right:.25rem}.sm\:mx-2{margin-left:.5rem;margin-right:.5rem}.sm\:inline{display:inline}.sm\:max-w-screen-sm{max-width:640px}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:p-8{padding:2rem}.sm\:px-5{padding-left:1.25rem;padding-right:1.25rem}.sm\:px-6{padding-left:1.5rem;padding-right:1.5rem}.sm\:px-8{padding-left:2rem;padding-right:2rem}.sm\:py-10{padding-bottom:2.5rem;padding-top:2.5rem}.sm\:py-3{padding-bottom:.75rem;padding-top:.75rem}}@media (min-width:768px){.md\:col-span-1{grid-column:span 1/span 1}.md\:h-14{height:3.5rem}.md\:h-96{height:24rem}.md\:w-14{width:3.5rem}.md\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.md\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.md\:flex-row{flex-direction:row}.md\:text-4xl{font-size:2.25rem;line-height:2.5rem}}@media (min-width:1024px){.lg\:invisible{visibility:hidden}.lg\:absolute{position:absolute}.lg\:left-0{left:0}.lg\:col-span-1{grid-column:span 1/span 1}.lg\:col-span-2{grid-column:span 2/span 2}.lg\:col-span-3{grid-column:span 3/span 3}.lg\:row-span-3{grid-row:span 3/span 3}.lg\:row-span-4{grid-row:span 4/span 4}.lg\:row-span-6{grid-row:span 6/span 6}.lg\:mt-2{margin-top:.5rem}.lg\:block{display:block}.lg\:inline{display:inline}.lg\:flex{display:flex}.lg\:hidden{display:none}.lg\:h-\[496px\]{height:496px}.lg\:w-48{width:12rem}.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.lg\:grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.lg\:grid-cols-\[auto_1fr_auto\]{grid-template-columns:auto 1fr auto}.lg\:flex-row{flex-direction:row}.lg\:items-center{align-items:center}.lg\:gap-2{gap:.5rem}.lg\:rounded-lg{border-radius:.5rem}.lg\:p-6{padding:1.5rem}.lg\:px-8{padding-left:2rem;padding-right:2rem}.lg\:py-2{padding-bottom:.5rem;padding-top:.5rem}.lg\:pl-0{padding-left:0}.lg\:text-3xl{font-size:1.875rem;line-height:2.25rem}.lg\:text-5xl{font-size:3rem;line-height:1}.lg\:opacity-0{opacity:0}.lg\:shadow-lg{--tw-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);--tw-shadow-colored:0 10px 15px -3px var(--tw-shadow-color),0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.lg\:ring-1{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.lg\:ring-black{--tw-ring-opacity:1;--tw-ring-color:rgb(0 0 0/var(--tw-ring-opacity,1))}.lg\:ring-opacity-5{--tw-ring-opacity:0.05}.group:focus-within .lg\:group-focus-within\:visible{visibility:visible}.group:hover .lg\:group-hover\:visible{visibility:visible}.group:hover .lg\:group-hover\:opacity-100{opacity:1}.dark\:lg\:shadow-gray-900\/50:is(.dark *){--tw-shadow-color:rgba(17,24,39,.5);--tw-shadow:var(--tw-shadow-colored)}.dark\:lg\:ring-gray-700:is(.dark *){--tw-ring-opacity:1;--tw-ring-color:rgb(55 65 81/var(--tw-ring-opacity,1))}}.gh-post-upgrade-cta{align-items:center;color:#fff;display:flex;flex-direction:column;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Open Sans,Helvetica Neue,sans-serif;font-size:16px;text-align:center;width:100%}.gh-post-upgrade-cta-content{border-radius:8px;padding:40px 4vw}.gh-post-upgrade-cta h2{color:#fff;font-size:28px;letter-spacing:-.2px;margin:0;padding:0}.gh-post-upgrade-cta p{margin:20px 0 0;padding:0}.gh-post-upgrade-cta small{font-size:16px;letter-spacing:-.2px}.gh-post-upgrade-cta a{cursor:pointer;font-weight:500}.gh-post-upgrade-cta a,.gh-post-upgrade-cta a:hover{box-shadow:none;color:#fff;text-decoration:underline}.gh-post-upgrade-cta a:hover{opacity:.8}.gh-post-upgrade-cta a.gh-btn{background:#fff;border-radius:4px;display:block;font-size:16px;font-weight:600;margin:28px 0 0;padding:8px 18px;text-decoration:none}.gh-post-upgrade-cta a.gh-btn:hover{opacity:.92}#search.loading{pointer-events:none}#search.loading i,#search.loading span,#search.loading svg{opacity:0;visibility:hidden}#search.loading:before{animation:search-loading-spin .8s linear infinite;border:3px solid rgba(0,0,0,.1);border-radius:50%;border-top-color:currentcolor;height:20px;margin:-10px 0 0 -10px;width:20px;z-index:1}#search.loading:after,#search.loading:before{content:"";left:50%;position:absolute;top:50%}#search.loading:after{animation:search-loading-pulse 1.5s ease-in-out infinite;background:rgba(0,0,0,.05);border-radius:50%;height:32px;margin:-16px 0 0 -16px;width:32px}@keyframes search-loading-spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}@keyframes search-loading-pulse{0%,to{opacity:.5;transform:scale(.8)}50%{opacity:.8;transform:scale(1.2)}}
GNU编译器是C,C ++,Objective-C,Fortran,Ada,Go 和D编程语言的编译器和库的集合。许多开源项目,包括Linux内核和GNU工具,都是使用GCC编译的。
除了这些语言使用gcc/g++编译器,Python和Node.js的第三方库或者软件,都可能会使用gcc
/g++
编译器。
安装GCC 默认的Ubuntu存储库包含一个名为build-essential
的开发者工具集,其中包括GNU编译器集合,GNU调试器以及编译软件所需的其他开发库和工具。
如需要安装build-essential
开发工具包,请以root用户或具有sudo权限的用户 运行以下apt
命令 :
sudo apt update
sudo apt install build-essential
该命令会安装很多软件开发者工具,包括gcc
,g++
和make
以及常用c/c++的头文件。
除了安装c/c++开发者工具之外,您还可能需要安装GNU/Linux开发手册,这些手册页描述了Linux编程接口的说明。
如果你是Linux开发者可能需要这些文档,运行以下apt
命令安装Linux编程接口的说明:
sudo apt-get install manpages-dev
至此,你已经完成gcc/g++开发工具的安装。
我们需要验证gcc/g++开发工具是否正确的安装,并检查gcc/g++的版本是否符号你要编写c/c++标准库的要求。
你可运行以下的gcc
/g++
命令打印GCC版本,验证GCC编译器是否已成功安装:
gcc --version
g++ --version
gcc (Ubuntu 9.3.0-10ubuntu2) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Ubuntu 20.04存储库的GCC版本是9.3.0
。至此gcc开发者工具和库已安装在您的Ubuntu系统上。
Hello World 在本节中,我们将使用gcc编译简单的C程序。打开您的喜欢代码编辑器 并创建以下hello.c
文件,在本教程中,我们将使用vscode编辑器 创建hello.c
文件。
使用快捷键ctrl+alt+t
打开终端,然后运行code
命令打开vscode编辑器:
code
创建hello.c文件,并复制以下代码到文件中:
// hello.c
#include <stdio.h>
int main() {
printf("Hello, world!\n");
return 0;
}
hello.c 保存文件,并通过运行以下gcc
命令将hello.c
编译为可执行文件:
gcc hello.c -o hello
gcc
命令将在当前目录中创建一个二进制文件hello
。你可通过以下命令执行hello
程序:
./hello
Hello World!
安装多个GCC版本 在本节中将说明如何在安装多个版本的gcc在Ubuntu 20.04。这可以使你获得GCC编译器的新版本,新功能和优化。编写更高版本标准库的代码。
在撰写本文时,默认的Ubuntu存储库包含从7.x.x
到10.x.x
的多个GCC版本。在以下示例中,我们将安装最新的三个版本的gcc
编译器和g++
编译器。
以下apt
命令将安装gcc
/g++
编译器的8/9/10的版本,你可选择全安装,也可以选择你是使用的编译器版本:
sudo apt install gcc-8 g++-8 gcc-9 g++-9 gcc-10 g++-10
现在已经安装多个版本的gcc
/g++
编译器的编译。我们需要一个简单快捷的方式切换gcc/g++版本。
update-alternatives
可以帮助我们快速切换gcc/g++的版本。update-alternatives
可以帮我们维护gcc
/g++
默认命令的符号链接 。使我们可以快速切换命令的版本。
由于gcc
/g++
安装的安装脚本并没有设置使用update-alternatives
设置默认的版本, 因此我们需要手动将gcc添加到update-alternatives
,并由update-alternatives
维护默认版本。
以下三个update-alternatives
命令将安装gcc编译器8/9/10版本,这时gcc的符号链接由update-alternatives
来维护。
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 100
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 100
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100
这里解释一下命令的含义,--install是update-alternatives
的子命令,/usr/bin/gcc是符号链接/软链接文件,/usr/bin/gcc-9
是gcc
的绝对路径,100是优先级。
你也可以使用同样的方式配置g++编译器命令的快速切换。由update-alternatives
维护g++命令的符号链接/软链接 。
设置update-alternatives
完成以后,如果要更改默认版本,请使用update-alternatives
命令:
sudo update-alternatives --config gcc
There are 3 choices for the alternative gcc (providing /usr/bin/gcc).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/bin/gcc-10 100 auto mode
1 /usr/bin/gcc-10 100 manual mode
2 /usr/bin/gcc-8 80 manual mode
3 /usr/bin/gcc-9 90 manual mode
Press <enter> to keep the current choice[*], or type selection number:
系统会为您提供Ubuntu系统上所有已安装GCC版本的列表。输入您要用作默认版本的版本号,然后按Enter
。
该命令将修改/usr/bin/gcc
符号链接,并将链接指向你选择的gcc
版本。g++的配置方式与gcc
一样。
结论 我们向您展示了如何安装gcc
/g++
在Ubuntu 20.04上。您现在可以访问官方GCC文档 页面,并学习如何使用GCC和G ++来编译C和C++程序。如果您遇到问题或有反馈,请在下面发表评论。
© 2025 myfreax. All rights reserved.