loadExtension - library not found
abdelhameedhamdy opened this issue · 6 comments
Describe the bug
when calling loadExtension function, I got Error Exception in HostFunction: dlopen failed: library "mylib.so" not found
location of .so compiled file for 'arm64-v8a' :
/node_modules/@op-engineering/op-sqlite/android/jniLibs/arm64-v8a
Notice: I've rolled back to op-sql@6.0.1
, it reads the library properly with no error raised, with the same file location.
Versions:
OS and version: Android 12 device and emulator
op-sqlite version: 6.0.4
RN version: 0.74.1
New Architecture: Yes
EXPO framework v51.0.9
Reproducible example
export async function loadExtension() {
let db = open(DB_CONFIG);
db.loadExtension("mylib", "sqlite3_mylib_init");
}
Oh, thanks for finding this. Can you create a reproducible example so I can take a look?
I've created a reproducible repo,
installation guide :
npm i
.so file extension in extension directory needs to be copied into the corresponding archs folders in /node_modules/@op-engineering/op-sqlite/android/jniLibs/
npm run android
or npx expo run:android
😨 no, you are not supposed to copy to node_modules folder... there is a reason why I didn't want to document this... dealing with the file system is brittle and complex but I see I have fallen into the API that is exposed, API that is abused hole
You need to copy your .so files into /android/app/src/main/jniLibs
. Here is your project with the files placed correctly:
I will add some documentation.
Thanks for your clarification for resolving this issue, it works properly.
Actually, it was not clearly documented where to place extensions, thanks for updating documentation, I was not sure initially where to put it, tried with the installation package which I know is not appropriate path, but just to test the load_extension function.
I know, I didn't document it on purpose, because people will constantly ask me how to compile their extensions. But it's there now.