Kitt-AI/snowboy

Build android error collect2: error: ld returned 1 exit status

neo1949 opened this issue · 0 comments

I have ever compiled the lib before, this time I want to make for ARMv8 64bit and get error like this:

$ make BIT=64
/home/avatarmind/work/projects/snowboy/swig/Android/ndk_install_64bit/bin/aarch64-linux-android-g++ -Wl,-soname,libsnowboy-detect-android.so -O3 --sysroot=/home/avatarmind/work/projects/snowboy/swig/Android/ndk_install_64bit/sysroot -std=c++0x -rdynamic -I../../ -Werror -Wall -fsigned-char -fpic -fPIC -march=armv8-a -DNDEBUG -ffast-math -fomit-frame-pointer -O3 -pie -fPIE -DHAVE_NEON=1 -fno-strict-aliasing -Wno-unused-function -shared  \
  snowboy-detect-swig.o ../..//lib/android/armv8-aarch64/libsnowboy-detect.a OpenBLAS-Android-ARM64/install/lib/libopenblas.a \
  -L/home/avatarmind/work/projects/snowboy/swig/Android/ndk_install_64bit/sysroot/usr/lib -L/home/avatarmind/work/projects/snowboy/swig/Android/android-ndk-r14b/sources/cxx-stl/gnu-libstdc++/4.9/libs/arm64-v8a -lgnustl_static -lsupc++ -lgcc -ldl -lc -lm -llog -pthread -o jniLibs/arm64-v8a/libsnowboy-detect-android.so
snowboy-detect-swig.o: error adding symbols: File in wrong format
collect2: error: ld returned 1 exit status
make: *** [jniLibs/arm64-v8a/libsnowboy-detect-android.so] Error 1

Use make clean to clean the build:

$ make clean
rm -rf *.o *.a *.so java jniLibs snowboy-detect-swig.cc

Build again and it succeeded:

$ make BIT=64
swig -I../../ -c++ -java -package ai.kitt.snowboy -outdir \
  java/ai/kitt/snowboy/ -o snowboy-detect-swig.cc snowboy-detect-swig.i
/home/avatarmind/work/projects/snowboy/swig/Android/ndk_install_64bit/bin/aarch64-linux-android-g++ -O3 --sysroot=/home/avatarmind/work/projects/snowboy/swig/Android/ndk_install_64bit/sysroot -std=c++0x -rdynamic -I../../ -Werror -Wall -fsigned-char -fpic -fPIC -march=armv8-a -DNDEBUG -ffast-math -fomit-frame-pointer -O3 -pie -fPIE -DHAVE_NEON=1 -fno-strict-aliasing -Wno-unused-function -shared -c snowboy-detect-swig.cc -o snowboy-detect-swig.o
/home/avatarmind/work/projects/snowboy/swig/Android/ndk_install_64bit/bin/aarch64-linux-android-g++ -Wl,-soname,libsnowboy-detect-android.so -O3 --sysroot=/home/avatarmind/work/projects/snowboy/swig/Android/ndk_install_64bit/sysroot -std=c++0x -rdynamic -I../../ -Werror -Wall -fsigned-char -fpic -fPIC -march=armv8-a -DNDEBUG -ffast-math -fomit-frame-pointer -O3 -pie -fPIE -DHAVE_NEON=1 -fno-strict-aliasing -Wno-unused-function -shared  \
  snowboy-detect-swig.o ../..//lib/android/armv8-aarch64/libsnowboy-detect.a OpenBLAS-Android-ARM64/install/lib/libopenblas.a \
  -L/home/avatarmind/work/projects/snowboy/swig/Android/ndk_install_64bit/sysroot/usr/lib -L/home/avatarmind/work/projects/snowboy/swig/Android/android-ndk-r14b/sources/cxx-stl/gnu-libstdc++/4.9/libs/arm64-v8a -lgnustl_static -lsupc++ -lgcc -ldl -lc -lm -llog -pthread -o jniLibs/arm64-v8a/libsnowboy-detect-android.so
/home/avatarmind/work/projects/snowboy/swig/Android/ndk_install_64bit/bin/aarch64-linux-android-strip --strip-unneeded jniLibs/arm64-v8a/libsnowboy-detect-android.so

Aha, strange thing! If you have ever compiled before and get errors like this, just make clean and try to build again.

Hope this helps a bit!