xiaoxichen / leveldb

Automatically exported from code.google.com/p/leveldb
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

x-compile for Android/x86 fails #132

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Use the leveldb-1.7.0 master branch. Edit leveldb/jni/Application.mk

APP_ABI := x86

The ndk-build output:
-----------------------------------------
In file included from ./port/port.h:14:0,
                 from ./db/filename.h:14,
                 from jni/.././db/builder.cc:7:
./port/port_posix.h:76:35: error: '_BYTE_ORDER' was not declared in this scope
make: *** [obj/local/x86/objs/jniLevelDB/__/./db/builder.o] Error 1
-----------------------------------------
compiled using android-ndk-r8c, Windows 7.

The patch should be
in port_posix.h
for OS_ANDROID, <sys/endian.h> -> <endian.h>.

Because in android-ndk, <endian.h> is more compatible than <sys/endian.h>.
Especially for x86, _BYTE_ORDER is only declared in <endian.h> but not in 
<sys/endian.h>. For other architecture, <endian.h> is simply include 
<sys/endian.h>.

Original issue reported on code.google.com by noranb...@gmail.com on 16 Nov 2012 at 2:30

GoogleCodeExporter commented 9 years ago
I confirm the issue. It's a bug in the NDK headers that is specific to x86.
Filed http://code.google.com/p/android/issues/detail?id=39824 to track the 
issue there.

The fix should be to include <endian.h>, will check this.

Original comment by di...@google.com on 16 Nov 2012 at 12:23

GoogleCodeExporter commented 9 years ago
I confirmed it's fixed in android-ndk-r8d.
x86 ndk-build succeeds without any patch now.

Original comment by noranb...@gmail.com on 26 Dec 2012 at 11:38

GoogleCodeExporter commented 9 years ago
Revision ea2e9195fc24 modified port_posix.h but
since android-ndk-r8d, this modification is not necessary.

In android-ndk-r8d, #include <sys/endian.h> properly defines __BYTE_ORDER and 
_BYTE_ORDER
because '#define _BYTE_ORDER _LITTLE_ENDIAN' is added in <machine/_types.h>, 
which is included in <sys/endian.h>.

Original comment by noranb...@gmail.com on 30 Dec 2012 at 4:54