问题
A certain C-code in my Android NDK application, calls the sigemptyset()
function defined in the signal.h. I am building my project using the NDK-r9
.
My library file called "libnative-service.so" is built fine, after the c-code is compiled.
But on running the application i get the following error regarding the refernce to sigemptyset()
.
Am i missing something ??
09-22 15:13:09.102: E/art(3718): dlopen("/data/app-lib/com.project/libnative-service.so", RTLD_LAZY) failed: dlopen failed: cannot locate symbol "sigemptyset" referenced by "libnative-service.so"...
09-22 15:13:09.103: D/AndroidRuntime(3718): Shutting down VM
09-22 15:13:09.106: E/AndroidRuntime(3718): FATAL EXCEPTION: main
09-22 15:13:09.106: E/AndroidRuntime(3718): Process: com.project, PID: 3718
09-22 15:13:09.106: E/AndroidRuntime(3718): java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "sigemptyset" referenced by "libnative-service.so"...
回答1:
This function appears to be declared inline:
static __inline__ int sigemptyset(sigset_t *set)
{
memset(set, 0, sizeof *set);
return 0;
}
So it should already be resolved in the compiled library, and not a dependency to be filled by runtime linking. If it is unresolved, it would seem that your library has not built correctly.
Did you perhaps link against the wrong headers? If you used a non-ndk signal.h you might not be compiling usage of this function correctly.
来源:https://stackoverflow.com/questions/25975291/sigemptyset-ndk-unsatisfiedlinkerror-dlopen