Linking issues
How do you guys solve the below linking issues?
~/armnn-devenv/toolchains/aarch64-android-r17b/bin/../lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: libarmnnUtils.a(Logging.cpp.o): undefined reference to symbol '__android_log_write'
Hi @phamyphen, please could you try using:
-DCMAKE_SYSTEM_NAME=Android when you run Cmake, not -DCMAKE_SYSTEM_NAME=Linux.
You will need to delete CmakeCache.txt before running Cmake again.
It appears that this could be an error in our documentation.
I did a try by changing DCMAKE_SYSTEM_NAME from Linux to Android. Below is the errors. Do I need some additional changes?
~/armnn-devenv/armnn/build$ CXX=aarch64-linux-android-clang++ \
CC=aarch64-linux-android-clang
CXX_FLAGS="-fPIE -fPIC"
cmake ..
-DCMAKE_SYSTEM_NAME=Android
-DCMAKE_EXE_LINKER_FLAGS=-pie
-DARMCOMPUTE_ROOT=$HOME/armnn-devenv/ComputeLibrary/
-DARMCOMPUTE_BUILD_DIR=$HOME/armnn-devenv/ComputeLibrary/build
-DBOOST_ROOT=$HOME/armnn-devenv/boost/install/
-DARMCOMPUTENEON=1 -DARMCOMPUTECL=1
-DTF_GENERATED_SOURCES=$HOME/armnn-devenv/google/tf_pb/ -DBUILD_TF_PARSER=1
-DPROTOBUF_ROOT=$HOME/armnn-devenv/google/arm64_pb_install/ CMake Error at /usr/local/share/cmake-3.9/Modules/Platform/Android-Determine.cmake:135 (message): Android: Neither the NDK or a standalone toolchain was found. Call Stack (most recent call first): /usr/local/share/cmake-3.9/Modules/CMakeDetermineSystem.cmake:130 (include) CMakeLists.txt:2 (project)
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage -- Configuring incomplete, errors occurred!
got the same error...
Hi @phamyphen and @lukaszs-appdate
It seems to me that the Android toolchain wasn't created successfully. Could you please try the steps for Downloading the Android NDK and making the toolchain again as mentioned in https://github.com/ARM-software/armnn/blob/master/BuildGuideAndroidNDK.md and see if they are successful.
I hope this solves your problem. Surabhi
@Surmeh ,
How do you confirm that Android NDK(I am using r17b) was created successfully? I tried it again. Same issues.
BTW, the above compiler setting issues happened only after changing DCMAKE_SYSTEM_NAME from Linux to Android.
Any other suggestions?
Best,
phamyphen
Hi @phamyphen and @lukaszs-appdate,
Try changing
DCMAKE_EXE_LINKER_FLAGS=-pie
to
DCMAKE_EXE_LINKER_FLAGS="-pie -llog"
in your cmake configuration. That should link also against Android's log library. You also will need to delete CMakeCache.txt before running cmake again.
That could be an error in our documentation.
Hi,
After fixing the linker error wrt liblog (using -llog linker flag), I get the following linker error. I'm following the complete build instructions from here, on a Ubuntu 16.04 machine. Only difference is that I'm using Android NDK r17 with --api 24 for my toolchain. However, I beleive that should be a problem
Could someone let me know what I'm missing here? Seems something going wrong withthe standard c++ libs and/or STL.
[100%] Linking CXX executable UnitTests
libarmnn.so: undefined reference to std::locale::id::_M_id() const'
libarmnn.so: undefined reference to std::basic_stringstream<char, std::char_traitsvtable for std::basic_streambuf<char, std::char_traits<char> >'
libarmnn.so: undefined reference to std::__detail::_Prime_rehash_policy::_M_next_bkt(unsigned long) const'
libarmnn.so: undefined reference to __once_proxy'
libarmnn.so: undefined reference to std::string::insert(unsigned long, char const*, unsigned long)'
libarmnn.so: undefined reference to std::thread::hardware_concurrency()'
libarmnn.so: undefined reference to std::string::swap(std::string&)'
libarmnn.so: undefined reference to std::string::assign(std::string const&)'
libarmnn.so: undefined reference to std::locale::~locale()'
libarmnn.so: undefined reference to std::basic_ifstream<char, std::char_traits<char> >::~basic_ifstream()'
libarmnn.so: undefined reference to std::istream& std::istream::_M_extractstd::locale::locale(std::locale const&)'
libarmnn.so: undefined reference to typeinfo for std::locale::facet'
libarmnn.so: undefined reference to VTT for std::basic_istringstream<char, std::char_traits<char>, std::allocator<char> >'
libarmnn.so: undefined reference to std::basic_ios<char, std::char_traitsstd::__get_once_mutex()'
libarmnn.so: undefined reference to typeinfo for std::ios_base::failure'
libarmnn.so: undefined reference to std::__throw_bad_cast()'
libarmnn.so: undefined reference to std::__throw_bad_function_call()'
libarmnn.so: undefined reference to std::ostream::flush()'
libarmnn.so: undefined reference to std::istream::seekg(long, std::_Ios_Seekdir)'
libarmnn.so: undefined reference to std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(unsigned long, char, std::allocator<char> const&)'
libarmnn.so: undefined reference to std::string::compare(char const*) const'
libarmnn.so: undefined reference to arm_compute::CLFullyConnectedLayer::CLFullyConnectedLayer(std::__ndk1::shared_ptr<arm_compute::IMemoryManager>)'
libarmnn.so: undefined reference to std::cerr'
libarmnn.so: undefined reference to arm_compute::CLTuner::save_to_file(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&) const'
libarmnn.so: undefined reference to std::ios_base::Init::Init()'
libarmnn.so: undefined reference to std::string::assign(char const*, unsigned long)'
libarmnn.so: undefined reference to std::basic_ifstream<char, std::char_traitsstd::_Rb_tree_increment(std::_Rb_tree_node_base*)'
libarmnn.so: undefined reference to std::string::find(char const*, unsigned long, unsigned long) const'
libarmnn.so: undefined reference to std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long)'
libarmnn.so: undefined reference to std::__throw_system_error(int)'
libarmnn.so: undefined reference to std::thread::join()'
libarmnn.so: undefined reference to std::__detail::_List_node_base::_M_transfer(std::__detail::_List_node_base*, std::__detail::_List_node_base*)'
libarmnn.so: undefined reference to std::__detail::_List_node_base::_M_hook(std::__detail::_List_node_base*)'
libarmnn.so: undefined reference to std::condition_variable::condition_variable()'
libarmnn.so: undefined reference to std::ctype<char>::id'
libarmnn.so: undefined reference to std::basic_ostringstream<char, std::char_traitsstd::string::_Rep::_M_destroy(std::allocator<char> const&)'
libarmnn.so: undefined reference to std::basic_string<char, std::char_traitsstd::collate<char> const& std::use_facet<std::collate<char> >(std::locale const&)'
libarmnn.so: undefined reference to arm_compute::NENormalizationLayer::NENormalizationLayer(std::__ndk1::shared_ptr<arm_compute::IMemoryManager>)'
libarmnn.so: undefined reference to std::basic_istringstream<char, std::char_traits<char>, std::allocator<char> >::basic_istringstream(std::string const&, std::_Ios_Openmode)'
libarmnn.so: undefined reference to std::basic_filebuf<char, std::char_traitsstd::string::_M_replace_safe(unsigned long, unsigned long, char const*, unsigned long)'
libarmnn.so: undefined reference to std::__throw_out_of_range_fmt(char const*, ...)'
libarmnn.so: undefined reference to std::string::append(std::string const&)'
libarmnn.so: undefined reference to std::string::_M_replace_aux(unsigned long, unsigned long, unsigned long, char)'
libarmnn.so: undefined reference to std::__exception_ptr::exception_ptr::swap(std::__exception_ptr::exception_ptr&)'
libarmnn.so: undefined reference to typeinfo for std::ctypearm_compute::CLSoftmaxLayer::CLSoftmaxLayer(std::__ndk1::shared_ptr<arm_compute::IMemoryManager>)'
libarmnn.so: undefined reference to arm_compute::MemoryManagerOnDemand::MemoryManagerOnDemand(std::__ndk1::shared_ptr<arm_compute::ILifetimeManager>, std::__ndk1::shared_ptr<arm_compute::IPoolManager>)'
libarmnn.so: undefined reference to std::chrono::_V2::system_clock::now()'
libarmnn.so: undefined reference to std::ctypestd::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >::basic_stringstream(std::_Ios_Openmode)'
libarmnn.so: undefined reference to std::ostream& std::ostream::_M_insertstd::basic_ofstream<char, std::char_traits<char> >::~basic_ofstream()'
libarmnn.so: undefined reference to std::string::_M_leak_hard()'
libarmnn.so: undefined reference to std::ios_base::Init::~Init()'
libarmnn.so: undefined reference to std::ostream& std::ostream::_M_insertstd::__detail::_List_node_base::_M_unhook()'
libarmnn.so: undefined reference to arm_compute::CLTuner::load_from_file(std::__ndk1::basic_string<char, std::__ndk1::char_traitsstd::cout'
libarmnn.so: undefined reference to std::string::append(char const*, unsigned long)'
libarmnn.so: undefined reference to std::istream::tellg()'
libarmnn.so: undefined reference to std::_Rb_tree_insert_and_rebalance(bool, std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, std::_Rb_tree_node_base&)'
libarmnn.so: undefined reference to std::condition_variable::wait(std::unique_lock<std::mutex>&)'
libarmnn.so: undefined reference to std::ostream::put(char)'
libarmnn.so: undefined reference to std::string::_M_mutate(unsigned long, unsigned long, unsigned long)'
libarmnn.so: undefined reference to arm_compute::NEConvolutionLayer::NEConvolutionLayer(std::__ndk1::shared_ptr<arm_compute::IMemoryManager>)'
libarmnn.so: undefined reference to VTT for std::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >'
libarmnn.so: undefined reference to std::basic_stringbuf<char, std::char_traitsstd::ctype<char>::_M_widen_init() const'
libarmnn.so: undefined reference to std::string::reserve(unsigned long)'
libarmnn.so: undefined reference to std::ios_base::~ios_base()'
libarmnn.so: undefined reference to std::__exception_ptr::exception_ptr::exception_ptr(std::__exception_ptr::exception_ptr const&)'
libarmnn.so: undefined reference to std::istream::operator>>(int&)'
libarmnn.so: undefined reference to std::basic_istream<char, std::char_traitsstd::_Rb_tree_decrement(std::_Rb_tree_node_base*)'
libarmnn.so: undefined reference to std::string::_Rep::_S_create(unsigned long, unsigned long, std::allocatorstd::thread::_M_start_thread(std::shared_ptr<std::thread::_Impl_base>)'
libarmnn.so: undefined reference to std::__set_once_functor_lock_ptr(std::unique_lockstd::mutex)'
libarmnn.so: undefined reference to std::ostream::operator<<(int)'
libarmnn.so: undefined reference to std::_Rb_tree_increment(std::_Rb_tree_node_base const)'
libarmnn.so: undefined reference to typeinfo for std::system_error'
libarmnn.so: undefined reference to arm_compute::NEDirectConvolutionLayer::NEDirectConvolutionLayer(std::__ndk1::shared_ptr<arm_compute::IMemoryManager>)'
libarmnn.so: undefined reference to arm_compute::NESoftmaxLayer::NESoftmaxLayer(std::__ndk1::shared_ptr<arm_compute::IMemoryManager>)'
libarmnn.so: undefined reference to std::__throw_length_error(char const*)'
libarmnn.so: undefined reference to VTT for std::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >'
libarmnn.so: undefined reference to std::__once_functor'
libarmnn.so: undefined reference to std::basic_ofstream<char, std::char_traits<char> >::basic_ofstream()'
libarmnn.so: undefined reference to std::basic_ios<char, std::char_traitsstd::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
libarmnn.so: undefined reference to std::__exception_ptr::exception_ptr::~exception_ptr()'
libarmnn.so: undefined reference to std::basic_filebuf<char, std::char_traits<char> >::close()'
libarmnn.so: undefined reference to std::runtime_error::runtime_error(std::string const&)'
libarmnn.so: undefined reference to std::__throw_logic_error(char const*)'
libarmnn.so: undefined reference to std::condition_variable::~condition_variable()'
libarmnn.so: undefined reference to arm_compute::CLConvolutionLayer::CLConvolutionLayer(std::__ndk1::shared_ptr<arm_compute::IMemoryManager>)'
libarmnn.so: undefined reference to std::basic_string<char, std::char_traitsstd::__detail::_Prime_rehash_policy::_M_need_rehash(unsigned long, unsigned long, unsigned long) const'
libarmnn.so: undefined reference to std::ostream& std::ostream::_M_insertstd::condition_variable::notify_one()'
libarmnn.so: undefined reference to std::locale::locale()'
libarmnn.so: undefined reference to std::_Hash_bytes(void const*, unsigned long, unsigned long)'
libarmnn.so: undefined reference to vtable for std::basic_stringbuf<char, std::char_traitsstd::__throw_regex_error(std::regex_constants::error_type)'
libarmnn.so: undefined reference to std::__basic_filestd::rethrow_exception(std::__exception_ptr::exception_ptr)'
libarmnn.so: undefined reference to arm_compute::NEFullyConnectedLayer::NEFullyConnectedLayer(std::__ndk1::shared_ptr<arm_compute::IMemoryManager>)'
libarmnn.so: undefined reference to `std::string::_Rep::_S_empty_rep_storage'
clang60++: error: linker command failed with exit code 1 (use -v to see invocation)
CMakeFiles/UnitTests.dir/build.make:1199: recipe for target 'UnitTests' failed
make[2]: *** [UnitTests] Error 1
CMakeFiles/Makefile2:106: recipe for target 'CMakeFiles/UnitTests.dir/all' failed
make[1]: *** [CMakeFiles/UnitTests.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2
This could be due to the ACL docs recommending a different version of stl than ArmNN (#44), if two separated toolchains are used for building ACL and ArmNN.
I'd suggest using a single toolchain for both components, as indicated at https://github.com/ARM-software/armnn/blob/master/BuildGuideAndroidNDK.md#download-the-android-ndk-and-make-a-standalone-toolchain.
@santo4ul, alternatively try building both toolchains with "--stl=libc++" and see if that solves the linker errors (if you need to keep the toolchains separated).
I'm able to fix the above linker error.
Looks like the problem was mixing STL in ACL and ARMNN. ACL recommends "--stl=gnustl", while ARMNN uses "--stl=libc++" for toolchains.
I recompiled ACL using the same toolchain I used for ARMNN (with --stl=libc++) and it helped fixing the linker error. However, I'm not sure what runtime errors would comeup.
I've raised this as a separate issue here
Hope we get a resolution on this.
Thanks, San
Hi @santo4ul,
Great to hear you've managed to fix your problem. Please get in touch if you have any more problems.
Thanks, Surabhi