29
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

macOS 10.15 Catalinaで、"fatal error: 'stdio.h' file not found"が出てしまう!

Posted at

初めてRailsとやらの環境構築をしていた際、gem install pgなどすると以下のようなエラーが出ていて困り果てていました。

/Users/Rascal/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/extensions/x86_64-darwin-18/2.6.0-static/pg-1.1.4/mkmf.log
find_executable: checking for pg_config... -------------------- yes

--------------------

"clang -o conftest -I/Users/Rascal/.rbenv/versions/2.6.4/include/ruby-2.6.0/x86_64-darwin18 -I/Users/Rascal/.rbenv/versions/2.6.4/include/ruby-2.6.0/ruby/backward -I/Users/Rascal/.rbenv/versions/2.6.4/include/ruby-2.6.0 -I. -I/usr/local/Cellar/postgresql/11.5_1/include -I/Users/Rascal/.rbenv/versions/2.6.4/include  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -O3 -ggdb3 -Wall -Wextra -Wdeclaration-after-statement -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wmissing-noreturn -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wextra-tokens  -pipe conftest.c  -L. -L/Users/Rascal/.rbenv/versions/2.6.4/lib -L/usr/local/lib -L. -L/Users/Rascal/.rbenv/versions/2.6.4/lib  -fstack-protector-strong -L/usr/local/opt/openssl/lib -L/usr/local/lib -L/usr/local/Cellar/llvm/8.0.1/lib/clang/8.0.1/lib     -lruby.2.6-static -framework Security -framework Foundation -lpthread -lgmp -ldl -lobjc   "
In file included from conftest.c:1:
In file included from /Users/Rascal/.rbenv/versions/2.6.4/include/ruby-2.6.0/ruby.h:33:
In file included from /Users/Rascal/.rbenv/versions/2.6.4/include/ruby-2.6.0/ruby/ruby.h:29:
In file included from /Users/Rascal/.rbenv/versions/2.6.4/include/ruby-2.6.0/ruby/defines.h:123:
/Library/Developer/CommandLineTools/usr/include/c++/v1/stdio.h:108:15: fatal error: 'stdio.h' file not found
#include_next <stdio.h>
              ^~~~~~~~~
1 error generated.
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: int main(int argc, char **argv)
4: {
5:   return 0;
6: }
/* end */

/Users/Rascal/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/extensions/x86_64-darwin-18/2.6.0-static/pg-1.1.4/mkmf.log (END)

stdio.hがないですと…?

Mojave(10.14)のときは、open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkgで何とかなっていたのですが今回からそのようなパッケージもなく、以下のパスを参照するようにしても上手く行きませんでした。
export CPATH=/Library/Developer/CommandLineTools/usr/include/c++/v1

結論としては、以下を~/.bash_profileなり~/.bashrcに追記することで問題は解消されました。
export SDKROOT="$(xcrun --sdk macosx --show-sdk-path)"

この問題にぶつかるまでは、Dockerを使っての環境構築をしていたので自身のマシンで苦労するとは思いませんでした。

29
6
0

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
  3. You can use dark theme
What you can do with signing up
29
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?