linux Android NDK > 18无法在Fedora 36中构建模块(与elf 32不兼容-i386错误)

jm2pwxwz  于 2023-08-03  发布在  Linux
关注(0)|答案(1)|浏览(178)

问题

我正在使用Fedora 36(Linux内核5.19.12-200.fc36.x86_64)为移动的应用程序框架构建一个Android模块。当我使用NDK 18.1.5063045时,一切正常。
我已经测试了Manjaro 22.0.3,也有同样的问题。OS X工作正常!
当我使用一个更新的版本,例如21.4.7075529,我最终得到以下错误:

[ERROR] [GRADLE]
[ERROR] [GRADLE] FAILURE: Build failed with an exception.
[ERROR] [GRADLE]
[ERROR] [GRADLE] * What went wrong:
[ERROR] [GRADLE] Execution failed for task ':module:buildNdkBuildRelease'.
[ERROR] [GRADLE] > Build command failed.
[ERROR] [GRADLE]   Error while executing process /home/user/tools/android-sdk/ndk/21.4.7075529/ndk-build with arguments {NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=/home/user/dev/ti.module/android/build/module/src/main/jni/Android.mk APP_ABI=armeabi-v7a NDK_ALL_ABIS=armeabi-v7a NDK_DEBUG=0 APP_PLATFORM=android-19 NDK_OUT=/home/user/dev/ti.module/android/build/module/build/intermediates/cxx/Release/18714c4q/obj NDK_LIBS_OUT=/home/user/dev/ti.module/android/build/module/build/intermediates/cxx/Release/18714c4q/lib APP_CPPFLAGS+=-std=c++14 APP_STL:=c++_shared -j20 --output-sync=none ti.module}
[ERROR] [GRADLE]   Android NDK: WARNING:/home/user/dev/ti.module/android/build/module/src/main/jni/Android.mk:ti.module: non-system libraries in linker flags: -lkroll-v8
[ERROR] [GRADLE]   Android NDK:     This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES
[ERROR] [GRADLE]   Android NDK:     or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the
[ERROR] [GRADLE]   Android NDK:     current module
[ERROR] [GRADLE]   [armeabi-v7a] Compile++ thumb: ti.module <= ti.module.CameraViewProxy.cpp
[ERROR] [GRADLE]   [armeabi-v7a] Compile++ thumb: ti.module <= ti.module.TiCameraxModule.cpp
[ERROR] [GRADLE]   [armeabi-v7a] Compile++ thumb: ti.module <= TiModuleBootstrap.cpp
[ERROR] [GRADLE]   [armeabi-v7a] SharedLibrary  : libti.module.so
[ERROR] [GRADLE]
[ERROR] [GRADLE]   ld: error: /home/user/tools/android-sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin/../sysroot/usr/lib/arm-linux-androideabi/19/crtbegin_so.o is incompatible with elf32-i386
[ERROR] [GRADLE]   ld: error: /home/user/dev/ti.module/android/build/module/build/intermediates/cxx/Release/18714c4q/obj/local/armeabi-v7a/objs/ti.module/__/__/__/build/ti-generated/jni/ti.module.CameraViewProxy.o is incompatible with elf32-i386
[ERROR] [GRADLE]   ld: error: /home/user/dev/ti.module/android/build/module/build/intermediates/cxx/Release/18714c4q/obj/local/armeabi-v7a/objs/ti.module/__/__/__/build/ti-generated/jni/ti.module.TiCameraxModule.o is incompatible with elf32-i386
[ERROR] [GRADLE]   ld: error: /home/user/dev/ti.module/android/build/module/build/intermediates/cxx/Release/18714c4q/obj/local/armeabi-v7a/objs/ti.module/__/__/__/build/ti-generated/jni/TiModuleBootstrap.o is incompatible with elf32-i386
[ERROR] [GRADLE]   ld: error: /home/user/dev/ti.module/android/build/module/build/intermediates/cxx/Release/18714c4q/obj/local/armeabi-v7a/libc++_shared.so is incompatible with elf32-i386
[ERROR] [GRADLE]   ld: error: /home/user/tools/android-sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin/../sysroot/usr/lib/arm-linux-androideabi/19/liblog.so is incompatible with elf32-i386
[ERROR] [GRADLE]   ld: error: /home/user/.titanium/mobilesdk/linux/11.1.1.GA/android/native/libs/armeabi-v7a/libkroll-v8.so is incompatible with elf32-i386
[ERROR] [GRADLE]   ld: error: /home/user/tools/android-sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin/../sysroot/usr/lib/arm-linux-androideabi/19/crtend_so.o is incompatible with elf32-i386
[ERROR] [GRADLE]   clang++: error: linker command failed with exit code 1 (use -v to see invocation)
[ERROR] [GRADLE]   make: *** [/home/user/tools/android-sdk/ndk/21.4.7075529/build/core/build-binary.mk:657: /home/user/dev/ti.module/android/build/module/build/intermediates/cxx/Release/18714c4q/obj/local/armeabi-v7a/libti.module.so] Fehler 1
[ERROR] [GRADLE]

字符串
ndk-build命令及其参数为:

/home/user/tools/android-sdk/ndk/21.4.7075529/ndk-build
  NDK_PROJECT_PATH=null
  APP_BUILD_SCRIPT=/home/user/dev/ti.module/android/build/module/src/main/jni/Android.mk
  APP_ABI=armeabi-v7a
  NDK_ALL_ABIS=armeabi-v7a
  NDK_DEBUG=0
  APP_PLATFORM=android-19
  NDK_OUT=/home/user/dev/ti.module/android/build/module/build/intermediates/cxx/Release/18714c4q/obj
  NDK_LIBS_OUT=/home/user/dev/ti.module/android/build/module/build/intermediates/cxx/Release/18714c4q/lib
  APP_CPPFLAGS+=-std=c++14
  APP_STL:=c++_shared
  -j20
  --output-sync=none
  ti.module

Android.mksource in repository

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := ti.module

# Allow non-constant format strings in functions like printf(), sprintf(), etc.
LOCAL_DISABLE_FORMAT_STRING_CHECKS=true

TI_SDK_DIR = /home/user/.titanium/mobilesdk/linux/11.1.1.GA/android
LOCAL_CFLAGS := -g "-I$(TI_SDK_DIR)/native/include"
LOCAL_CFLAGS += -Wno-conversion-null -Wno-format-security -Wno-format -Wno-tautological-compare -Wno-unused-result -Wno-deprecated-register
LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -ldl -llog -L$(TARGET_OUT) "-L$(TI_SDK_DIR)/native/libs/$(TARGET_ARCH_ABI)" -lkroll-v8

ABS_SRC_FILES := \
    $(wildcard $(LOCAL_PATH)/*.cpp) \
    $(wildcard $(LOCAL_PATH)/../../../build/ti-generated/jni/*.cpp)
LOCAL_SRC_FILES := $(patsubst $(LOCAL_PATH)/%,%,$(ABS_SRC_FILES))

include $(BUILD_SHARED_LIBRARY)


Build.gradle file in repo

提问

为了使用NDK > 18,我需要在我的Fedora机器上更改/安装什么吗?这样它就不会因为这个错误而停止:
这很可能导致错误的构建。尝试使用LOCAL_STATIC_LIBRARIES或LOCAL_SHARED_LIBRARIES来列出库依赖项...

当前解决方案

由于它与NDK 18一起工作,我继续使用NDK 18,并将NDK 21文件夹链接到我的NDK 18文件夹。

如何测试

由于它是一个移动的框架的模块,因此您需要安装框架本身:

  • 安装Titanium CLI sudo npm i -g titanium
  • 安装SDK ti sdk install latest
  • 克隆一个模块仓库,如https://github.com/tidev/ti.map
  • 进入ti.map/android文件夹并运行ti build -p android -b

我测试过的

我已经更改了 * Android.mk * 文件以使用

LOCAL_SRC_FILES := $(TI_SDK_DIR)/native/libs/$(TARGET_ARCH_ABI)/libkroll-v8.so
include $(PREBUILT_SHARED_LIBRARY)


它构建模块,但它不构建/包含带有.so文件的jni/arm*jni/x86*文件夹。

o8x7eapl

o8x7eapl1#

我遇到了这个问题,通过更新Android.mk文件解决了这个问题。
因此,更新您的Android.mk文件以使用LOCAL_STATIC_LIBRARIESLOCAL_SHARED_LIBRARIES,而不是直接在链接器标志中列出库。
另外,看看你是否在Fedora机器上安装了必要的依赖项。较新的NDK 18.1可能需要安装其他库或包。

相关问题