Skip to content

Commit

Permalink
fixup android build issues
Browse files Browse the repository at this point in the history
Former-commit-id: 4db877f
  • Loading branch information
cyberfire committed Jun 19, 2018
1 parent 08b987a commit a652e79
Show file tree
Hide file tree
Showing 17 changed files with 99 additions and 37 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ if(CONFIG_ARCH_BLAS)
TARGET_LINK_LIBRARIES(tengine ${BLAS_DIR}/arm32/lib/libopenblas.so)
endif()
if(ANDROID AND ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "aarch64"))
set(PROTOBUF_LIB ${BLAS_DIR}/arm64/lib/libopenblas.so)
endif()
TARGET_LINK_LIBRARIES(tengine ${BLAS_DIR}/arm64/lib/libopenblas.so)
endif()
else()
message(FATAL_ERROR "need to set the blas path")
endif()
Expand Down
2 changes: 1 addition & 1 deletion android_config.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ANDROID_NDK:/home/usr/android-ndk-r16
PROTOBUF_DIR:/home/usr/protobuf_lib
BLAS_DIR:/home/usr/openbla020_android
CONFIG_ARCH_TYPE:ARMv7
CONFIG_ARCH_TYPE:ARMv8

8 changes: 5 additions & 3 deletions doc/build_android.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## 1.Download Tengine poject
```
git clone https://github.com/OAID/tengine/
git clone https://github.com/OAID/tengine/
```
## 2.Download OpenCV protobuf OpenBLAS and Android ndk

Expand All @@ -19,7 +19,7 @@ tar -zxvf openblas020_android.tgz
```
## 4.Set the *NDK PATH*,*PROTOBUF_DIR*,*BLAS PATH* and *CONFIG_ARCH_TYPE*
if you want to build android for armv7,set the CONFIG_ARCH_TYPE:**ARMv7**
,otherwise ,set the CONFIG_ARCH_TYPE:**ARMv8**
.otherwise,set the CONFIG_ARCH_TYPE:**ARMv8**
```
vim ~/tengine/android_config.txt
```
Expand All @@ -40,7 +40,9 @@ if you want to run tengine with openblas, remove the DCONFIG_ARCH_ARM64 or DCONF
cd ~
unzip opencv-3.4.0-android-sdk.zip
```
### 6.2 Set the *TENGINE_DIR*, *OpenCV_DIR*, *PROTOBUF_DIR*
### 6.2 Set the *TENGINE_DIR*, *OpenCV_DIR*, *PROTOBUF_DIR*.
if you want to run Tengine with OpenBlas, please add the correct blas path in example/android_build_armv7.sh or example/android_build_armv8.sh.eg: -DBLAS_DIR=/home/usr/openbla020_android.

```
cd ~/tengine/example
vim android_build_armv7.sh or
Expand Down
9 changes: 5 additions & 4 deletions examples/android_build_armv7.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#!/bin/bash

export ANDROID_NDK=/home/zhangrui/android-ndk-r16
export ANDROID_NDK=/home/usr/android-ndk-r16

cmake -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake \
-DANDROID_ABI="armeabi-v7a" \
-DANDROID_PLATFORM=android-21 \
-DANDROID_STL=gnustl_shared \
-DTENGINE_DIR=/home/zhangrui/zr_tengine/tengine \
-DOpenCV_DIR=/home/zhangrui/OpenCV-android-sdk/sdk/native/jni \
-DPROTOBUF_DIR=/home/zhangrui/oaid_tengine/tengine/protobuf_lib \
-DTENGINE_DIR=/home/usr/tengine \
-DOpenCV_DIR=/home/usr/OpenCV-android-sdk/sdk/native/jni \
-DPROTOBUF_DIR=/home/usr/protobuf_lib \
-DBLAS_DIR=/home/usr/openbla020_android \
..

8 changes: 4 additions & 4 deletions examples/android_build_armv8.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/bin/bash

export ANDROID_NDK=/home/zhangrui/android-ndk-r16
export ANDROID_NDK=/home/usr/android-ndk-r16

cmake -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake \
-DANDROID_ABI="arm64-v8a" \
-DANDROID_PLATFORM=android-21 \
-DANDROID_STL=gnustl_shared \
-DTENGINE_DIR=/home/zhangrui/zr_tengine/tengine \
-DOpenCV_DIR=/home/zhangrui/OpenCV-android-sdk/sdk/native/jni \
-DPROTOBUF_DIR=/home/zhangrui/oaid_tengine/tengine/protobuf_lib \
-DTENGINE_DIR=/home/usr/tengine \
-DOpenCV_DIR=/home/usr/OpenCV-android-sdk/sdk/native/jni \
-DPROTOBUF_DIR=/home/usr/protobuf_lib \
..

2 changes: 2 additions & 0 deletions examples/caffe_wrapper/cpp_classification/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ add_definitions(-DCPU_ONLY)
#opencv
find_package(OpenCV REQUIRED)

set(CMAKE_CXX_FLAGS "-std=c++11 -O3 -Wall")

#include
include_directories(${INSTALL_DIR}/wrapper_include
${INSTALL_DIR}/include)
Expand Down
2 changes: 1 addition & 1 deletion examples/caffe_wrapper/mtcnn/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ set( TENGINE_LIBS wrapper tengine )
set( CAFFE_MTCNN_SRCS test_caffe_mtcnn.cpp caffe_mtcnn.cpp caffe_mtcnn_utils.cpp )

#flag
#set(CMAKE_CXX_FLAGS "-std=c++11 -O3 -Wall")
set(CMAKE_CXX_FLAGS "-std=c++11 -O3 -Wall")

#opencv
find_package(OpenCV REQUIRED)
Expand Down
11 changes: 10 additions & 1 deletion examples/faster_rcnn/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ endif()

set( RESNET_SRCS faster_rcnn.cpp ../common/common.cpp)

if( BLAS_DIR)
if( ANDROID AND ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "armv7-a"))
set( BLAS_LIB ${BLAS_DIR}/arm32/lib/libopenblas.so)
endif()
if( ANDROID AND ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "aarch64"))
set( BLAS_LIB ${BLAS_DIR}/arm64/lib/libopenblas.so)
endif()
endif()

#opencv
find_package(OpenCV REQUIRED)

Expand All @@ -26,7 +35,7 @@ link_directories( ${INSTALL_DIR}/lib )
#exe
add_executable(FASTER_RCNN ${RESNET_SRCS})
if( ANDROID)
target_link_libraries(FASTER_RCNN ${TENGINE_LIBS} ${PROTOBUF_LIB} ${OpenCV_LIBS})
target_link_libraries(FASTER_RCNN ${TENGINE_LIBS} ${PROTOBUF_LIB} ${OpenCV_LIBS} ${BLAS_LIB})
else()
target_link_libraries(FASTER_RCNN ${TENGINE_LIBS} ${OpenCV_LIBS})
endif()
Expand Down
12 changes: 11 additions & 1 deletion examples/imagenet_classification/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ if( ANDROID AND ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "aarch64"))
set( PROTOBUF_LIB ${PROTOBUF_DIR}/arm64_lib/libprotobuf.so)
endif()

if( BLAS_DIR)
if( ANDROID AND ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "armv7-a"))
set( BLAS_LIB ${BLAS_DIR}/arm32/lib/libopenblas.so)
endif()
if( ANDROID AND ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "aarch64"))
set( BLAS_LIB ${BLAS_DIR}/arm64/lib/libopenblas.so)
endif()
endif()


set( CODE_SRCS classification.cpp model_config.cpp ../common/common.cpp )
set( BIN_EXE Classify )

Expand All @@ -26,7 +36,7 @@ link_directories(${INSTALL_DIR}/lib)
#exe
add_executable(${BIN_EXE} ${CODE_SRCS})
if(ANDROID)
target_link_libraries(${BIN_EXE} ${PROTOBUF_LIB} ${TENGINE_LIBS} ${OpenCV_LIBS})
target_link_libraries(${BIN_EXE} ${PROTOBUF_LIB} ${TENGINE_LIBS} ${OpenCV_LIBS} ${BLAS_LIB})
else()
target_link_libraries(${BIN_EXE} ${TENGINE_LIBS} ${OpenCV_LIBS})
endif()
11 changes: 10 additions & 1 deletion examples/lighten_cnn/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ if( ANDROID AND ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "aarch64"))
endif()
set( CODE_SRCS lighten_cnn.cpp ../common/common.cpp )

if( BLAS_DIR)
if( ANDROID AND ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "armv7-a"))
set( BLAS_LIB ${BLAS_DIR}/arm32/lib/libopenblas.so)
endif()
if( ANDROID AND ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "aarch64"))
set( BLAS_LIB ${BLAS_DIR}/arm64/lib/libopenblas.so)
endif()
endif()

#opencv
find_package(OpenCV REQUIRED)

Expand All @@ -24,7 +33,7 @@ link_directories(${INSTALL_DIR}/lib)
#exe
add_executable(LIGHTEN_CNN ${CODE_SRCS})
if( ANDROID)
target_link_libraries(LIGHTEN_CNN ${TENGINE_LIBS} ${PROTOBUF_LIB} ${OpenCV_LIBS})
target_link_libraries(LIGHTEN_CNN ${TENGINE_LIBS} ${PROTOBUF_LIB} ${OpenCV_LIBS} ${BLAS_LIB})
else()
target_link_libraries(LIGHTEN_CNN ${TENGINE_LIBS} ${OpenCV_LIBS})
endif()
Expand Down
12 changes: 11 additions & 1 deletion examples/mobilenet_ssd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ if( ANDROID AND ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "aarch64"))
set( PROTOBUF_LIB ${PROTOBUF_DIR}/arm64_lib/libprotobuf.so)
endif()

if( BLAS_DIR)
if( ANDROID AND ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "armv7-a"))
set( BLAS_LIB ${BLAS_DIR}/arm32/lib/libopenblas.so)
endif()
if( ANDROID AND ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "aarch64"))
set( BLAS_LIB ${BLAS_DIR}/arm64/lib/libopenblas.so)
endif()
endif()


set( CODE_SRCS mssd.cpp ../common/common.cpp)

#opencv
Expand All @@ -27,7 +37,7 @@ link_directories( ${INSTALL_DIR}/lib)
#exe
add_executable(MSSD ${CODE_SRCS})
if( ANDROID)
target_link_libraries(MSSD ${TENGINE_LIBS} ${PROTOBUF_LIB} ${OpenCV_LIBS})
target_link_libraries(MSSD ${TENGINE_LIBS} ${PROTOBUF_LIB} ${OpenCV_LIBS} ${BLAS_LIB})
else()
target_link_libraries(MSSD ${TENGINE_LIBS} ${OpenCV_LIBS})
endif()
Expand Down
11 changes: 10 additions & 1 deletion examples/mtcnn/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ if( ANDROID AND ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "aarch64"))
set( PROTOBUF_LIB ${PROTOBUF_DIR}/arm64_lib/libprotobuf.so)
endif()

if( BLAS_DIR)
if( ANDROID AND ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "armv7-a"))
set( BLAS_LIB ${BLAS_DIR}/arm32/lib/libopenblas.so)
endif()
if( ANDROID AND ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "aarch64"))
set( BLAS_LIB ${BLAS_DIR}/arm64/lib/libopenblas.so)
endif()
endif()

set( MTCNN_SRCS mtcnn_utils.cpp mtcnn.cpp test_mtcnn.cpp ../common/common.cpp )

#opencv
Expand All @@ -26,7 +35,7 @@ link_directories(${INSTALL_DIR}/lib)
#exe
add_executable(MTCNN ${MTCNN_SRCS})
if( ANDROID)
target_link_libraries(MTCNN ${TENGINE_LIBS} ${PROTOBUF_LIB} ${OpenCV_LIBS})
target_link_libraries(MTCNN ${TENGINE_LIBS} ${PROTOBUF_LIB} ${OpenCV_LIBS} ${BLAS_LIB})
else()
target_link_libraries(MTCNN ${TENGINE_LIBS} ${OpenCV_LIBS})
endif()
Expand Down
2 changes: 1 addition & 1 deletion examples/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ make -j4
cd ~/tengine/examples
vim android_build_armv7.sh or vim android_build_armv8.sh
```
Set the correct NDK path ,Tengine path ,Opencv path and protobuf path
Set the correct NDK path ,Tengine path ,Opencv path and protobuf path. if you want to run Tengine with OpenBlas, please add the correct blas path in android_build_armv7.sh or android_build_armv8.sh.eg: -DBLAS_DIR=/home/usr/openbla020_android
```
mkdir build
cd build
Expand Down
11 changes: 10 additions & 1 deletion examples/ssd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ if( ANDROID AND ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "aarch64"))
endif()
set( CODE_SRCS ssd.cpp ../common/common.cpp)

if( BLAS_DIR)
if( ANDROID AND ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "armv7-a"))
set( BLAS_LIB ${BLAS_DIR}/arm32/lib/libopenblas.so)
endif()
if( ANDROID AND ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "aarch64"))
set( BLAS_LIB ${BLAS_DIR}/arm64/lib/libopenblas.so)
endif()
endif()


#opencv
find_package(OpenCV REQUIRED)
Expand All @@ -26,7 +35,7 @@ link_directories( ${INSTALL_DIR}/lib)
#exe
add_executable(SSD ${CODE_SRCS})
if( ANDROID)
target_link_libraries(SSD ${TENGINE_LIBS} ${PROTOBUF_LIB} ${OpenCV_LIBS})
target_link_libraries(SSD ${TENGINE_LIBS} ${PROTOBUF_LIB} ${OpenCV_LIBS} ${BLAS_LIB})
else()
target_link_libraries(SSD ${TENGINE_LIBS} ${OpenCV_LIBS})
endif()
Expand Down
3 changes: 3 additions & 0 deletions examples/tensorflow_wrapper/label_image/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ include_directories(${INSTALL_DIR}/wrapper_include
${INSTALL_DIR}/include
${TENGINE_DIR}/examples/common)


set(CMAKE_CXX_FLAGS "-std=c++11 -O3 -Wall")

#lib
link_directories(${INSTALL_DIR}/lib)

Expand Down
18 changes: 13 additions & 5 deletions examples/yolov2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ endif()
if( ANDROID AND ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "aarch64"))
set( PROTOBUF_LIB ${PROTOBUF_DIR}/arm64_lib/libprotobuf.so)
endif()
if( BLAS_DIR)
if( ANDROID AND ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "armv7-a"))
set( BLAS_LIB ${BLAS_DIR}/arm32/lib/libopenblas.so)
endif()
if( ANDROID AND ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "aarch64"))
set( BLAS_LIB ${BLAS_DIR}/arm64/lib/libopenblas.so)
endif()
endif()

set( CODE_SRCS yolov2.cpp ../common/common.cpp)
set( BIN_EXE YOLOV2)
Expand All @@ -19,18 +27,18 @@ find_package(OpenCV REQUIRED)

#include
include_directories(${INSTALL_DIR}/include
${TENGINE_DIR}/include
${TENGINE_DIR}/core/include
${TENGINE_DIR}/operator/include
${TENGINE_DIR}/examples/common)
${TENGINE_DIR}/include
${TENGINE_DIR}/core/include
${TENGINE_DIR}/operator/include
${TENGINE_DIR}/examples/common)

#lib
link_directories( ${INSTALL_DIR}/lib )

#exe
add_executable(${BIN_EXE} ${CODE_SRCS})
if( ANDROID)
target_link_libraries(${BIN_EXE} ${TENGINE_LIBS} ${PROTOBUF_LIB} ${OpenCV_LIBS})
target_link_libraries(${BIN_EXE} ${TENGINE_LIBS} ${PROTOBUF_LIB} ${OpenCV_LIBS} ${BLAS_LIB})
else()
target_link_libraries(${BIN_EXE} ${TENGINE_LIBS} ${OpenCV_LIBS})
endif()
Expand Down
10 changes: 0 additions & 10 deletions sysroot/config

This file was deleted.

0 comments on commit a652e79

Please sign in to comment.