Home >Backend Development >C++ >When to Specify \'-stdlib=libstdc \' when Compiling with GCC?
When to Use -stdlib=libstdc
When compiling with gcc, the -stdlib=libstdc flag specifies the C standard library to use. In most cases, the compiler will automatically use libstdc , the GNU C library, as the default. However, there are instances where it may be necessary to explicitly specify -stdlib=libstdc .
Compiler-Specific Behavior
On Linux, all major distributions use libstdc as the default C library, and recent GCC versions support C 11 by default. To compile C 11 code, you can use either:
On OS X prior to Mavericks, g was an alias for clang , and Apple's older libstdc was the default. To use libc , which includes C 11 library support, pass -stdlib=libc . Compilation options include:
OS X Mavericks and Later
Since OS X Mavericks, libc has become the default C library. You should refrain from using the -stdlib= flag in this case. Notably, Xcode 10 and later no longer support compiling against libstdc .
Recommended Compilation Options
The above is the detailed content of When to Specify \'-stdlib=libstdc \' when Compiling with GCC?. For more information, please follow other related articles on the PHP Chinese website!