cómo incluir una biblioteca nativa que use encabezados posix en android ndk

I have to include a static native library (dsplink.a) which uses System V IPCs in android ndk project.

Including my library in android.mk as,

    LOCAL_LDLIBS := ($MY-PATH)/dsplink.a

da el siguiente error:

    _sync_usr.c:(.text+0x24b4): undefined reference to `semget'
    _sync_usr.c:(.text+0x24d4): undefined reference to `__errno_location'
    _sync_usr.c:(.text+0x24f4): undefined reference to `semget'
    _sync_usr.c:(.text+0x2538): undefined reference to `semctl'

semctl,semget,.. functions are included from sys/sem.h. Is there any way to include the library ?

preguntado el 04 de julio de 12 a las 10:07

1 Respuestas

Sadly it isn't possible.

Extraction from android-ndk-r8/docs/system/libc/SYSV-IPC.html

Android does not support System V IPCs, i.e. the facilities provided by the following standard Posix headers:

<sys/sem.h>   /* SysV semaphores */
<sys/shm.h>   /* SysV shared memory segments */
<sys/msg.h>   /* SysV message queues */
<sys/ipc.h>   /* General IPC definitions */

The reason for this is due to the fact that, by design, they lead to global kernel resource leakage.

Respondido 06 Jul 12, 09:07

Thanks for the reply.I can create a executable 'hello' using the same library and run it in the terminal as ./hello.It works perfect.Is there a way to create a apk file and run in the same way. - 123

How do you create the executable (NDK?) And in which terminal do you run it? (adb shell?) - sweisgerber.dev

I have created the executable using my board compatible toolchain.. And I run the executable in the serial port terminal connected to host ubuntu PC(in minicom).. - 123

Okay, that's possible, but you can't use the library with Android NDK's bionic libc... - sweisgerber.dev

I have replaced the libc.so in the android NDK with the libc.so in my rootfs.But it results in the same error.. - 123

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.