gpt4 book ai didi

android - 项目使用 ndk-build 而不是 Android studio 构建

转载 作者:太空宇宙 更新时间:2023-11-03 23:24:23 24 4
gpt4 key购买 nike

当我从命令行使用 ndk-build 命令构建我的 C/C++ 库时,它可以正常工作。

[armeabi] Prebuilt       : libVidyoClientApp.so <= jni/lib/
[armeabi] Install : libVidyoClientApp.so => libs/armeabi/libVidyoClientApp.so
[armeabi] Compile thumb : vidyoguestapi <= NCR.JNI.VidyoExports.c
[armeabi] Compile++ thumb: vidyoguestapi <= Ncr.Jni.Wrapper.cpp
In file included from m:/src/projects/java/VideoPlatform/app/src/main/jni/Ncr.Jni.Wrapper.cpp:6:0:
m:/src/projects/java/VideoPlatform/app/src/main/jni/include/Ncr.Jni.Wrapper.h:13:1: warning: 'typedef' was ignored in th
is declaration [enabled by default]
};
^
[armeabi] Compile++ thumb: vidyoguestapi <= NCR.Vidyo.SDK.cpp
In file included from m:/src/projects/java/VideoPlatform/app/src/main/jni/NCR.Vidyo.SDK.cpp:7:0:
m:/src/projects/java/VideoPlatform/app/src/main/jni/include/NCR.Jni.Wrapper.h:13:1: warning: 'typedef' was ignored in th
is declaration [enabled by default]
};
^
[armeabi] StaticLibrary : libstdc++.a
[armeabi] SharedLibrary : libvidyoguestapi.so
[armeabi] Install : libvidyoguestapi.so => libs/armeabi/libvidyoguestapi.so

但是当我尝试在 Android studio 中构建我的项目时,出现编译错误:

M:\src\projects\java\VideoPlatform\app\build\intermediates\ndk\debug\obj/local/arm64-v8a/objs/vidyoguestapi/M_\src\projects\java\VideoPlatform\app\src\main\jni\NCR.JNI.VidyoExports.o: In function `Java_com_ncr_mobilevideo_videosdk_VidyoGuestClient_sdkLoginGuest':
M:\src\projects\java\VideoPlatform\app\src\main\jni\NCR.JNI.VidyoExports.c
Error:(50) undefined reference to `VidyoClientInitialize'
collect2.exe: error: ld returned 1 exit status
make.exe: *** [M:\src\projects\java\VideoPlatform\app\build\intermediates\ndk\debug\obj/local/arm64-v8a/libvidyoguestapi.so] Error 1

命令行 ndk-build 和 Android Studio 有什么不同?

仅供引用:我删除了引用 VidyoClientInitialize 的行,一切都在命令行和 Android Studio 中构建。所以看起来像是某种环境,但我不确定要看什么

最佳答案

现在,Android Studio 会即时创建一个新的 Android.mk 来编译您的 C/C++ 源代码,忽略您对其他预构建库的所有依赖,因为他无法处理它们。

来自 AS/gradle 的更好的 NDK 支持应该很快就会出来,但与此同时你可以停用它并让它从 libs/(armeabi,armeabi-v7a,x86,. ..) 通过在 build.gradle 中设置:

android {
sourceSets.main {
jniLibs.srcDir 'src/main/libs' //set libs as .so's location instead of jniLibs
jni.srcDirs = [] //disable automatic ndk-build call with auto-generated Android.mk
}
}

关于android - 项目使用 ndk-build 而不是 Android studio 构建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30675767/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com