我正在进行交叉编译。我正在尝试ndk构建我的代码,并且当我包含 Python.h 时,它会导致错误 LONG_BIT定义对于平台(坏gcc / glibc config?)显示错误 p>
我在互联网上发现了一些类似的案例,但问题仍然无法解决。这是virtualenv的问题吗?它安装了一些关于gcc的东西。那么,有人会建议一种方法来解决这个问题吗?
我使用的是64位python 2.7。 Python.h来自Kivy的python-for-android项目。
错误:
kivy@kivy-VirtualBox:~/AndroidStudioProjects/Pytest/python-for-android/dist/default/libs/armeabi$ /home/kivy/Android/Sdk/ndk-bundle/ndk-build NDK_PROJECT_PATH=/home/kivy/AndroidStudioProjects/Pytest APP_BUILD_SCRIPT=/home/kivy/AndroidStudioProjects/Pytest/app/src/main/jni/android.mk
[arm64-v8a] Compile : pyjni <= pyjni.c
In file included from /home/kivy/AndroidStudioProjects/Pytest/app/src/main/jni/../..
/../../python-for-android/dist/default/python-install/include/python2.7/Python.h:58:0,
from /home/kivy/AndroidStudioProjects/Pytest/app/src/main/jni/pyjni.c:1:
/home/kivy/AndroidStudioProjects/Pytest/app/src/main/jni/../../.
./../python-for-android/dist/default/python-install/include/python2.7/pyport.h:849:2:
error:
#error "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?).
"
#error "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?)."
^
make: *** [/home/kivy/AndroidStudioProjects/Pytest/obj/local/arm64-v8a/objs/pyjni/pyjni.o] Error 1
android.mk
LOCAL_PATH := $(call my-dir)
#square
include $(CLEAR_VARS)
LOCAL_MODULE := square
LOCAL_SRC_FILES := square.c
include $(BUILD_SHARED_LIBRARY)
# Build libpyjni.so
include $(CLEAR_VARS)
LOCAL_MODULE := pyjni
LOCAL_SRC_FILES := pyjni.c
LOCAL_CFLAGS := -I $(LOCAL_PATH)/../../../../python-for-android/dist/default/python-install/include/python2.7/
LOCAL_LDFLAGS += -L $(LOCAL_PATH)/../../../../python-for-android/dist/default/libs/armeabi/
LOCAL_SHARED_LIBRARIES += python2.7 # This line links to libpython2.7
LOCAL_LDLIBS += -llog # This line links to the Android log
include $(BUILD_SHARED_LIBRARY)
# Include libpython2.7.so
include $(CLEAR_VARS)
LOCAL_MODULE := python2.7
LOCAL_SRC_FILES := ../../../../python-for-android/dist/default/libs/armeabi/libpython2.7.so
include $(PREBUILT_SHARED_LIBRARY)