未定义的引用property_get [英] undefined reference to property_get

查看:2152
本文介绍了未定义的引用property_get的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目标做微调,以找到合适的线程优先级。

My aims to do fine tuning to find proper thread priority.

线程我关注的是位于下/硬件/ my_company / codeC / openmax_il /

The thread I concern is located in under /hardware/my_company/codec/openmax_il/

我修改两个文件


  1. Android.mk

  1. Android.mk

在LOCAL_C_INCLUDES列表中添加$(TOP)/系统/核心/包括,如下图

Add "$(TOP)/system/core/include" in the list of LOCAL_C_INCLUDES as below

LOCAL_C_INCLUDES:= \

    blur blur blur
    $(TOP)/hardware/my_company/camera/v4l2_camerahal \
    $(TOP)/system/core/include


  • 在我的源文件。

  • In my source file.

    #include <cutils/properties.h>
    
    int componentInit(blur blur blur)
    {
       int ret = 0;
    
       blur blur blur
    
       // To find proper thread priority
       char value[92];
       property_get("omx.video_enc.priority", value, "0");
       setVideoEncoderPriority(atoi(value));
    
       return ret;
    }
    


  • 不过,我遇到的链接错误

    But, I encountered the linking error of

     error: undefined reference to 'property_get'
     collect2: ld returned 1 exit status
    

    如果有人可以帮助这一点,那将是对我好。 :)

    If anyone helps this, it would be good to me. :)

    感谢

    推荐答案

    这听起来像你想使用 __ system_property_get(),这是定义在&LT; SYS / system_properties.h&GT; 。从标题:

    It sounds like you want to use __system_property_get(), which is defined in <sys/system_properties.h>. From that header:

    /* Look up a system property by name, copying its value and a
    ** \0 terminator to the provided pointer.  The total bytes
    ** copied will be no greater than PROP_VALUE_MAX.  Returns
    ** the string length of the value.  A property that is not
    ** defined is identical to a property with a length 0 value.
    */
    int __system_property_get(const char *name, char *value);
    

    这签名是不是正是你要寻找的使用,因为你有没有定义属性时的默认值是什么。由于 __ system_property_get()中的财产没有被定义的事件返回0,你可以很容易地补充自己动手。

    This signature is not exactly what you're looking to use, since you have a default value in the event the property isn't defined. Since __system_property_get() returns 0 in the event of the property not being defined, you can easily supplement this yourself.

    下面是如何我已经解决了这个问题在我自己的本土code,它很适合我(虽然缺少缓冲区溢出检查,这将是一个更好的解决方案的话):

    Here is how I've solved the issue in my own native code, and it works well for me (though it is lacking buffer overflow checking, which would be a better solution):

    #include <sys/system_properties.h>
    int android_property_get(const char *key, char *value, const char *default_value)
    {
        int iReturn = __system_property_get(key, value);
        if (!iReturn) strcpy(value, default_value);
        return iReturn;
    }
    

    这篇关于未定义的引用property_get的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆