essentia icon indicating copy to clipboard operation
essentia copied to clipboard

undefined symbol: essentia::init() Android

Open faiziakbr opened this issue 2 years ago • 4 comments

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 avatar Jun 19 '23 17:06 faiziakbr

@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?

rodgomesc avatar Jun 23 '23 04:06 rodgomesc

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 avatar Jun 23 '23 12:06 faiziakbr

@faiziakbr can you kindly give a brief explanation about how did you solved it and mark this issue as solved?

rodgomesc avatar Jun 24 '23 20:06 rodgomesc

Ofcourse!!

  1. I changed wscript for android to generate all the architectures of android.
  2. I confirmed them using file libessentia.so command
  3. I created a C++ project on Android.
  4. Created distribution folder at root of project.
  5. Add all the architectures in their respective folders.
  6. Put the header files in the include folder
  7. Added these dependencies in CMake
  8. Loaded the library.
  9. All successful

Also I used ndkVersion '21.3.6528147'

faiziakbr avatar Jun 25 '23 19:06 faiziakbr