I meet some trouble when I compile some C code on my mac which give me this error :
fatal error: 'endian.h' file not found
I did some google search about this problem.It seems like mac os x does not have header files like "endian.h", we have to create this file manually.
Then, I found this http://www.opensource.apple.com/source/CarbonHeaders/CarbonHeaders-18.1/Endian.h which might be the file I am looking for but not sure.
But more troubles are coming.. where should I put this file?
The file /usr/include does not exist.
These are the folders in my /usr directory:
X11 bin libexec share X11R6 lib sbin standalone
Could anyone help me to check the correctness of the endian.h file I found and tell me where to put this file in my mac please?
Xcode on OS X does not install the command-line tools by default. Depending on your Xcode and OS X version you have to
- install the command line tools from the Xcode Preferences->Downloads window, or
- execute
xcode-select --install
from the Terminal command-line.
This will also install the "/usr/include" files, including "/usr/include/machine/endian.h".
For Xcode 10 and later, see Camille G.'s answer.
I just used <machine/endian.h>
rather than <endian.h>
.
It works.
As said in the first comment, endian.h
is in /usr/include/machine/
folder.
Download and install the Command Line Tools (macOS 10.X) for XCode 10.X from Apple : https://developer.apple.com/download/more/
Since MacOS 10.14 this will not create anymore the /usr/include folder. This require the installation of an extra package that you could find on your computer after having installed the command-line tools :
/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
In fact, you should import "Endian.h" check your disk manager, maybe your disk is case sensitive
来源:https://stackoverflow.com/questions/20813028/endian-h-not-found-on-mac-osx