[英]fatal error: 'endian.h' file not found
Trying to compile C program, every time I run make
or gmake
as recommended I get this error. 尝试编译C程序,每次我按照建议运行
make
或gmake
我都会收到此错误。
$ make
/Applications/Xcode.app/Contents/Developer/usr/bin/make -C src all
gcc -g -W -Wall -O3 -D_FILE_OFFSET_BITS=64 -D_REVISION=0 -Iinclude -c -o osdep/radiotap/radiotap.o osdep/radiotap/radiotap.c
In file included from osdep/radiotap/radiotap.c:17:
osdep/radiotap/platform.h:6:10: fatal error: 'endian.h' file not found
#include <endian.h>
^
1 error generated.
make[1]: *** [osdep/radiotap/radiotap.o] Error 1
make: *** [all] Error 2
$ gmake
gmake -C src all
gmake[1]: Entering directory '/Users/silent/Desktop/aircr-1.2-rc1/src'
gcc -g -W -Wall -O3 -D_FILE_OFFSET_BITS=64 -D_REVISION=0 -Iinclude -c -o osdep/radiotap/radiotap.o osdep/radiotap/radiotap.c
In file included from osdep/radiotap/radiotap.c:17:
osdep/radiotap/platform.h:6:10: fatal error: 'endian.h' file not found
#include <endian.h>
^
1 error generated.
<builtin>: recipe for target 'osdep/radiotap/radiotap.o' failed
gmake[1]: *** [osdep/radiotap/radiotap.o] Error 1
gmake[1]: Leaving directory '/Users/silent/Desktop/aircr-1.2-rc1/src'
Makefile:25: recipe for target 'all' failed
gmake: *** [all] Error 2
According to some forms online recommended to check the file in this location ~/usr/include/machine
but doesn't say what to do if found or not! 根据在线推荐的一些表格来检查这个位置的文件
~/usr/include/machine
但是如果找不到则不说该做什么! nothing else was helpful. 没有别的帮助。 Then, I found this http://www.opensource.apple.com/source/CarbonHeaders/CarbonHeaders-18.1/Endian.h
然后,我发现了这个http://www.opensource.apple.com/source/CarbonHeaders/CarbonHeaders-18.1/Endian.h
silent:~/usr/include/machine
$ ls
_limits.h _types.h fasttrap_isa.h profile.h vmparam.h
_mcontext.h byte_order.h limits.h signal.h
_param.h `endian.h` param.h types.h
As you can the file I am getting the error for is already existed! 正如你所知,我收到错误的文件已经存在! Any help would be appreciated.
任何帮助,将不胜感激。 Thank you.
谢谢。
PS: I am newbie, I don't know what is this link above talking about :(! PS:我是新手,我不知道上面这个链接在说什么:(!
On OSX and iOS, you can include endian.h this way: 在OSX和iOS上,您可以这样包含endian.h:
#include <machine/endian.h>
But note that this will fail on Android or Linux because they expect #include <endian.h>
. 但请注意,这将在Android或Linux上失败,因为他们期望
#include <endian.h>
。
You can also include sys/types.h, which will include the right endian.h both on iOS/OSX and Android/Linux: 您还可以包含sys / types.h,它将在iOS / OSX和Android / Linux上包含正确的endian.h:
#include <sys/types.h>
You have to tell the c compiler where it can find this file: 你必须告诉c编译器它可以在哪里找到这个文件:
export CFLAGS="$CFLAGS -I~/usr/include/machine"
then run make
. export CFLAGS="$CFLAGS -I~/usr/include/machine"
然后运行make
。
Alternatively you can edit the file Makefile
to add the -I~/usr/include/machine
part where necessary. 或者,您可以编辑文件
Makefile
以在必要时添加-I~/usr/include/machine
部分。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.