fatal error: 'ext/hash_map.h' file not found on Mac - c++

I run some downloaded code using hash_map.h. But when I compile it using g++, it gives error message:
fatal error: 'hash_map.h' file not found
I search on google, some one suggests to replace 'hash_map.h' by 'ext/hash_map.h' and add 'using namespace __gnu_cxx;'. But still I get the error message 'fatal error: 'ext/hash_map.h' file not found'.
I type "sudo find / -name hash_map.h" in the terminal of my Mac, and get the following results.
/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/usr/include/c++/4.2.1/backward/hash_map.h
/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/usr/include/c++/4.2.1/debug/hash_map.h
/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator.sdk/usr/include/c++/4.2.1/backward/hash_map.h
/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator.sdk/usr/include/c++/4.2.1/debug/hash_map.h
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/c++/4.2.1/backward/hash_map.h
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/c++/4.2.1/debug/hash_map.h
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include/c++/4.2.1/backward/hash_map.h
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include/c++/4.2.1/debug/hash_map.h
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/c++/4.2.1/backward/hash_map.h
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/c++/4.2.1/debug/hash_map.h
How to link hash_map.h to the downloaded code?

I add the path to the hash_map.h to the Makefile as follows.
g++ -I /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/c++/4.2.1/ -c target.cpp
And I replace 'hash_map.h' by 'debug/hash_map.h', and add 'using namespace __gnu_cxx;'.
It works for me.

Related

Xcode command line tools not finding header files (Catalina Update 10.15.7)

Recently I have updated my MacBook operating system to Catalina 10.15.7 and Xcode command line tools to 12.1. Ever since I have been getting the following error when I try to use any C++ compiler:
gcc A3v2.cpp
In file included from /usr/local/include/c++/9.2.0/bits/postypes.h:40,
from /usr/local/include/c++/9.2.0/iosfwd:40,
from /usr/local/include/c++/9.2.0/ios:38,
from /usr/local/include/c++/9.2.0/ostream:38,
from /usr/local/include/c++/9.2.0/iostream:39,
from A3v2.cpp:13:
/usr/local/include/c++/9.2.0/cwchar:44:10: fatal error: wchar.h: No such file or directory
44 | #include <wchar.h>
| ^~~~~~~~~
compilation terminated.
I have tried removing and re installing command line tools but it hasn't worked (amongst trying various other solutions I've found on Stackoverflow). When I run sudo find on wchar.h I get the following.
sudo find /Library -name wchar.h
find: /Library/Application Support/com.apple.TCC: Operation not permitted
/Library/Developer/CommandLineTools/usr/include/c++/v1/wchar.h
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/wchar.h
As a current work around (as I need a c++ compiler for a current assignment) I have been using:
/usr/bin/gcc A3v2.cpp
however I'm hoping this will just be temporary. I think this is a path problem since the missing header file exsits? Not sure what I am doing when it comes to specifying file paths so please let me know if you know how to solve this. Thanks!

How to add sys/mman.h to MinGW in Windows?

I'm trying to use the following tool: Extract Loudest Section in Windows.
I used the following command line to run main.cc g++ -o main main.cc
But I've got this message: "fatal error: sys/mman.h: No such file or directory"
However, I read this answer, but I still need more details about how to add the needed files correctly to my compiler?
The "Downloads" page in the link provided by the answer shows:
There was an error getting resource 'downloads':
401: Anonymous caller does not have storage.objects.get access to google-code-archive/v2/code.google.com/mman-win32/downloads-page-1.json.
So, I found this as an alternative resource.

fatal error: winsock: No such file or directory

I have been trying to compile multiple C and C++ scripts on a kali VM and 99% of the time I get an error like this:
test.cpp:39:10: fatal error: winsock: No such file or directory
#include <winsock>
It will do the same for Iostream too, I cannot find anything that has helped me fix this and I need to be able to comple and run these programs.
You need to download and install the sdk platform

Clang errors after deletion in /usr/bin and copying back

Please don't ask me what on earth got into me deleting clang from the /usr/bin folder...I got weird error messages and couldn't find anything on the web...
However, I deleted clang, tried reinstalling Xcode + developer tools, but clang wasn't installed again. So I searched inside the Xcode folder and found it in /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
So, I copied this (and clang++) back to my /usr/bin folder, but now I'm getting weird error messages again, e.g:
fatal error: 'stdarg.h' file not found
#include <stdarg.h>
^
1 error generated.
Any idea how I could fix this?
Try to link it instead of copying
ln -s /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang /usr/bin/clang

How to get started with twitCurl?

I am trying to use twitCurl and I am following instructions given on
[1]: http://code.google.com/p/twitcurl/wiki/WikiHowToUseTwitcurlLibrary under the Unix/Linux section.
Getting stuck while doing
g++ twitterClient.cpp -ltwitcurl
It gives an error message
In file included from twitterClient.h:4:0,
from twitterClient.cpp:1:
includes/twitcurl.h:8:23: fatal error: curl/curl.h: No such file or directory
compilation terminated.
The file curl.h is inside curl/ but it still gives an error.
Why?
Add -I<path to curl/curl.h> to your building command.