Hello dev:
I Create a SPM project and it have a C language library Target
that like CNIOLinux
of SwiftNIO
.
And it will build a SO file that named libnative-activity.so
// android_native_app_glue.c
// ------------------------------------
__attribute__((visibility("default")))
JNIEXPORT
void ANativeActivity_onCreate(ANativeActivity* activity, void* savedState,
size_t savedStateSize) {
LOGV("Creating: %p\n", activity);
activity->callbacks->onDestroy = onDestroy;
activity->callbacks->onStart = onStart;
activity->callbacks->onResume = onResume;
activity->callbacks->onSaveInstanceState = onSaveInstanceState;
activity->callbacks->onPause = onPause;
activity->callbacks->onStop = onStop;
activity->callbacks->onConfigurationChanged = onConfigurationChanged;
activity->callbacks->onLowMemory = onLowMemory;
activity->callbacks->onWindowFocusChanged = onWindowFocusChanged;
activity->callbacks->onNativeWindowCreated = onNativeWindowCreated;
activity->callbacks->onNativeWindowDestroyed = onNativeWindowDestroyed;
activity->callbacks->onInputQueueCreated = onInputQueueCreated;
activity->callbacks->onInputQueueDestroyed = onInputQueueDestroyed;
activity->instance = android_app_create(activity, savedState, savedStateSize);
}
Which option should pass to swift build
for keeping a symbol of C function that named ANativeActivity_onCreate
?
or
Which option should pass to swift build
to avoid stripping a symbol of C function that named ANativeActivity_onCreate
?
Because i need to load this C function inside this SO file at running-time by dlopen
PS:
Already attempt "swift build -Xlinker -u -Xlinker ANativeActivity_onCreate", but not work.
-u symbol
Pretend the symbol symbol is undefined, to force linking of library modules to define it. You
can use -u multiple times with different symbols to force loading of additional library modules.
Could you give me some suggestion? Thanks.