| 
									
										
										
										
											2025-02-03 10:59:02 +00:00
										 |  |  | --- | 
					
						
							|  |  |  | last_review_date: "1970-01-01" | 
					
						
							|  |  |  | --- | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-26 14:54:36 +00:00
										 |  |  | # C++ Standard Libraries
 | 
					
						
							| 
									
										
										
										
											2017-01-04 16:16:00 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-26 14:54:36 +00:00
										 |  |  | There are two C++ standard libraries supported by Apple compilers. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-06 15:07:00 +01:00
										 |  |  | The default for 10.9 and later is **libc++**, which is also the default for `clang` on older | 
					
						
							|  |  |  | platforms when building C++11 code. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | The default for 10.8 and earlier was **libstdc++**, supported by Apple GCC | 
					
						
							| 
									
										
										
										
											2017-03-25 22:53:33 -04:00
										 |  |  | compilers, GNU GCC compilers, and `clang`. This was marked deprecated with a | 
					
						
							| 
									
										
										
										
											2018-10-05 17:23:22 -04:00
										 |  |  | warning during compilation as of Xcode 8. | 
					
						
							| 
									
										
										
										
											2014-10-26 14:54:36 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-14 17:29:07 +01:00
										 |  |  | There are subtle incompatibilities between several of the C++ standard libraries, | 
					
						
							|  |  |  | so Homebrew will refuse to install software if a dependency was built with an | 
					
						
							|  |  |  | incompatible C++ library. It's recommended that you install the dependency tree | 
					
						
							|  |  |  | using a compatible compiler. | 
					
						
							| 
									
										
										
										
											2014-10-26 14:54:36 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-05 17:23:22 -04:00
										 |  |  | **If you've upgraded to 10.9 or later from an earlier version:** Because the default C++ | 
					
						
							| 
									
										
										
										
											2016-09-14 17:29:07 +01:00
										 |  |  | standard library is now libc++, you may not be able to build software using | 
					
						
							| 
									
										
										
										
											2018-10-05 17:23:22 -04:00
										 |  |  | dependencies that you built on 10.8 or earlier. If you're reading this page because | 
					
						
							| 
									
										
										
										
											2016-09-14 17:29:07 +01:00
										 |  |  | you were directed here by a build error, you can most likely fix the issue if | 
					
						
							|  |  |  | you reinstall all the dependencies of the package you're trying to build. | 
					
						
							| 
									
										
										
										
											2014-10-26 14:54:36 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-22 17:42:46 -04:00
										 |  |  | Example install using GCC 9: | 
					
						
							| 
									
										
										
										
											2018-10-05 17:23:22 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | ```sh | 
					
						
							| 
									
										
										
										
											2024-08-22 17:42:46 -04:00
										 |  |  | brew install gcc@9 | 
					
						
							|  |  |  | brew install --cc=gcc-9 <formula> | 
					
						
							| 
									
										
										
										
											2018-10-05 17:23:22 -04:00
										 |  |  | ``` |