Skip to content

Commit

Permalink
Fix amalgamation compiling issue. (apache#2814)
Browse files Browse the repository at this point in the history
* .gitignore
Add Eclipse project files

* Fix amalgamation compiling issue (apache#2602, apache#2808). Add minimum Android API
level requirement in README.

* Fix amalgamation compiling issue (apache#2602, apache#2808)

Keep ${OPENBLAS_ROOT}/include and ${OPENBLAS_ROOT}/lib in Makefile
  • Loading branch information
Allan Lu authored and piiswrong committed Jul 24, 2016
1 parent a1b404c commit 3fb29a3
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,8 @@ scala-package/*/*/target/
!scala-package/*/bin
*.bak
*/node_modules/

# Eclipse project config
.project
.cproject
.pydevproject
12 changes: 6 additions & 6 deletions amalgamation/Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
export MXNET_ROOT=`pwd`/..
# Change this to path of openblas
export OPENBLAS_ROOT=`pwd`/OpenBLAS
export OPENBLAS_ROOT=${MXNET_ROOT}/../OpenBLAS

# Whether use minimum build without blas and SSE, this will make the library super slow
ifndef MIN
export MIN= 0
export MIN=0
endif

ifndef ANDROID
export ANDROID=0
export ANDROID=0
endif


Expand All @@ -17,8 +17,8 @@ endif

CFLAGS=-std=c++11 -Wno-unknown-pragmas -Wall
ifneq ($(MIN), 1)
CFLAGS+= -I${OPENBLAS_ROOT}/include
LDFLAGS+=-L${OPENBLAS_ROOT}/lib -lopenblas
CFLAGS += -I${OPENBLAS_ROOT} -I${OPENBLAS_ROOT}/include
LDFLAGS+= -L${OPENBLAS_ROOT} -L${OPENBLAS_ROOT}/lib -lopenblas
endif


Expand Down Expand Up @@ -68,4 +68,4 @@ ${MXNET_ROOT}/lib/libmxnet_predict.so: mxnet_predict-all.o
ls -alh $@

clean:
rm -f *.d *.o
rm -f *.d *.o *.so *.a mxnet_predict-all.cc
4 changes: 2 additions & 2 deletions amalgamation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ This module is created by [Jack Deng](https://github.com/jdeng).

Android
---------------
Setup NDK and build your standalone toolchain. [Instructions](http://developer.android.com/ndk/guides/standalone_toolchain.html#itc) Use the Advanced Method!!! In particular set PATH, CC and CXX.
Setup NDK and build your standalone toolchain. [Instructions](http://developer.android.com/ndk/guides/standalone_toolchain.html#itc) Use the Advanced Method!!! In particular set PATH, CC and CXX. The minimum API level required is 16.

Example:
```
Expand All @@ -33,7 +33,7 @@ export CC=arm-linux-androideabi-gcc # or export CC=arm-linux-androideabi-clang
export CXX=arm-linux-androideabi-g++ # or export CXX=arm-linux-androideabi-clang++
```

Build OpenBlas for Android: [Build OpenBlas](https://github.com/xianyi/OpenBLAS/wiki/How-to-build-OpenBLAS-for-Android)
Build OpenBLAS for Android: [Build OpenBLAS](https://github.com/xianyi/OpenBLAS/wiki/How-to-build-OpenBLAS-for-Android) Please put OpenBLAS source code outside mxnet directory.
Modify OPENBLAS_ROOT in Makefile
Type ```make ANDROID=1```

Expand Down
5 changes: 3 additions & 2 deletions amalgamation/amalgamation.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@ def get_sources(def_file):
sources = []
files = []
visited = set()
mxnet_path = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), os.pardir))
for line in open(def_file):
files = files + line.strip().split(' ')

for f in files:
f = f.strip()
if not f or f.endswith('.o') or f == '\\': continue
if not f or f.endswith('.o:') or f == '\\': continue
fn = os.path.relpath(f)
if fn.find('/usr/') < 0 and fn not in visited:
if os.path.abspath(f).startswith(mxnet_path) and fn not in visited:
sources.append(fn)
visited.add(fn)
return sources
Expand Down

0 comments on commit 3fb29a3

Please sign in to comment.