ndk-build 使用 amadillo (blas lapack) 和 vlfeat lib
Posted
技术标签:
【中文标题】ndk-build 使用 amadillo (blas lapack) 和 vlfeat lib【英文标题】:ndk-build using amadillo (blas lapack) and vlfeat lib 【发布时间】:2015-05-03 13:42:20 【问题描述】:我正在尝试编译使用犰狳编写的 c++ 代码,我在 config.hpp 中取消了对 blas lapack 的注释,并在 Andriod make 文件中取消了 vlfeat (vl.so)。
在 Jni 文件夹中,我有以下 Andriod.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
PRODUCT_PACKAGES += \libblas
PRODUCT_PACKAGES += \liblapack
PRODUCT_PACKAGES += \libvl
include $(CLEAR_VARS)
LOCAL_MODULE+=mjni
LOCAL_SRC_FILES+=HelloJNI.cpp
LOCAL_SRC_FILES+=featureExtraction.cpp
LOCAL_C_INCLUDES:=$(LOCAL_PATH)/include
LOCAL_C_INCLUDES+=$(LOCAL_PATH)/include/externalInclude/
LOCAL_C_INCLUDES+=$(LOCAL_PATH)/include/externalInclude/armadillo_bits
#LOCAL_SHARED_LIBRARIES := blas lapack
LOCAL_LDLIBS += -llog -ldl
LOCAL_CPP_FEATURES += exceptions
LOCAL_CPPFLAGS += -fexceptions
include $(BUILD_SHARED_LIBRARY)
对于每个模块 blas、lapack 和 vlfeat,我使用了 .so 库,如下所示:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libvl
MY_LIBRARY_NAME := libvl
### export include path
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../include/vl
LOCAL_EXPORT_C_INCLUDES += $(LOCAL_PATH)/../include/src
### path to library
LOCAL_SRC_FILES := libvl.so
### export dependency on the library
LOCAL_EXPORT_LDLIBS += -l$(MY_LIBRARY_NAME)
include $(PREBUILT_SHARED_LIBRARY)
和
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libblas
MY_LIBRARY_NAME := libblas
### export include path
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../include/OpenBLAS/include
### path to library
LOCAL_SRC_FILES := libblas.so
### export dependency on the library
LOCAL_EXPORT_LDLIBS += -l$(MY_LIBRARY_NAME)
include $(PREBUILT_SHARED_LIBRARY)
使用 ndk-build 命令时出现以下错误:
jni/include/externalInclude/armadillo_bits/blas_wrapper.hpp:172: error: undefined reference to 'sdot_'
jni/include/externalInclude/armadillo_bits/blas_wrapper.hpp:98: error: undefined reference to 'ssyrk_'
jni/include/externalInclude/armadillo_bits/blas_wrapper.hpp:28: error: undefined reference to 'sgemv_'
jni/include/externalInclude/armadillo_bits/blas_wrapper.hpp:63: error: undefined reference to 'sgemm_'
error: undefined reference to 'vl_sift_new'
error: undefined reference to 'vl_sift_process_first_octave'
error: undefined reference to 'vl_sift_delete'
error: undefined reference to 'vl_sift_detect'
error: undefined reference to 'vl_sift_calc_keypoint_orientations'
error: undefined reference to 'vl_sift_calc_keypoint_descriptor'
error: undefined reference to 'vl_sift_process_next_octave'
【问题讨论】:
您找到解决链接问题的方法了吗? 【参考方案1】:我也遇到了同样的问题,经过一番挣扎后,我发现了一个问题
-
转到http://danilogiulianelli.blogspot.co.il/2013/02/how-to-build-gcc-fortran-cross-compiler.html 并构建 gcc 交叉编译器。我是为 ndk-8d 做的。
确保在运行脚本后您可以看到脚本在其中创建的 2 个文件夹 android-ndk-r8d\toolchains\arm-linux-androideabi-4.8.0 android-ndk-r8b\android-ndk-r8d\toolchains\x86-4.8.
下载 blas lib 并更新 blas make.in 中的以下字段: 而不是
FORTRAN = gfortran
FORTRAN = $(yourPath)/android-ndk-r8d/toolchains/x86-4.8.0/prebuilt/linux-x86/bin/i686-linux-android-gfortran
运行生成文件。
添加你的 android.mk 并添加以下 localflags
LOCAL_LDFLAGS := $(OPT) $(PROF) -lblas -llapack -lstdc++ -lgfortran
运行 ndk-build
我遇到了 ndk-8d 的问题,它缺少 gcc 4.8 的文件,为了解决这个问题,我从 ndk-9 复制了丢失的文件,它可以工作。【讨论】:
以上是关于ndk-build 使用 amadillo (blas lapack) 和 vlfeat lib的主要内容,如果未能解决你的问题,请参考以下文章
NDK笔记-在Android Studio中使用ndk-build
NDK笔记-在Android Studio中使用ndk-build(转)