Fix GCC 11 Missing Headers on Mac OS Monterey

Encountered this issue trying to compile a simple “Hello World” program with gcc-11 from homebrew. The compiler complained about fatal error: _stdio.h: No such file or directory. After some investigation, this was caused by wrong building configuration for gcc: $ gcc -v Using built-in specs. COLLECT_GCC=gcc-11 COLLECT_LTO_WRAPPER=/opt/homebrew/Cellar/gcc/11.2.0_3/libexec/gcc/aarch64-apple-darwin21/11/lto-wrapper Target: aarch64-apple-darwin21 Configured with: ../configure --prefix=/opt/homebrew/Cellar/gcc/11.2.0_3 --libdir=/opt/homebrew/Cellar/gcc/11.2.0_3/lib/gcc/11 --disable-nls --enable-checking=release --with-gcc-major-version-only --enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-11 --with-gmp=/opt/homebrew/opt/gmp --with-mpfr=/opt/homebrew/opt/mpfr --with-mpc=/opt/homebrew/opt/libmpc --with-isl=/opt/homebrew/opt/isl --with-zstd=/opt/homebrew/opt/zstd --with-pkgversion='Homebrew GCC 11.2.0_3' --with-bugurl=https://github.com/Homebrew/homebrew-core/issues --build=aarch64-apple-darwin21 --with-system-zlib --disable-multilib --with-native-system-header-dir=/usr/include --with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 11.2.0 (Homebrew GCC 11.2.0_3) The gcc from homebrew is assuming --with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk, but it doesn’t exists on Mac OS Monterey. Instead the path is /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk. As we now know the root cause of this issue, fixing it will be easy: ...

December 8, 2021

Quick Start Guide with create-react-app (TypeScript + Eslint + Prettier)

Why use create-react-app Originally I was using a manually written webpack script to build my react project. The reason was to reduce the length of package-lock.json. But as I’m diving deeper into the frontend ecosystem, it doesn’t look like a good choice to wait for frontend guys fixing the dependency hell. So instead of waiting for a neat solution, I need to find a quick solution. As part of the lessons I learned from handwriting webpack scripts, it’s hard to build a complete and reusable scaffold to build a React.js + TypeScript + ESLint project. create-react-app is good enough with only minimal extra configurations. This blog is mainly a note on how to quickly start another project later. ...

December 2, 2021

Migrate From Bash to Zsh

The story of bash and my taste on command line I’ve been using bash as the development environment for a long time. The reason for choosing bash is its ubiquity. Most desktop & server Linux distributions and Docker images will ship with bash, which makes it a great fit for a configure-once-use-everywhere development environment. So you write it once and copy it to every host you’ll write code on. But since ~2014 my bash configuration has degraded several times, for two major reasons: ...

November 28, 2021