Lendfating / leveldb

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

Error with android port #100

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. compile for armV6
2. In application.mk set "APP_ABI := armeabi-v7a armeabi"
3. launch build-ndk

What is the expected output? What do you see instead?

In file included from ./port/port.h:18,
                 from ./db/filename.h:14,
                 from jni/.././db/builder.cc:7:
./port/port_android.h:81: error: expected initializer before 'ATTRIBUTE_WEAK'
./port/port_android.h: In member function 'void 
leveldb::port::AtomicPointer::MemoryBarrier() const':
./port/port_android.h:95: error: 'pLinuxKernelMemoryBarrier' was not declared 
in this scope
make: *** [obj/local/armeabi/objs-debug/leveldb/__/./db/builder.o] Error 1

What version of the product are you using? On what operating system?
I'm on windows 7 with the last NDK

Please provide any additional information below.

It's works with just "APP_ABI := armeabi-v7a"

Original issue reported on code.google.com by bruno.ro...@gmail.com on 6 Jul 2012 at 8:22

GoogleCodeExporter commented 9 years ago
I believe this is fixed in Leveldb 1.5. Can you please test with this version 
instead.

Original comment by di...@google.com on 9 Jul 2012 at 10:52

GoogleCodeExporter commented 9 years ago
I'm using last source from the android branch.

To solve the problem i have replace "ATTRIBUTE_WEAK" declaration by 
"__attribute__((weak))" in the port_android.h file line 80

Issue solve with Google so it need to be valide.

I still have compile error with mips architecture but i'm not sure such device 
exist on android.
(x86 is ok)

Original comment by bruno.ro...@gmail.com on 9 Jul 2012 at 9:29

Attachments:

GoogleCodeExporter commented 9 years ago
I don't know who manages the android branch, or what differences it has with 
mainline, but I suspect it is seriously out-dated :-(

Original comment by di...@google.com on 10 Jul 2012 at 9:14

GoogleCodeExporter commented 9 years ago
Ok, i will try to compare/merge my code with master branch 

Original comment by bruno.ro...@gmail.com on 10 Jul 2012 at 12:39

GoogleCodeExporter commented 9 years ago
I have made the diff between android branch and master branch.
Android branch is totally out of sync.
Do you plan to maintain it or maybe let android port to another project ?

Original comment by bruno.ro...@gmail.com on 11 Jul 2012 at 3:14

GoogleCodeExporter commented 9 years ago
I have publish my port of leveldb on android on github.
I have add a class for use it as library in an android project.

if you have any comment or question don't hesitate.

https://github.com/moritan/LevelDBlib

Original comment by bruno.ro...@gmail.com on 11 Jul 2012 at 9:18

GoogleCodeExporter commented 9 years ago
Well done, bruno. Thank you.

I compared master and android branch and I thought some features are removed 
intentionally. But it seems not.

Your android port works nicely in Android 2.1 (armeabi) and Android 4.1 
(armeabi-v7a).

Original comment by noranb...@gmail.com on 16 Oct 2012 at 6:22

GoogleCodeExporter commented 9 years ago
I found that in Android 2.1 leveldb doesn't work
because pread() always returns 0.
I posted at ndk groups but got nothing.

android ndk is still growing so each release could be different

I think if Env can check platform version at runtime, it would be more 
compatible and mobile friendly.

Original comment by noranb...@gmail.com on 1 Nov 2012 at 8:02

GoogleCodeExporter commented 9 years ago
If I change pread to lseek->read->lseek, (in android 7)
is there any possible problem, thread or performance?

If I want to do this, where would be the best place to put the platform check?

Or are you have any plan for runtime platform check?

Original comment by noranb...@gmail.com on 6 Nov 2012 at 1:10

GoogleCodeExporter commented 9 years ago
> If I change pread to lseek->read->lseek, (in android 7)

This won't work since multiple threads may be reading from the same file at the 
same time and they will interfere with each other.

Some potential fixes:

(1) Does the mmap version work? If so, you could relax the rules for using the 
mmap implementation of RandomAccessFile to cover Eclair.

(2) If you use lseek/read, combine it with a Mutex to prevent threading 
problems. E.g.,
      lock mutex
      lseek to offset
      read()
      unlock mutex
(there is no need to lseek at the end since the next reader will do another 
lseek before their read anyway).

Original comment by san...@google.com on 14 Dec 2012 at 5:29