简体   繁体   English

在android ndk中定义sem_t

[英]Defining sem_t in android ndk

I am porting some code from my libs in C++. 我正在从C ++库中移植一些代码。

Note that android include library has the semaphore.h. 请注意,Android include库具有semaphore.h。

I include the files but when compiling it gives me an error: 'sem_t' does not name a type. 我包含了文件,但是在编译时却出现错误:'sem_t'未命名类型。

For example in linux would define my semaphore like: 例如在linux中,我的信号灯将定义为:

    sem_t id;

Then would call: 然后会调用:

    sem_init(&id, 0, initialCount);

In my Application.mk I am using: 在我的Application.mk中,我正在使用:

    APP_STL := gnustl_static

Thanks in advance. 提前致谢。

Try to compile with -lz -lm -llog -lc -L$(call host-path, $(LOCAL_PATH))/$(TARGET_ARCH_ABI) 尝试使用-lz -lm -llog -lc -L$(call host-path, $(LOCAL_PATH))/$(TARGET_ARCH_ABI)进行编译

or just add the following line to Your android.mk : 或仅android.mk下行添加到Your android.mk

LOCAL_LDLIBS += -lz -lm -llog -lc -L$(call host-path, $(LOCAL_PATH))/$(TARGET_ARCH_ABI) 

It works for me 这个对我有用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM