I am trying to build Shared Object (.so) files for the ImageMagick library. However, it get stuck due to the following error while creating the .so file:
[arm64-v8a] Executable : magick
ld: error: undefined symbol: aligned_alloc
>>> referenced by memory.c:262 (././ImageMagick-7.0.9-17/MagickCore\memory.c:262)
>>> memory.o:(AcquireAlignedMemory) in archive ./obj/local/arm64-v8a/libmagickcore-7.a
>>> referenced by memory.c:262 (././ImageMagick-7.0.9-17/MagickCore\memory.c:262)
>>> memory.o:(AcquireVirtualMemory) in archive ./obj/local/arm64-v8a/libmagickcore-7.a
>>> referenced by memory.c:262 (././ImageMagick-7.0.9-17/MagickCore\memory.c:262)
>>> memory.o:(AcquireVirtualMemory) in archive ./obj/local/arm64-v8a/libmagickcore-7.a
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [C:/hostedtoolcache/windows/ndk/r22b/x64/build//../build/core/build-binary.mk:741: obj/local/arm64-v8a/magick] Error 1
Error: Process completed with exit code 1.
Here's a GitHub Actions link where I am generating a .so file and for facing the error for ease of reproducing the issue.
https://github.com/malaythecool/Android-ImageMagick7/runs/2316777388?check_suite_focus=true
In case anyone else is facing this issue, bump up the minSdkVersion to 28 in your build.gradle file.
The Android NDK seems to define these functions based on minSdkVersion, even when you have -std=c11 in your CFLAGS.
File ~/Android/Sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/stdlib.h:
#if ANDROID_API >= 28
void* aligned_alloc(size_t alignment, size_t __size) __INTRODUCED_IN(28);
#endif /* __ANDROID_API >= 28 */
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With