Reputation: 2960
I am trying to compile TBB source files from threadingbuildingblocks.
I have tried all available solutions on stackoverflow but none of them works. The error I am getting is:
lib -L/cygdrive/d/Android/NDK/sources/cxx-stl/gnu-libstdc++/4.6/libs/x86 -lgnustl_shared -shared -Wl,-soname=libtbb.so --sysroot=/cygdrive/d/Android/NDK/platforms/android-9/arch-x86 -m32 -Wl,--version-script,tbb.def
d:/android/ndk/toolchains/x86-4.6/prebuilt/windows/bin/../lib/gcc/i686-linux-android/4.6/../../../../i686-linux-android/bin/ld.exe: error: cannot find -ldl
d:/android/ndk/toolchains/x86-4.6/prebuilt/windows/bin/../lib/gcc/i686-linux-android/4.6/../../../../i686-linux-android/bin/ld.exe: error: cannot find -lgnustl_shared
d:/android/ndk/toolchains/x86-4.6/prebuilt/windows/bin/../lib/gcc/i686-linux-android/4.6/../../../../i686-linux-android/bin/ld.exe: error: cannot find -lstdc++
d:/android/ndk/toolchains/x86-4.6/prebuilt/windows/bin/../lib/gcc/i686-linux-android/4.6/../../../../i686-linux-android/bin/ld.exe: error: cannot find -lm
d:/android/ndk/toolchains/x86-4.6/prebuilt/windows/bin/../lib/gcc/i686-linux-android/4.6/../../../../i686-linux-android/bin/ld.exe: error: cannot find -lc
d:/android/ndk/toolchains/x86-4.6/prebuilt/windows/bin/../lib/gcc/i686-linux-android/4.6/../../../../i686-linux-android/bin/ld.exe: error: cannot find -ldl
collect2: ld returned 1 exit status
../../build/Makefile.tbb:127: recipe for target `libtbb.so' failed
make[1]: *** [libtbb.so] Error 1
make[1]: Leaving directory `/cygdrive/d/OpenCV4Android/workspace_july_2013/TbbLib/jni/build/linux_ia32_gcc_android_cc4.6_release'
jni/Makefile:40: recipe for target `tbb' failed
make: *** [tbb] Error 2
Here is my Android.mk file:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libstdc++
LOCAL_SRC_FILES := libstdc++.so
include $(PREBUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
ifeq (armeabi-v7a,$(APP_ABI))
export SYSROOT:=$(NDK_ROOT)/platforms/$(APP_PLATFORM)/arch-arm
else
export SYSROOT:=$(NDK_ROOT)/platforms/$(APP_PLATFORM)/arch-$(APP_ABI)
endif
ifeq (windows,$(tbb_os))
export CPATH_SEPARATOR :=;
else
export CPATH_SEPARATOR :=:
endif
export CPATH := $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/$(NDK_TOOLCHAIN_VERSION)/include$(CPATH_SEPARATOR)$(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/$(NDK_TOOLCHAIN_VERSION)/libs/$(APP_ABI)/include
export LIB_GNU_STL_ANDROID := $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/$(NDK_TOOLCHAIN_VERSION)/libs/$(APP_ABI)
export CPLUS_LIB_PATH := $(SYSROOT)/usr/lib -L$(LIB_GNU_STL_ANDROID)
export ANDROID_NDK_ROOT:=$(NDK_ROOT)
export target_os_version:=$(APP_PLATFORM)
export tbb_tool_prefix:=$(TOOLCHAIN_PREFIX)
LOCAL_CFLAGS += -DTBB_USE_GCC_BUILTINS -std=c++11
LOCAL_C_INCLUDES := $(NDK_PROJECT_PATH)/jni/include
LOCAL_C_INCLUDES += $(NDK_PROJECT_PATH)/jni/include/tbb
LOCAL_C_INCLUDES += $(NDK_PROJECT_PATH)/jni/src/rml/include
LOCAL_C_INCLUDES += $(NDK_PROJECT_PATH)/jni/include/serial/tbb
CPPFLAGS +="-I$(NDK_ROOT)/platforms/android-9/arch-x86/usr/include/" \
CFLAGS="-nostdlib" \
LDFLAGS="-Wl,-rpath-link=$(NDK_ROOT)/platforms/android-9/arch-x86/usr/lib/ -L$(NDK_ROOT)/platforms/android-9/arch-x86/usr/lib/" \
LIBS="-lc"
LOCAL_PATH := $(NDK_PROJECT_PATH)/jni/src/tbb
LOCAL_MODULE := tbb
#export MAKE_PATH=D:/Android/NDK/prebuilt/windows/bin
include $(NDK_PROJECT_PATH)/jni/Makefile
#LOCAL_SRC_FILES := concurrent_hash_map.cpp concurrent_vector.cpp dynamic_link.cpp itt_notify.cpp cache_aligned_allocator.cpp queuing_mutex.cpp queuing_rw_mutex.cpp reader_writer_lock.cpp spin_rw_mutex.cpp spin_mutex.cpp critical_section.cpp tbb_misc.cpp tbb_misc_ex.cpp mutex.cpp recursive_mutex.cpp condition_variable.cpp concurrent_monitor.cpp semaphore.cpp rml_tbb.cpp tbb_statistics.cpp tbb_thread.cpp governor.cpp market.cpp arena.cpp scheduler.cpp observer_proxy.cpp pipeline.cpp tbb_thread.cpp private_server.cpp task_group_context.cpp task.cpp tbb_main.cpp
include $(BUILD_SHARED_LIBRARY)
Here is my Application.mk file:
export tbb_os?=linux
export compiler?=gcc
export arch?=ia32
export target?=android
ifeq (arm,$(arch))
APP_ABI:=armeabi-v7a
else
APP_ABI:=x86
endif
APP_PLATFORM:=android-9
NDK_TOOLCHAIN_VERSION:=4.6
APP_STL :=gnustl_shared
Please let me know if I should add some other file here to let you understand the issue.
Upvotes: 2
Views: 8107
Reputation: 2960
The solution to my problem was that it was trying to load libraries from the path
-L/cygdrive/d/Android/NDK/platforms/android-9/arch-x86/usr/lib
-L/cygdrive/d/Android/NDK/sources/cxx-stl/gnu-libstdc++/4.6/libs/x86
which is indeed right location on my drive but not correct path on Windows.
I had to hardocde this part of the code with Windows understandable path text as:
-LD:/Android/NDK/platforms/android-9/arch-x86/usr/lib
-LD:/Android/NDK/sources/cxx-stl/gnu-libstdc++/4.6/libs/x86
Upvotes: 1
Reputation: 675
Multiple libraries cannot be found. Try to find out where these libraries are located on your system.
In the makefile, this path is added to LD_FLAGS for the linker to search:
-L$(NDK_ROOT)/platforms/android-9/arch-x86/usr/lib/
First, check if the required libraries can be found there (e.g. libm.so)
If not, try to find out whether they are somewhere else on your system. On Linux, libdl.so, libm.so etc. can be found in /usr/lib64 (/usr/lib on a 32-bit system). If you find them, add the path to LDFLAGS as for the path above:
-L/path/to/libs
Upvotes: 0