Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
732 views
in Technique[技术] by (71.8m points)

c - endian.h not found on mac osx

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...