致命错误:找不到'endian.h'文件
问题描述:
试图编译C程序,每次我按照建议运行make
或gmake
时出现此错误。致命错误:找不到'endian.h'文件
$ 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
根据网上建议检查文件在此位置~/usr/include/machine
,但不说,如果发现或不能做什么某些形式!没有别的是有帮助的。然后,我发现这个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
如你我收到错误的文件已经存在!任何帮助,将不胜感激。谢谢。
!PS:我是新手,我不知道什么是上面谈到这个链接:(
答
你必须告诉C编译器在那里可以找到这个文件:
export CFLAGS="$CFLAGS -I~/usr/include/machine"
然后运行make
。
另外,您可以编辑该文件Makefile
以在必要时添加-I~/usr/include/machine
一部分。
答
在OSX和iOS,您可以包括endian.h日是方式:
#include <machine/endian.h>
但请注意,这将在Android或Linux上失败,因为他们预计#include <endian.h>
。
还可以包括SYS/types.h中,其中将包括endian.h都在iOS/OSX和Android/Linux的权利:
#include <sys/types.h>
你试图复制并粘贴endian.h到/ usr/include目录? 这是这里的答案http://*.com/questions/20813028/endian-h-not-found-on-mac-osx – 2014-11-22 04:21:20
这是我到那个链接,但我没有尝试过,现在会做并看看会发生什么。 – user93097373 2014-11-22 06:40:35
@ user3097840,我得到更多错误链接丢失,所以我把它放回去,错误解决与重新启动。现在,它获得了'架构x86_64的未定义符号:' – user93097373 2014-11-22 09:18:44