Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fatal error: 'endian.h' file not found

Tags:

c

xcode

macos

Trying to compile C program, every time I run make or gmake as recommended I get this error.

$ 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! nothing else was helpful. Then, I found this 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 :(!

like image 781
user93097373 Avatar asked Nov 22 '14 03:11

user93097373


2 Answers

On OSX and iOS, you can include endian.h this way:

#include <machine/endian.h>

But note that this will fail on Android or Linux because they expect #include <endian.h>.

You can also include sys/types.h, which will include the right endian.h both on iOS/OSX and Android/Linux:

#include <sys/types.h>
like image 77
Samuel Peter Avatar answered Oct 25 '22 21:10

Samuel Peter


You have to tell the c compiler where it can find this file:

export CFLAGS="$CFLAGS -I~/usr/include/machine" then run make.

Alternatively you can edit the file Makefile to add the -I~/usr/include/machine part where necessary.

like image 30
blld Avatar answered Oct 25 '22 22:10

blld