Termux-packages: Clang is not working

Created on 23 Sep 2019  路  16Comments  路  Source: termux/termux-packages

Problem description
Clang produces linking errors when compiling.

$ clang hello.c
/data/data/com.termux/files/usr/bin/ld: /system/lib/libunwind.so: undefined reference to `XzUnpacker_Code'
/data/data/com.termux/files/usr/bin/ld: /system/lib/libunwind.so: undefined reference to `XzUnpacker_Free'
/data/data/com.termux/files/usr/bin/ld: /system/lib/libunwind.so: undefined reference to `Crc64GenerateTable'
/data/data/com.termux/files/usr/bin/ld: /system/lib/libunwind.so: undefined reference to `CrcGenerateTable'
/data/data/com.termux/files/usr/bin/ld: /system/lib/libunwind.so: undefined reference to `XzUnpacker_Construct'
/data/data/com.termux/files/usr/bin/ld: /system/lib/libunwind.so: undefined reference to `XzUnpacker_IsStreamWasFinished'
clang-8: error: linker command failed with exit code 1 (use -v to see invocation)

Steps to reproduce
hello.c

#include <stdio.h>

int main(void) {
    printf("Hello\n");
    return 0;
}
$ clang hello.c

Expected behavior
Clang should be able to compile hello world code.

Additional information

Updatable packages:
All packages up to date
Subscribed repositories:
https://dl.bintray.com/xeffyr/unstable-packages-24 unstable/main
https://dl.bintray.com/grimler/science-packages-24 science/stable
https://dl.bintray.com/grimler/game-packages-24 games/stable
https://dl.bintray.com/termux/termux-packages-24 stable/main
System information:
Linux localhost 3.18.71-perf-gea366bb-00016-g6e15bdb #1 SMP PREEMPT Mon Mar 4 18:13:35 CST 2019 armv7l Android
Termux-packages arch:
arm
Android version:
8.1.0
Device manufacturer:
motorola
Device model:
Moto G (5)
bug report

Most helpful comment

@svimes This is a conflict between liblzma.so from Termux and from Android. You should force link with one in /system/lib64.

All 16 comments

Seems like libunwind.a from NDK is required now. libunwind.a is already in ndk-sysroot.

Should be fixed with clang 8.0.1-4.

@xeffyr Unfortunately it isn't. Can you please re-open this ? It is still showing the same error.

@yubrajbhoi Did you pkg upgrade'd ? I just verified on my devices and undefined reference error is gone.

@xeffyr NVM it was my mistake. I was overriding libunwind. It is indeed fixed. Thank you.

I am getting similar error with clang-9:

clang++ -o selfdrive/camerad/camerad -Wl,-rpath=/system/vendor/lib64 selfdrive/camerad/main.o selfdrive/camerad/transforms/rgb_to_yuv.o selfdrive/camerad/cameras/camera_qcom.o -Lphonelibs/snpe/aarch64-android-clang3.8 -L/usr/lib -L/data/data/com.termux/files/usr/lib -L/system/vendor/lib64 -L/system/comma/usr/lib -Lphonelibs/yaml-cpp/lib -Lphonelibs/nanovg -Lphonelibs/libyuv/lib -Lcereal -Lselfdrive/common -Lphonelibs -Lphonelibs/zmq/aarch64-linux/lib -Lphonelibs/capnp-cpp/aarch64-linux/lib -lm -lpthread selfdrive/common/libcommon.a -ljson -ljpeg -ljson cereal/libcereal.a -lOpenCL cereal/libmessaging.a -lczmq -lzmq -lcapnp -lkj -lcapnp_c selfdrive/common/libvisionipc.a selfdrive/common/libgpucommon.a -lgui -ladreno_utils -llzma -lgsl -lCB -ladreno_utils -lEGL -lGLESv3 -lcutils -lui
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: /system/vendor/lib64/libOpenCL.so: .dynsym local symbol at index 3 (>= sh_info of 3)
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: /system/vendor/lib64/libOpenCL.so: .dynsym local symbol at index 4 (>= sh_info of 3)
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: /system/vendor/lib64/libOpenCL.so: .dynsym local symbol at index 5 (>= sh_info of 3)
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: /system/vendor/lib64/libOpenCL.so: .dynsym local symbol at index 6 (>= sh_info of 3)
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: /system/vendor/lib64/libOpenCL.so: .dynsym local symbol at index 7 (>= sh_info of 3)
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: /system/vendor/lib64/libOpenCL.so: .dynsym local symbol at index 8 (>= sh_info of 3)
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: /system/vendor/lib64/libOpenCL.so: .dynsym local symbol at index 9 (>= sh_info of 3)
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: /data/openpilot/phonelibs/zmq/aarch64/lib//libgnustl_shared.so: .dynsym local symbol at index 3 (>= sh_info of 3)
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: /data/openpilot/phonelibs/zmq/aarch64/lib//libgnustl_shared.so: .dynsym local symbol at index 4 (>= sh_info of 3)
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: /data/openpilot/phonelibs/zmq/aarch64/lib//libgnustl_shared.so: .dynsym local symbol at index 5 (>= sh_info of 3)
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: /data/openpilot/phonelibs/zmq/aarch64/lib//libgnustl_shared.so: .dynsym local symbol at index 6 (>= sh_info of 3)
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: /data/openpilot/phonelibs/zmq/aarch64/lib//libgnustl_shared.so: .dynsym local symbol at index 7 (>= sh_info of 3)
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: /data/openpilot/phonelibs/zmq/aarch64/lib//libgnustl_shared.so: .dynsym local symbol at index 8 (>= sh_info of 3)
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: /data/openpilot/phonelibs/zmq/aarch64/lib//libgnustl_shared.so: .dynsym local symbol at index 9 (>= sh_info of 3)
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: /system/lib64/libunwind.so: undefined reference to `XzUnpacker_Free'
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: /system/lib64/libunwind.so: undefined reference to `XzUnpacker_IsStreamWasFinished'
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: /system/lib64/libunwind.so: undefined reference to `XzUnpacker_Construct'
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: /system/lib64/libunwind.so: undefined reference to `CrcGenerateTable'
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: /system/lib64/libunwind.so: undefined reference to `Crc64GenerateTable'
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: /system/lib64/libunwind.so: undefined reference to `XzUnpacker_Code'
clang-9: error: linker command failed with exit code 1 (use -v to see invocation)

@svimes This is a conflict between liblzma.so from Termux and from Android. You should force link with one in /system/lib64.

Thank you. You are right, the build was using the Termux copy of liblzma.so instead of the Android one.

Plz help me with this
I have the issue while running the code:
$clang hello.c
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: /system/lib64/libc.so: .dynsym local symbol at index 3 (>= sh_info of 3) /data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: /system/lib64/libc.so: .dynsym local symbol at index 4 (>= sh_info of 3)
$ ./hello
bash: ./hello: Permission denied

@sane-987

  1. You have issues with your ROM. Looks like /system/lib64/libc.so is corrupted but still usable.
  2. Have you tried chmod +x ./hello ? And make sure that binary is not stored on /sdcard - execution permissions are disabled at this location.

I've stored everything in internal
While performing chmod the operation is not permitted

I've stored everything in internal
chmod the operation is not permitted

Ensure your "internal" path is exactly

/data/data/com.termux/files/home

Yes,it is
But still operation is denied

@xeffyr thankyou it work after giving permissions :chmod +x ./hello.c

Hi, I have the same error on my phone which is an android with clang 9, here's the error:

I've tried the chmod solution but it silently succeded without executing the file, and i dont know what to do to solve the liblzma.so solution, I might have a corrupted libc.so, can i redownload it to fix it or something?

$ gcc main.cpp
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: /system/lib64/libc.so: .dynsym local symbol at index 3 (>= sh_info of 3)
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: /system/lib64/libc.so: .dynsym local symbol at index 4 (>= sh_info of 3)
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: /data/data/com.termux/files/usr/tmp/main-15772a.o: in function `main':
main.cpp:(.text+0xc): undefined reference to `std::__ndk1::cout'
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: main.cpp:(.text+0x10): undefined reference to `std::__ndk1::cout'
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: /data/data/com.termux/files/usr/tmp/main-15772a.o: in function `std::__ndk1::basic_ostream<char, std::__ndk1::char_traits<char> >& std::__ndk1::__put_character_sequence<char, std::__ndk1::char_traits<char> >(std::__ndk1::basic_ostream<char, std::__ndk1::char_traits<char> >&, char const*, unsigned long)':
main.cpp:(.text._ZNSt6__ndk124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m[_ZNSt6__ndk124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m]+0x170): undefined reference to `__cxa_begin_catch'
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: main.cpp:(.text._ZNSt6__ndk124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m[_ZNSt6__ndk124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m]+0x188): undefined reference to `std::__ndk1::ios_base::__set_badbit_and_consider_rethrow()'
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: main.cpp:(.text._ZNSt6__ndk124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m[_ZNSt6__ndk124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m]+0x190): undefined reference to `__cxa_end_catch'
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: main.cpp:(.text._ZNSt6__ndk124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m[_ZNSt6__ndk124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m]+0x1b8): undefined reference to `__cxa_end_catch'
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: /data/data/com.termux/files/usr/tmp/main-15772a.o: in function `std::__ndk1::basic_ostream<char, std::__ndk1::char_traits<char> >::sentry::~sentry()':
main.cpp:(.text._ZNSt6__ndk113basic_ostreamIcNS_11char_traitsIcEEE6sentryD2Ev[_ZNSt6__ndk113basic_ostreamIcNS_11char_traitsIcEEE6sentryD2Ev]+0x98): undefined reference to `std::uncaught_exception()'
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: main.cpp:(.text._ZNSt6__ndk113basic_ostreamIcNS_11char_traitsIcEEE6sentryD2Ev[_ZNSt6__ndk113basic_ostreamIcNS_11char_traitsIcEEE6sentryD2Ev]+0x110): undefined reference to `__cxa_begin_catch'
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: main.cpp:(.text._ZNSt6__ndk113basic_ostreamIcNS_11char_traitsIcEEE6sentryD2Ev[_ZNSt6__ndk113basic_ostreamIcNS_11char_traitsIcEEE6sentryD2Ev]+0x114): undefined reference to `__cxa_end_catch'
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: /data/data/com.termux/files/usr/tmp/main-15772a.o: in function `__clang_call_terminate':
main.cpp:(.text.__clang_call_terminate[__clang_call_terminate]+0x4): undefined reference to `__cxa_begin_catch'
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: main.cpp:(.text.__clang_call_terminate[__clang_call_terminate]+0x8): undefined reference to `std::terminate()'
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: /data/data/com.termux/files/usr/tmp/main-15772a.o: in function `std::__ndk1::basic_ostream<char, std::__ndk1::char_traits<char> >::flush()':
main.cpp:(.text._ZNSt6__ndk113basic_ostreamIcNS_11char_traitsIcEEE5flushEv[_ZNSt6__ndk113basic_ostreamIcNS_11char_traitsIcEEE5flushEv]+0xe0): undefined reference to `__cxa_begin_catch'
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: main.cpp:(.text._ZNSt6__ndk113basic_ostreamIcNS_11char_traitsIcEEE5flushEv[_ZNSt6__ndk113basic_ostreamIcNS_11char_traitsIcEEE5flushEv]+0xf8): undefined reference to `std::__ndk1::ios_base::__set_badbit_and_consider_rethrow()'
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: main.cpp:(.text._ZNSt6__ndk113basic_ostreamIcNS_11char_traitsIcEEE5flushEv[_ZNSt6__ndk113basic_ostreamIcNS_11char_traitsIcEEE5flushEv]+0x100): undefined reference to `__cxa_end_catch'
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: main.cpp:(.text._ZNSt6__ndk113basic_ostreamIcNS_11char_traitsIcEEE5flushEv[_ZNSt6__ndk113basic_ostreamIcNS_11char_traitsIcEEE5flushEv]+0x128): undefined reference to `__cxa_end_catch'
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: /data/data/com.termux/files/usr/tmp/main-15772a.o: in function `std::__ndk1::__throw_length_error(char const*)':
main.cpp:(.text._ZNSt6__ndk120__throw_length_errorEPKc[_ZNSt6__ndk120__throw_length_errorEPKc]+0x18): undefined reference to `__cxa_allocate_exception'
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: main.cpp:(.text._ZNSt6__ndk120__throw_length_errorEPKc[_ZNSt6__ndk120__throw_length_errorEPKc]+0x30): undefined reference to `typeinfo for std::length_error'
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: main.cpp:(.text._ZNSt6__ndk120__throw_length_errorEPKc[_ZNSt6__ndk120__throw_length_errorEPKc]+0x34): undefined reference to `typeinfo for std::length_error'
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: main.cpp:(.text._ZNSt6__ndk120__throw_length_errorEPKc[_ZNSt6__ndk120__throw_length_errorEPKc]+0x38): undefined reference to `std::length_error::~length_error()'
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: main.cpp:(.text._ZNSt6__ndk120__throw_length_errorEPKc[_ZNSt6__ndk120__throw_length_errorEPKc]+0x3c): undefined reference to `std::length_error::~length_error()'
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: main.cpp:(.text._ZNSt6__ndk120__throw_length_errorEPKc[_ZNSt6__ndk120__throw_length_errorEPKc]+0x40): undefined reference to `__cxa_throw'
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: main.cpp:(.text._ZNSt6__ndk120__throw_length_errorEPKc[_ZNSt6__ndk120__throw_length_errorEPKc]+0x50): undefined reference to `__cxa_free_exception'
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: /data/data/com.termux/files/usr/tmp/main-15772a.o: in function `std::length_error::length_error(char const*)':
main.cpp:(.text._ZNSt12length_errorC2EPKc[_ZNSt12length_errorC2EPKc]+0xc): undefined reference to `vtable for std::length_error'
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: main.cpp:(.text._ZNSt12length_errorC2EPKc[_ZNSt12length_errorC2EPKc]+0x10): undefined reference to `vtable for std::length_error'
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: main.cpp:(.text._ZNSt12length_errorC2EPKc[_ZNSt12length_errorC2EPKc]+0x38): undefined reference to `std::logic_error::logic_error(char const*)'
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: /data/data/com.termux/files/usr/tmp/main-15772a.o: in function `std::__ndk1::__libcpp_allocate(unsigned long, unsigned long)':
main.cpp:(.text._ZNSt6__ndk117__libcpp_allocateEmm[_ZNSt6__ndk117__libcpp_allocateEmm]+0x18): undefined reference to `operator new(unsigned long)'
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: /data/data/com.termux/files/usr/tmp/main-15772a.o: in function `std::__ndk1::_DeallocateCaller::__do_call(void*)':
main.cpp:(.text._ZNSt6__ndk117_DeallocateCaller9__do_callEPv[_ZNSt6__ndk117_DeallocateCaller9__do_callEPv]+0x14): undefined reference to `operator delete(void*)'
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: /data/data/com.termux/files/usr/tmp/main-15772a.o: in function `std::__ndk1::basic_ios<char, std::__ndk1::char_traits<char> >::widen(char) const':
main.cpp:(.text._ZNKSt6__ndk19basic_iosIcNS_11char_traitsIcEEE5widenEc[_ZNKSt6__ndk19basic_iosIcNS_11char_traitsIcEEE5widenEc]+0x20): undefined reference to `std::__ndk1::ios_base::getloc() const'
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: main.cpp:(.text._ZNKSt6__ndk19basic_iosIcNS_11char_traitsIcEEE5widenEc[_ZNKSt6__ndk19basic_iosIcNS_11char_traitsIcEEE5widenEc]+0x4c): undefined reference to `std::__ndk1::locale::~locale()'
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: main.cpp:(.text._ZNKSt6__ndk19basic_iosIcNS_11char_traitsIcEEE5widenEc[_ZNKSt6__ndk19basic_iosIcNS_11char_traitsIcEEE5widenEc]+0x6c): undefined reference to `std::__ndk1::locale::~locale()'
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: /data/data/com.termux/files/usr/tmp/main-15772a.o: in function `std::__ndk1::ctype<char> const& std::__ndk1::use_facet<std::__ndk1::ctype<char> >(std::__ndk1::locale const&)':
main.cpp:(.text._ZNSt6__ndk19use_facetINS_5ctypeIcEEEERKT_RKNS_6localeE[_ZNSt6__ndk19use_facetINS_5ctypeIcEEEERKT_RKNS_6localeE]+0xc): undefined reference to `std::__ndk1::ctype<char>::id'
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: main.cpp:(.text._ZNSt6__ndk19use_facetINS_5ctypeIcEEEERKT_RKNS_6localeE[_ZNSt6__ndk19use_facetINS_5ctypeIcEEEERKT_RKNS_6localeE]+0x10): undefined reference to `std::__ndk1::ctype<char>::id'
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: main.cpp:(.text._ZNSt6__ndk19use_facetINS_5ctypeIcEEEERKT_RKNS_6localeE[_ZNSt6__ndk19use_facetINS_5ctypeIcEEEERKT_RKNS_6localeE]+0x1c): undefined reference to `std::__ndk1::locale::use_facet(std::__ndk1::locale::id&) const'
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: /data/data/com.termux/files/usr/tmp/main-15772a.o: in function `std::__ndk1::ios_base::setstate(unsigned int)':
main.cpp:(.text._ZNSt6__ndk18ios_base8setstateEj[_ZNSt6__ndk18ios_base8setstateEj]+0x28): undefined reference to `std::__ndk1::ios_base::clear(unsigned int)'
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: /data/data/com.termux/files/usr/tmp/main-15772a.o:(.data.DW.ref.__gxx_personality_v0[DW.ref.__gxx_personality_v0]+0x0): undefined reference to `__gxx_personality_v0'
clang-9: error: linker command failed with exit code 1 (use -v to see invocation)

Hi, I have the similar error on my phone which is an android with clang10:
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: /system/lib64/libhwjpeg.so: undefined reference toremote_handle_close@SDSPRPC'
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: /system/lib64/libhwjpeg.so: undefined reference to remote_handle_open@SDSPRPC' /data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: /system/lib64/libhwjpeg.so: undefined reference toremote_handle_invoke@SDSPRPC' `

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bkdwt picture bkdwt  路  3Comments

jackbrycesmith picture jackbrycesmith  路  3Comments

roalyr picture roalyr  路  3Comments

reggi picture reggi  路  4Comments

loveablefellow007 picture loveablefellow007  路  3Comments