2013-07-25 47 views
0

我試圖從threadingbuildingblocks編譯TBB源文件。獲取錯誤ld.exe:錯誤:無法在編譯tbb源文件時在ndk中找到-lgnustl_shared

我已經嘗試了所有可用的解決方案,但沒有一個能夠運行。 我得到的錯誤是:

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 

這裏是我的Android.mk文件:

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) 

這裏是我的Application.mk文件:

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 

請讓我知道如果我應該在這裏添加一些其他文件,讓你瞭解這個問題。

+0

爲什麼不使用包裝成TBB的Linux版本的二進制版本(不回答你的問題) – Samveen

+0

感謝Samveen期待你的答覆。你可以請一些鏈接詳細說明我該怎麼做? –

+0

[TBB下載頁面](http://threadingbuildingblocks.org/download)提到了甚至包含Android的Linux版本的TBB。 (在下載頁面上搜索android) – Samveen

回答

0

我的問題的解決方案是,它試圖從路徑

-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 

加載庫這確實是正確的在我的驅動器上的位置,但在Windows上不正確的路徑。

我不得不hardocde的這部分代碼與Windows可以理解的路徑文本:

-LD:/Android/NDK/platforms/android-9/arch-x86/usr/lib 
-LD:/Android/NDK/sources/cxx-stl/gnu-libstdc++/4.6/libs/x86 
0

無法找到多個庫。嘗試找出這些庫在系統中的位置。

在生成文件中,這個路徑添加到LD_FLAGS鏈接器搜索:

-L$(NDK_ROOT)/platforms/android-9/arch-x86/usr/lib/ 

首先,檢查所需的庫可以在那裏找到(如libm.so)

如果沒有,試着找出它們是否在你係統的其他地方。在Linux上,可以在/ usr/lib64(32位系統上的/ usr/lib)中找到libdl.so,libm.so等。如果你發現它們的路徑添加到LDFLAGS如對上述路徑:

-L/path/to/libs 
相關問題