Libpytorch_jni.so: invalid local symbol '__bss_end__' in global part of symbol table

kabyanil: <p>I have a running libtorch inference code which I want to re-use in an android app. I built pytorch for android following this <a href="https://github.com/pytorch/pytorch/blob/main/android/README.md#linking-to-prebuilt-libtorch-library-from-gradle-dependency" rel="noopener nofollow ugc">guide.</a></p>
<p>After the build, I have pytorch_android-2.1.0.aar inside /build folder.</p>
<p>When I run the app, I get the following errors:</p>
<pre><code class="lang-auto">&gt; Task :app:buildCMakeDebug[arm64-v8a] FAILED
C/C++: ninja: Entering directory `/home/ik/AndroidStudioProjects/test-app/app/.cxx/Debug/6zi25n2z/arm64-v8a'
C/C++: : &amp;&amp; /home/ik/Android/Sdk/ndk/26.1.10909125/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ --target=aarch64-none-linux-android24 --sysroot=/home/ik/Android/Sdk/ndk/26.1.10909125/toolchains/llvm/prebuilt/linux-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,--no-undefined-version -Wl,--fatal-warnings -Wl,--no-undefined -Qunused-arguments -shared -Wl,-soname,libaakhor.so -o ../../../../build/intermediates/cxx/Debug/6zi25n2z/obj/arm64-v8a/libaakhor.so CMakeFiles/test-app.dir/src/main/cpp/test.cpp.o CMakeFiles/test-app.dir/src/main/cpp/asm_tokenizer.cpp.o CMakeFiles/test-app.dir/src/main/cpp/eng_tokenizer.cpp.o  ../../../../build/pytorch_android-2.1.0.aar/jni/arm64-v8a/libpytorch_jni.so  ../../../../build/pytorch_android-2.1.0.aar/jni/arm64-v8a/libfbjni.so  /home/ik/Downloads/icu4c-main/prebuilt/libs/android/arm64-v8a/libicui18n_floris.a  /home/ik/Downloads/icu4c-main/prebuilt/libs/android/arm64-v8a/libicudata_floris.a  /home/ik/Downloads/icu4c-main/prebuilt/libs/android/arm64-v8a/libicuuc_floris.a  -landroid  -llog  -latomic -lm &amp;&amp; :
C/C++: ld.lld: error: ../../../../build/pytorch_android-2.1.0.aar/jni/arm64-v8a/libpytorch_jni.so: invalid local symbol '__bss_end__' in global part of symbol table
C/C++: ld.lld: error: ../../../../build/pytorch_android-2.1.0.aar/jni/arm64-v8a/libpytorch_jni.so: invalid local symbol '__bss_start' in global part of symbol table
C/C++: ld.lld: error: ../../../../build/pytorch_android-2.1.0.aar/jni/arm64-v8a/libpytorch_jni.so: invalid local symbol '_end' in global part of symbol table
C/C++: ld.lld: error: ../../../../build/pytorch_android-2.1.0.aar/jni/arm64-v8a/libpytorch_jni.so: invalid local symbol '_edata' in global part of symbol table
C/C++: ld.lld: error: ../../../../build/pytorch_android-2.1.0.aar/jni/arm64-v8a/libpytorch_jni.so: invalid local symbol '__bss_start__' in global part of symbol table
C/C++: ld.lld: error: ../../../../build/pytorch_android-2.1.0.aar/jni/arm64-v8a/libpytorch_jni.so: invalid local symbol '_bss_end__' in global part of symbol table
C/C++: ld.lld: error: ../../../../build/pytorch_android-2.1.0.aar/jni/arm64-v8a/libpytorch_jni.so: invalid local symbol '__end__' in global part of symbol table
C/C++: clang++: error: linker command failed with exit code 1 (use -v to see invocation)
C/C++: ninja: build stopped: subcommand failed.
</code></pre>
<p>I am assuming this could be a version incompatibility issue. Requesting help to resolve this.</p>
<pre><code class="lang-auto">NDK: 26.1.10909125
Gradle: 8.7
Java: 17.0.11
gcc: gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
CMake: 3.22.1
</code></pre>