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

10,251

Reinstalling the heaaders fixed my issue:

open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
Share:
10,251
hiroyuki tanaka
Author by

hiroyuki tanaka

Updated on August 05, 2022

Comments

  • hiroyuki tanaka
    hiroyuki tanaka almost 2 years

    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

    • Sam Varshavchik
      Sam Varshavchik over 7 years
      The problem is that you do not have C header files installed.
    • hiroyuki tanaka
      hiroyuki tanaka over 7 years
      I think I installed Command Line(C header files). I can find /usr/include.
    • Beta
      Beta over 7 years
      Try #include <string>
    • hiroyuki tanaka
      hiroyuki tanaka over 7 years
      I think <string> and <cstring> are certainly different. But, I tried that. and I got another error./usr/local/Cellar/gcc49/4.9.3/include/c++/4.9.3/cwchar‌​:44:19: fatal error: wchar.h: No such file or directory #include <wchar.h>