OP-Engineering / op-sqlite

Fastest SQLite library for react-native by @ospfranco
MIT License
603 stars 40 forks source link

loadExtension [Error: Failed to open database: Exception in HostFunction: undefined symbol: arabic_tokenizer] #121

Closed NaseemYE closed 4 months ago

NaseemYE commented 4 months ago

Describe the bug A clear and concise description of what the bug is.

Versions:

I'm having trouble downloading plugins First, I compiled the extension into the Android system using the following commands:


compile-android-arm64-v8a:
  $(NDK)/toolchains/llvm/prebuilt/$(HOST_TAG)/bin/clang -target aarch64-linux-android21 -shared -fPIC generate/sqlite3-arabic-tokenizer.c -o dist/android/arm64-v8a/sqlite3 -arabic-tokenizer.so

compile-android-armeabi-v7a:
  $(NDK)/toolchains/llvm/prebuilt/$(HOST_TAG)/bin/clang -target armv7a-linux-androideabi21 -shared -fPIC generate/sqlite3-arabic-tokenizer.c -o dist/android/armeabi-v7a/sqlite3 -arabic-tokenizer.so

compile-android-x86:
  $(NDK)/toolchains/llvm/prebuilt/$(HOST_TAG)/bin/clang -target i686-linux-android21 -shared -fPIC generate/sqlite3-arabic-tokenizer.c -o dist/android/x86/sqlite3-arabic -tokenizer.so

compile-android-x86_64:
  $(NDK)/toolchains/llvm/prebuilt/$(HOST_TAG)/bin/clang -target x86_64-linux-android21 -shared -fPIC generate/sqlite3-arabic-tokenizer.c -o dist/android/x86_64/sqlite3-arabic -tokenizer.so

Then I put them inside:


/android
    /app
        /src
            /main
                /jniLibs
                    /arm64-v8a
                        sqlite3-arabic-tokenizer.so
                    /armeabi-v7a
                        sqlite3-arabic-tokenizer.so
                    /x86
                        sqlite3-arabic-tokenizer.so
                    /x86_64
                        sqlite3-arabic-tokenizer.so

Then it was called by:

db.loadExtension('sqlite3-arabic-tokenizer', 'arabic_tokenizer');

But I have the following problem:

[Error: Failed to open database: Exception in HostFunction: undefined symbol: arabic_tokenizer]

Taking into account that I compiled it for Mac systems and used it via the sqlite terminal and it worked perfectly.

But when I use it within the application, I have the problem you mentioned

SQL query :

CREATE VIRTUAL TABLE articles_fts USING fts5(
    thread_id UNINDEXED,
    id,
    title,
    content,
    dateline UNINDEXED,
    content='articles',
    tokenize = "arabic_tokenizer",
);

package.json

"op-sqlite": {
      "iosSqlite": false,
      "fts5": true
    }

Extension files: sqlite3-arabic-tokenizer.zip

Files without compilition https://github.com/GreentechApps/sqlite3-arabic-tokenizer

ospfranco commented 4 months ago

a few questions:

Other than that, I don't really know what could be the problem. The library correctly packages other extensions and loads them correctly so it has to be something on your specific compilation process or packaging that is not quite working.

ospfranco commented 4 months ago

I can see in the README of the repo you posted they load the extension without modifying the entry point

https://github.com/GreentechApps/sqlite3-arabic-tokenizer

You should read on the usage of extension loading.

NaseemYE commented 4 months ago

Sorry, it was the function sqlite3_sqlitearabictokenizer_init I found it in the sqlite3-arabic-tokenizer.hfile Thank you