Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fatal error: string.h: No such file or directory

Tags:

c++

xcode

macos

In my environment, I couldn't include <cstring>. My g++ version is 4.9.3 (Homebrew gcc49 4.9.3).

The error is:

 - /usr/local/Cellar/gcc49/4.9.3/include/c++/4.9.3/cstring:42:20: fatal
   error: string.h: No such file or directory
  "#include string.h"

But, in another environment (g++ 4.8.4[Ubuntu 4.8.4-2ubuntu1~14.04.3]), I can include <cstring> and run.

What's the problem and how do I solve it?

[P.S.] Maybe, I misunderstood about the problem. I tried to run my previous code, but got an error like this:

    /usr/local/Cellar/gcc49/4.9.3/include/c++/4.9.3/cassert:43:20: fatal error: assert.h: No such file or directory
 #include <assert.h>

Then, I can't run my code. It is a g++'s problem.

I checked this article, but this procedure is not working. I already installed xcode-select (commmad line tool) and I uninstalled xcode-select and reinstalled xcode-select, but it's not working.

Building C++ not working in OSX 10.9

like image 682
hiroyuki tanaka Avatar asked Sep 28 '16 01:09

hiroyuki tanaka


1 Answers

Reinstalling the heaaders fixed my issue:

open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
like image 144
Tim Givois Avatar answered Sep 22 '22 03:09

Tim Givois