我是否需要具有本机函数的单独库才能加载具有 main 函数的库?
Do I need seperate library with native function in order to load library with main function?
就像在主题中一样,我需要单独的具有本机功能的库才能加载具有主要功能的库吗?还是建议这样做?
此刻我得到了使用 main.so 编译的那些原生函数,但我不确定是否应该这样做。
native 在 main 之前加载 lib
protected String[] getLibraries() {
return new String[] {
"SDL2",
"hidapi",
"native",
"main"
};
}
我在里面得到了一堆原生函数,其中之一就是那个例子
JNIEXPORT int JNICALL Java_org_libsdl_app_SDLActivity_nativeRunMain(jstring library, jstring function, jobject array)
{
return Java_org_libsdl_app_SDLActivity_nativeRunMain("libmain.so", "SDL_main", NULL);
}
到目前为止,应用程序正在 运行 加载库,没有其他尝试查看 log_android 是否来自主函数,但它没有。
好的,我的问题的解决方案有点奇怪。我不得不使用 SDL2 提供的 build-scripts 之一从头开始生成整个包。然后我从旧文件中复制了一些文件,现在它可以访问 int main() 函数了。
这是来自 Logcat 的日志。
05-11 12:42:28.829 10315 10315 V SDL : Device: santoni
05-11 12:42:28.829 10315 10315 V SDL : Model: Redmi 4X
05-11 12:42:28.829 10315 10315 V SDL : onCreate()
05-11 12:42:28.890 10315 10315 V SDL : nativeSetupJNI()
05-11 12:42:28.890 10315 10315 V SDL : AUDIO nativeSetupJNI()
05-11 12:42:28.890 10315 10315 V SDL : CONTROLLER nativeSetupJNI()
05-11 12:42:28.900 10315 10315 D hidapi : Initializing Bluetooth
05-11 12:42:28.929 10315 10315 D AccessibilityManager: current package=org.libsdl.app, accessibility manager mIsFinalEnabled=false, mOptimizeEnabled=false, mIsUiAutomationEnabled=false, mIsInterestedPackage=false
05-11 12:42:28.952 10315 10315 V SDL : onResume()
05-11 12:42:28.986 10315 10336 I Adreno : QUALCOMM build : dd15ef5, Ic280a69317
05-11 12:42:28.986 10315 10336 I Adreno : Build Date : 05/09/17
05-11 12:42:28.986 10315 10336 I Adreno : OpenGL ES Shader Compiler Version: XE031.09.00.04
05-11 12:42:28.986 10315 10336 I Adreno : Local Branch :
05-11 12:42:28.986 10315 10336 I Adreno : Remote Branch : quic/gfx-adreno.lnx.1.0.r5-rel
05-11 12:42:28.986 10315 10336 I Adreno : Remote Branch : NONE
05-11 12:42:28.986 10315 10336 I Adreno : Reconstruct Branch : NOTHING
05-11 12:42:28.994 10315 10336 I OpenGLRenderer: Initialized EGL, version 1.4
05-11 12:42:28.994 10315 10336 D OpenGLRenderer: Swap behavior 1
05-11 12:42:28.995 10315 10315 V SDL : surfaceCreated()
05-11 12:42:28.995 10315 10315 V SDL : surfaceChanged()
05-11 12:42:28.995 10315 10315 V SDL : pixel format RGB_565
05-11 12:42:28.996 10315 10315 V SDL : Window size: 720x1230
05-11 12:42:28.996 10315 10315 V SDL : Device size: 720x1280
05-11 12:42:29.001 10315 10315 V SDL : nativeResume()
05-11 12:42:29.002 10315 10338 V SDL : Running main function SDL_main from library /data/app/org.libsdl.app-1/lib/arm64/libmain.so
05-11 12:42:29.002 10315 10338 V SDL : nativeRunMain()
还有下一期等着我。
就像在主题中一样,我需要单独的具有本机功能的库才能加载具有主要功能的库吗?还是建议这样做?
此刻我得到了使用 main.so 编译的那些原生函数,但我不确定是否应该这样做。
native 在 main 之前加载 lib
protected String[] getLibraries() {
return new String[] {
"SDL2",
"hidapi",
"native",
"main"
};
}
我在里面得到了一堆原生函数,其中之一就是那个例子
JNIEXPORT int JNICALL Java_org_libsdl_app_SDLActivity_nativeRunMain(jstring library, jstring function, jobject array)
{
return Java_org_libsdl_app_SDLActivity_nativeRunMain("libmain.so", "SDL_main", NULL);
}
到目前为止,应用程序正在 运行 加载库,没有其他尝试查看 log_android 是否来自主函数,但它没有。
好的,我的问题的解决方案有点奇怪。我不得不使用 SDL2 提供的 build-scripts 之一从头开始生成整个包。然后我从旧文件中复制了一些文件,现在它可以访问 int main() 函数了。
这是来自 Logcat 的日志。
05-11 12:42:28.829 10315 10315 V SDL : Device: santoni
05-11 12:42:28.829 10315 10315 V SDL : Model: Redmi 4X
05-11 12:42:28.829 10315 10315 V SDL : onCreate()
05-11 12:42:28.890 10315 10315 V SDL : nativeSetupJNI()
05-11 12:42:28.890 10315 10315 V SDL : AUDIO nativeSetupJNI()
05-11 12:42:28.890 10315 10315 V SDL : CONTROLLER nativeSetupJNI()
05-11 12:42:28.900 10315 10315 D hidapi : Initializing Bluetooth
05-11 12:42:28.929 10315 10315 D AccessibilityManager: current package=org.libsdl.app, accessibility manager mIsFinalEnabled=false, mOptimizeEnabled=false, mIsUiAutomationEnabled=false, mIsInterestedPackage=false
05-11 12:42:28.952 10315 10315 V SDL : onResume()
05-11 12:42:28.986 10315 10336 I Adreno : QUALCOMM build : dd15ef5, Ic280a69317
05-11 12:42:28.986 10315 10336 I Adreno : Build Date : 05/09/17
05-11 12:42:28.986 10315 10336 I Adreno : OpenGL ES Shader Compiler Version: XE031.09.00.04
05-11 12:42:28.986 10315 10336 I Adreno : Local Branch :
05-11 12:42:28.986 10315 10336 I Adreno : Remote Branch : quic/gfx-adreno.lnx.1.0.r5-rel
05-11 12:42:28.986 10315 10336 I Adreno : Remote Branch : NONE
05-11 12:42:28.986 10315 10336 I Adreno : Reconstruct Branch : NOTHING
05-11 12:42:28.994 10315 10336 I OpenGLRenderer: Initialized EGL, version 1.4
05-11 12:42:28.994 10315 10336 D OpenGLRenderer: Swap behavior 1
05-11 12:42:28.995 10315 10315 V SDL : surfaceCreated()
05-11 12:42:28.995 10315 10315 V SDL : surfaceChanged()
05-11 12:42:28.995 10315 10315 V SDL : pixel format RGB_565
05-11 12:42:28.996 10315 10315 V SDL : Window size: 720x1230
05-11 12:42:28.996 10315 10315 V SDL : Device size: 720x1280
05-11 12:42:29.001 10315 10315 V SDL : nativeResume()
05-11 12:42:29.002 10315 10338 V SDL : Running main function SDL_main from library /data/app/org.libsdl.app-1/lib/arm64/libmain.so
05-11 12:42:29.002 10315 10338 V SDL : nativeRunMain()
还有下一期等着我。