Issue
I've been using a c++ library on my android app for some time now but it has been using 32-bit. I'm trying to compile now the c++ library to a 64bit .so
file but every time I do ndk-build
I do see the armeabi-v7a
get generated successfully, but when the arm64-v8a
tries to compile, it fails and gives me the following error message:
libfftw3.a: error adding symbols: File in wrong format
collect2: error: ld returned 1 exit status
I'm going to place below my Application.mk
and Android.mk
respectively to show what I've done to try to do this properly.
Application.mk
APP_STL := gnustl_static
NDK_TOOLCHAIN_VERSION=4.9
APP_CPPFLAGS += -frtti
APP_PLATFORM := android-23
APP_CPPFLAGS += -std=c++11
APP_ABI := armeabi-v7a arm64-v8a
APP_MODULES := SCCpp
Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
CXXFLAGS += -arch x86_64 -arch i386
LOCAL_MODULE := fftw3
LOCAL_SRC_FILES := ../lib/libfftw3.a
LOCAL_EXPORT_C_INCLUDES = $(LOCAL_PATH)/..
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
GLOBAL_C_INCLUDES := \
$(LOCAL_PATH)/../src
LOCAL_SRC_FILES += ../src/d/re.cpp
LOCAL_SRC_FILES += ../src/d/me.cpp
LOCAL_SRC_FILES += ../src/d/ev.cpp
LOCAL_SRC_FILES += ../src/d/fe.cpp
LOCAL_SRC_FILES += ../src/fft/fourier.cpp
LOCAL_SRC_FILES += ../src/nu/ac.cpp
LOCAL_SRC_FILES += ../src/nu/st.cpp
LOCAL_SRC_FILES += ../src/utils/converter.cpp
LOCAL_SRC_FILES += ../src/sci.cpp
LOCAL_MODULE := SCCpp
LOCAL_MODULE_FILENAME := libSCCpp
LOCAL_STATIC_LIBRARIES := fftw3
LOCAL_CPP_FEATURES += exceptions
LOCAL_CFLAGS += -fopenmp
LOCAL_CFLAGS += -Ofast
LOCAL_LDFLAGS += -fopenmp -t
LOCAL_CPPFLAGS := -std=c++11
LOCAL_LDLIBS += -latomic -llog
LOCAL_C_INCLUDES := $(GLOBAL_C_INCLUDES) $(LOCAL_PATH)/../../../3rdParty/fftw-3.3.4-dll32/
LOCAL_EXPORT_CPPFLAGS := -fexceptions -frtti
include $(BUILD_SHARED_LIBRARY)
I'm really unfamiliar with this whole process so I'm at a dead end especially since the logs don't really tell me anything at all. I thought that by just adding in the arm64-v8a
would automatically generate the 64bit shared object. Is there a missing step?
If there's any missing information that I should provide, please ask in the comments so I can give more details, but as of now in my current position, this is all that I have touched in the code base for the c++ library so I'm not quite sure where all the pieces are at the moment.
Solution
You use a prebuilt library at
../lib/libfftw3.a
You must build fftw3 for arm64, too. Usually we have
LOCAL_SRC_FILES := ../lib/$(TARGET_ARCH_ABI)/libfftw3.a
so that ndk-build can choose the right variant of the 3rd party lib.
The instructions to build fftw3 for arm64 are available on GitHub.
Answered By - Alex Cohn
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.