Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Amalgamation on Android failed #4888

Closed
PhanTask opened this issue Feb 5, 2017 · 2 comments
Closed

Amalgamation on Android failed #4888

PhanTask opened this issue Feb 5, 2017 · 2 comments

Comments

@PhanTask
Copy link

PhanTask commented Feb 5, 2017

Environment info

Operating System: Ubuntu 14.04 64bit Desktop

Compiler: arm-linux-androideabi-g++

MXNet version: v0.9.3

NDK vesion: android-ndk-r13b

Description

I cloned the latest version and tried amalgamation but met some troubles.
I run 'make ANDROID=1' directly and there are two errors.
First:

arm-linux-androideabi-g++ -std=c++11 -Wall -O3 -msse2 -Wno-unknown-pragmas -funroll-loops -Iinclude -fPIC -M -MT nnvm.o \
		-I `pwd`/../ -I `pwd`/../include \
		-D__MIN__=0 nnvm.cc > nnvm.d
arm-linux-androideabi-g++: error: unrecognized command line option '-msse2'

Second:

arm-linux-androideabi-g++ -std=c++11 -Wno-unknown-pragmas -Wall -DMSHADOW_USE_CBLAS=1 -DMSHADOW_USE_SSE=0 -DMSHADOW_USE_CUDA=0 -DMSHADOW_USE_MKL=0 -DMSHADOW_RABIT_PS=0 -DMSHADOW_DIST_PS=0 -DMSHADOW_USE_SSE=0 -DDMLC_LOG_STACK_TRACE=0 -DMSHADOW_FORCE_STREAM -DMXNET_USE_OPENCV=0 -DMXNET_PREDICT_ONLY=1 -DDISABLE_OPENMP=1 -I/home/rokim/OpenBLAS -I/home/rokim/OpenBLAS/include -mhard-float -D_NDK_MATH_NO_SOFTFP=1 -O3 -fPIC -o jni_libmxnet_predict.o -c jni/predictor.cc
In file included from jni/predictor.cc:4:0:
jni/../mxnet_predict-all.cc:54:36: fatal error: src/c_api/c_api_error.cc: No such file or directory
 #include <src/c_api/c_api_error.cc>
                                    ^
compilation terminated.

I checked nnvm.d and, of course, it is empty.
Then I deleted '-msse2' option in mxnet/nnvm/amalgamation/makefile and run make clean make ANDROID=1 again, the first error is replaced by:

                 from nnvm.cc:1:
/home/rokim/mxnet/nnvm/amalgamation/../include/dmlc/./logging.h:18:22: fatal error: execinfo.h: No such file or directory
 #include <execinfo.h>

So I tried to add DEFS in mxnet/nnvm/amalgamation/makefile:

DEFS+=-DMSHADOW_USE_CUDA=0 -DMSHADOW_USE_MKL=0 -DMSHADOW_RABIT_PS=0 -DMSHADOW_DIST_PS=0 -DMSHADOW_USE_SSE=0 -DDMLC_LOG_STACK_TRACE=0 -DMSHADOW_FORCE_STREAM -DMXNET_USE_OPENCV=0 -DMXNET_PREDICT_ONLY=1 -DDISABLE_OPENMP=1
export CFLAGS = -std=c++11 -Wall -O3 -Wno-unknown-pragmas -funroll-loops -Iinclude -fPIC $(DEFS)

And I run make clean make ANDROID=1 again.
The errors mentioned above were gone, and nnvm.d is not empty, but I met some new errors like those:

jni/../mxnet_predict-all.cc:2801:37: error: 'fopen64' was not declared in this scope
jni/../mxnet_predict-all.cc:21495:14: error: 'stoi' is not a member of 'std'
jni/../mxnet_predict-all.cc:30077:52: error: 'to_string' is not a member of 'std'
jni/../mxnet_predict-all.cc:34298:29: error: 'stof' is not a member of 'std'
jni/../mxnet_predict-all.cc:41383:56: error: 'stod' is not a member of 'std'
……

I added #define fopen64 std::fopen in mxnet_predict-all.cc and fopen64 error is gone, but I don't know how to solve others. I think this may be my NDK's problem. What should I do now?

I've attached my mxnet_predict-all.cc and nnvm.d:
mxnet_predict-all.cc.zip
nnvm.d.zip

@PhanTask
Copy link
Author

PhanTask commented Feb 5, 2017

It seems to be a GNU STL library problem. I rebuilded standalone toolchain with libc++ and compiled successfully.

@PhanTask PhanTask closed this as completed Feb 5, 2017
@arank
Copy link
Contributor

arank commented Mar 22, 2017

This is still an issue. When adding --stl=libc++ to the toolchain build the amalgamation build still breaks due to this existing issue with NDK (which break if you use GCC and libc++) which Google refuses to fix:

android/ndk#215

Is there any workaround to this or a WORKING way to compile the android version from source using the existing toolchain?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants