Help us understand the problem. What is going on with this article?

_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

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

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away