undefined symbol: essentia::init() Android
I have compiled Essentia library successfully from the docs but when I use the shared library I get error.
` : && /Users/faizan/Library/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ --target=aarch64-none-linux-android24 --sysroot=/Users/faizan/Library/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/darwin-x86_64/sysroot -fPIC -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fno-limit-debug-info -Wl,--build-id=sha1 -Wl,--no-rosegment -Wl,--fatal-warnings -Wl,--no-undefined -Qunused-arguments -shared -Wl,-soname,libtesting_esstia.so -o /Volumes/Internal_HD/Documents/Raphael/Testing_esstia/app/build/intermediates/cxx/Debug/25225k4s/obj/arm64-v8a/libtesting_esstia.so CMakeFiles/testing_esstia.dir/native-lib.cpp.o /Users/faizan/Library/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/lib/aarch64-linux-android/24/liblog.so -latomic -lm && :
ld: error: undefined symbol: essentia::init() `
I have placed the *.so files in their respective architectures after generating them one by one in Android project app -> src -> main -> jniLibs -> ${Android_ABI} -> libessentia.so
I have placed the include header files under cpp folder.
I load the library and it loads successfully: System.loadLibrary("essentia")
When I call "essentia::init();" It gives me error "ld: error: undefined symbol: essentia::init()".
I have been stuck in this problem for a week now. Really appreciate the help on this one. Thanks!.
@faiziakbr unfortunately the docs for android building are outdated i spent almost 2 weeks to compile it successfully so you are on the right path 😅, i was only able to build it using --build-static did you try static lib instead of shared?
I was successful in compiling the library with shared lib. Figured out the issue of undefined symbol. I was able to solve it with using CMake. Docs are depricated which is frustrating.
@faiziakbr can you kindly give a brief explanation about how did you solved it and mark this issue as solved?
Ofcourse!!
- I changed wscript for android to generate all the architectures of android.
- I confirmed them using file libessentia.so command
- I created a C++ project on Android.
- Created distribution folder at root of project.
- Add all the architectures in their respective folders.
- Put the header files in the include folder
- Added these dependencies in CMake
- Loaded the library.
- All successful
Also I used ndkVersion '21.3.6528147'