Amalgamation Failed to Build
Android NDK version 11c. Followed README. Error messages are:
arm-linux-androideabi-g++ -std=c++11 -Wno-unknown-pragmas -Wall -I/workspace/OpenBLAS-0.2.18 -mhard-float -D_NDK_MATH_NO_SOFTFP=1 -O3 -MD -MF mxnet_predict0.d \
-I /workspace/mxnet/ -I /workspace/mxnet/mshadow/ -I /workspace/mxnet/dmlc-core/include \
-I /workspace/mxnet/include \
-D__MIN__=0 -c mxnet_predict0.cc
In file included from /workspace/mxnet/mshadow/mshadow/././././extension/implicit_gemm.h:11:0,
from /workspace/mxnet/mshadow/mshadow/./././dot_engine-inl.h:11,
from /workspace/mxnet/mshadow/mshadow/././expr_engine-inl.h:375,
from /workspace/mxnet/mshadow/mshadow/./extension.h:10,
from /workspace/mxnet/mshadow/mshadow/tensor.h:872,
from /workspace/mxnet/src/ndarray/./ndarray_function.h:10,
from /workspace/mxnet/src/ndarray/ndarray_function.cc:8,
from mxnet_predict0.cc:26:
/workspace/mxnet/mshadow/mshadow/././././extension/../packet-inl.h: In function 'void* mshadow::packet::AlignedMallocPitch(size_t*, size_t, size_t)':
/workspace/mxnet/mshadow/mshadow/././././extension/../packet-inl.h:71:61: error: 'posix_memalign' was not declared in this scope
int ret = posix_memalign(&res, 1 << bits, pitch * num_line);
Issue resolved by using platform-24 (instead of 14, I'll test out a minimal requirement later). However, continue to build gives
Generating amalgamation to mxnet_predict-all.cc
python ./amalgamation.py mxnet_predict0.d mxnet_predict0.cc mxnet_predict-all.cc 0 1
* This is a Standard C++ Library file. You should @c \#include this file
#include <bits/c++config.h>
not found
* This is a Standard C++ Library file. You should @c \#include this file
#include <bits/c++config.h>
not found
#include <bits/c++config.h>
not found
#include <bits/c++config.h>
not found
#include <bits/c++config.h>
not found
#include <bits/c++config.h>
not found
#include <bits/c++config.h>
not found
#include <bits/c++config.h>
not found
#include <bits/c++config.h>
not found
#include <bits/c++config.h>
not found
#include <bits/c++config.h>
not found
#include <bits/c++config.h>
not found
#include <bits/c++config.h>
not found
* This is a Standard C++ Library file. You should @c \#include this file
#include <bits/c++config.h>
not found
#include <bits/c++config.h>
not found
#include <bits/c++allocator.h> // Define the base class to std::allocator.
not found
#include <bits/c++config.h>
not found
#include <bits/c++locale.h> // Defines __c_locale, config-specific include
not found
#include <bits/c++config.h>
not found
* This is a Standard C++ Library file. You should @c \#include this file
#include <bits/c++config.h>
not found
#include <bits/c++config.h>
not found
#include <bits/c++config.h>
not found
#include <bits/c++config.h>
not found
#include <bits/c++config.h>
not found
#include <bits/c++config.h>
not found
#include <bits/c++config.h>
not found
#include <bits/c++config.h>
not found
* This is a Standard C++ Library file. You should @c \#include this file
#include <bits/c++config.h>
not found
* #include <iostream>
* #include <fstream>
* #include <exception>
* This is a Standard C++ Library file. You should @c \#include this file
#include <bits/c++config.h>
not found
* This is a Standard C++ Library file. You should @c \#include this file
#include <bits/c++config.h>
not found
* This is a Standard C++ Library file. You should @c \#include this file
* This is a Standard C++ Library file. You should @c \#include this file
#include <bits/c++config.h>
not found
#include <bits/c++config.h>
not found
#include <bits/c++config.h>
not found
#include <bits/c++config.h>
not found
#include <bits/c++config.h>
not found
* This is a Standard C++ Library file. You should @c \#include this file
#include <bits/c++config.h>
not found
* This is a Standard C++ Library file. You should @c \#include this file
#include <bits/c++config.h>
not found
#include <bits/c++config.h>
not found
#include <bits/c++config.h>
not found
#include <bits/c++config.h>
not found
* This is a Standard C++ Library file. You should @c \#include this file
Not processed: mxnet_predict0.o:
Not processed: ../../../opt/android-toolchain/include/c++/4.9/arm-linux-androideabi/bits/c++config.h
Not processed: ../../../opt/android-toolchain/include/c++/4.9/arm-linux-androideabi/bits/os_defines.h
Not processed: ../../../opt/android-toolchain/include/c++/4.9/arm-linux-androideabi/bits/cpu_defines.h
Not processed: ../../../opt/android-toolchain/lib/gcc/arm-linux-androideabi/4.9/include/stdarg.h
Not processed: ../../../opt/android-toolchain/include/c++/4.9/arm-linux-androideabi/bits/c++allocator.h
Not processed: ../../../opt/android-toolchain/include/c++/4.9/ext/new_allocator.h
Not processed: ../../../opt/android-toolchain/include/c++/4.9/arm-linux-androideabi/bits/c++locale.h
Not processed: ../../../opt/android-toolchain/include/c++/4.9/clocale
Not processed: ../../../opt/android-toolchain/include/c++/4.9/backward/binders.h
Not processed: ../../../opt/android-toolchain/include/c++/4.9/bits/alloc_traits.h
Not processed: ../../../opt/android-toolchain/include/c++/4.9/bits/vector.tcc
Not processed: ../../../opt/android-toolchain/include/c++/4.9/bits/locale_classes.tcc
Not processed: ../../../opt/android-toolchain/include/c++/4.9/bits/locale_facets.tcc
Not processed: ../../../opt/android-toolchain/include/c++/4.9/ext/concurrence.h
Not processed: ../../../opt/android-toolchain/include/c++/4.9/bits/unique_ptr.h
Not processed: ../../../opt/android-toolchain/include/c++/4.9/bits/shared_ptr.h
Not processed: ../../../opt/android-toolchain/include/c++/4.9/bits/shared_ptr_base.h
Not processed: ../../../opt/android-toolchain/include/c++/4.9/backward/auto_ptr.h
arm-linux-androideabi-g++ -std=c++11 -Wno-unknown-pragmas -Wall -I/workspace/OpenBLAS-0.2.18 -mhard-float -D_NDK_MATH_NO_SOFTFP=1 -O3 -fPIC -o jni_libmxnet_predict.o -c jni/predictor.cc
In file included from jni/../mxnet_predict-all.cc:19:0,
from jni/predictor.cc:4:
/opt/android-toolchain/include/c++/4.9/bits/exception_ptr.h:40:4: error: #error This platform does not support exception propagation.
# error This platform does not support exception propagation.
^
In file included from jni/../mxnet_predict-all.cc:20:0,
from jni/predictor.cc:4:
/opt/android-toolchain/include/c++/4.9/bits/nested_exception.h:42:4: error: #error This platform does not support exception propagation.
# error This platform does not support exception propagation.
^
In file included from jni/predictor.cc:4:0:
jni/../mxnet_predict-all.cc:21:19: fatal error: c_asm.h: No such file or directory
#include <c_asm.h>
^
compilation terminated.
make: *** [jni_libmxnet_predict.o] Error 1
Looks similar to #2602
After manually removed all includes involved in the previous README (https://github.com/dmlc/mxnet/blob/7773549f5a96eb844d34a3c7814610d4ca26c994/amalgamation/README.md). Another type of error emerged. The immediate one is:
In file included from jni/predictor.cc:4:0:
jni/../mxnet_predict-all.cc:9554:45: error: expected template-name before '<' token
class allocator: public __allocator_base<_Tp>
^
jni/../mxnet_predict-all.cc:9554:45: error: expected '{' before '<' token
jni/../mxnet_predict-all.cc:9554:45: error: expected unqualified-id before '<' token
I figured that probing '/usr/' in file path is not the correct way to exclude system headers, so I changed line 40 of the amalgamation.py to the prefix of my android toolchain (for now, I'll figure out a better way later). Now it generates a much smaller mxnet_predict-all.cc which does not contain STL sources. After manually removed all includes involved in the previous README, it gives a really wired error:
In file included from jni/predictor.cc:4:0:
jni/../mxnet_predict-all.cc:24498:24: error: 'expr' has not been declared
struct TRValue: public expr::RValueExp<Container, DType> {
^
However, I think it has been defined (in mshadow/mshadow/expression.h, which has already been expanded).
Issue resolved by further excluding OpenBLAS headers (in line 40 of amalgamation.py). Still need a elegant solution though.