LoginSignup
4

More than 3 years have passed since last update.

posted at

Organization

_cgo_export.c:3:10: fatal error: 'stdlib.h' file not found の解決方法

はじめに

開発中に遭遇した問題解決の備忘メモです。

問題事象

ローカル環境で go test を実行したところ、下記のエラーが表示され、実行できない状態になった。

_cgo_export.c:3:10: fatal error: 'stdlib.h' file not found

原因

原因はgolang関係なく、macOSをmojaveにアップグレードしたことの様子。

解決

多くのケースでは、 xcode-select --install で解決するみたいだが、自分の場合は、既に入っているよと怒られた。

$ xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates

stackoverflowによると、下記コマンドで解決するとのこと。
あらかじめ、AppleのID/PASSが必要です。

$ open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg

これで、実行できるようになった。
めでたし、めでたし。

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
What you can do with signing up
4