fatal error: string.h: No such file or directory - c++

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

Reinstalling the heaaders fixed my issue:
open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg

Related

cannot compile on mint 20.1: stdlib.h: No such file or directory

I am running a fresh install of Linux Mint 20.1 and I'n trying to compile a program for a GPS tracker, but it won't compile:
In file included from /usr/include/c++/9/bits/stl_algo.h:59,
from /usr/include/c++/9/algorithm:62,
from /usr/include/x86_64-linux-gnu/qt5/QtCore/qglobal.h:142,
from /usr/include/x86_64-linux-gnu/qt5/QtCore/QtCore:4,
from pch.h:27:
/usr/include/c++/9/cstdlib:75:15: fatal error: stdlib.h: No such file or directory
75 | #include_next <stdlib.h>
| ^~~~~~~~~~
compilation terminated.
I have installed a number of additional libraries (libusb, libmarble and a few others) and qmake.
Of course, stdlib.h is present on the system:
$ find /usr -name stdlib.h
/usr/include/x86_64-linux-gnu/bits/stdlib.h
/usr/include/bsd/stdlib.h
/usr/include/stdlib.h
/usr/include/c++/9/tr1/stdlib.h
/usr/include/c++/9/stdlib.h
/usr/include/tcl8.6/tcl-private/compat/stdlib.h
After looking at the other questions about this, I re-installed build-essential, which didn't help.
I re-installed the g++ compiler, no luck either.
I copied /usr/include/c++/9/stdlib.h to /usr/local/include, but it still complains about a missing stdlib.h
I changed the
#include_next <stdlib.h>
in cstdlib into
#include <stdlib.h>
only to find that the next include cannot find stdlib.h; changing that one produced the third include and so on. So that does not work either.
The program compiles and works on Slackware 14.2 by the way.
What am I missing?
Hello-world compiles normally; a simple program that does a malloc also compiles and runs.
I used to #anastaciu 's solution.
As it was a fresh install without much customization, I resorted to the option of a complete re-install. Bizarre that that works a bit, as it was already a fresh install. I still had to copy stdlib.h and a few others (math.h etc.) to /usr/local/lib` to get to the point where it would at least compile.

wchar.h no such file or directory

I've been trying to run simple c++ program
#include<iostream.h>
void main(){
cout<<"helloworld";
}
and the error I get is :
In file included from d:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\postypes.h:40:0,
from d:\mingw\lib\gcc\mingw32\6.3.0\include\c++\iosfwd:40,
from d:\mingw\lib\gcc\mingw32\6.3.0\include\c++\ios:38,
from d:\mingw\lib\gcc\mingw32\6.3.0\include\c++\ostream:38,
from d:\mingw\lib\gcc\mingw32\6.3.0\include\c++\iostream:39,
from my.cpp:1:
d:\mingw\lib\gcc\mingw32\6.3.0\include\c++\cwchar:44:19: fatal error: wchar.h: No such file or directory
#include <wchar.h>
^
compilation terminated."
anyone know how to fix it ,I'm using the mingw to compile it.
Probably your MinGW is broken. Also, GCC 6.3.0 is very old.
Try a more recent MinGW or even better MinGW-w64.
A standalone build is available from http://winlibs.com/ with GCC 10.2.0 (both for Windows 32-bit and 64-bit).

How to install nan.h on cygwin for g++?

I can't build this simple program on cygwin:
#include <nan.h>
int main(){}
I get this error message:
$ g++ a.cpp
a.cpp:1:17: fatal error: nan.h: No such file or directory
compilation terminated.
Is it possible to install something on cygwin to get correct nan.h?
nan.h is an obsolete include of old gcc. On Cygwin NAN is defined on math.h
You can not use a software written in 2008
https://boutell.com/fracster-src/doubledouble/doubledouble.html
for such specific issue and just hope than it works out of the box.
You need to figure out where nan.h is located and than Add this path to the includes.
How to make g++ search for header files in a specific directory?

how to solve cppdb/frontend.h compilation error

I am extending a project which includes cppdb/frontend.h, but when I compile I always have this compilation error.
graph_from_db.cpp:6:28: fatal error: cppdb/frontend.h: No such file or directory
#include <cppdb/frontend.h>
^
compilation terminated.
I tried to install libcppdb0 in my Kubuntu 14.04 but it gives this error
E: Package 'libcppdb0' has no installation candidate.
What could be the best way to include this package or file to the project?
I am using a 32bit HP computer with i386 architecture. I have been on this for two weeks now no solution.

Clang: 'cmath' file not found

I'm compiling my project with clang but I'm having an odd error:
[ 1%] Building CXX object CMakeFiles/tfs.dir/src/actions.cpp.o
In file included from /home/travis/build/dominique120/miniature-adventure/src/actions.cpp:20:
In file included from /home/travis/build/dominique120/miniature-adventure/src/otpch.h:27:
/home/travis/build/dominique120/miniature-adventure/src/definitions.h:39:10: fatal error:
'cmath' file not found
#include <cmath>
^
make: *** [all] Error 2
My actions.cpp line 20:
#include "otpch.h"
otpch.h line 27:
#include "definitions.h"
definitions.h line 31:
#include <cmath>
I made a few edits but I have no idea what is causing this error, edits here: https://github.com/dominique120/miniature-adventure/commits/master
PS: GCC just dumps a ton of errors:
https://travis-ci.org/dominique120/miniature-adventure/jobs/21905513
After googling for a problem I was having on macOS, I came to your post. I am sharing a solution, even though it applies only to Mac users.
Chances are you upgraded Xcode (or it was upgraded for you) and you continue to use an old compilation scheme.
Determine which of the following directories actually exists on your disk:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/
and make sure that among your compilation switches you have -I along with a directory that exists.
I had the same issue on Ubuntu 22.04 with libstdc++-11-dev installed.
After doing:
sudo apt install libstdc++-12-dev
...the error went away.
It seems to occur with libstdc++-11 only?