2012-07-06 8 views
2

저의 목표는 적절한 스레드 우선 순위를 찾기 위해 미세 조정입니다.property_get에 대한 정의되지 않은 참조

스레드 I 우려가 아래에 위치/하드웨어/my_company/코덱/openmax_il 내가 수정/

2 개 파일

  1. Android.mk

    추가 "$ (TOP)/시스템/코어/아래

    LOCAL_C_INCLUDES:= \ 
    
        blur blur blur 
        $(TOP)/hardware/my_company/camera/v4l2_camerahal \ 
        $(TOP)/system/core/include 
    
  2. 로 LOCAL_C_INCLUDES 목록에서 "포함 내 소스 파일에서.

    #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; 
    } 
    

는하지만, 나는 사람이 도움이된다면, 그것은 나에게 좋은 것

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

의 연결 오류가 발생했습니다. :)

감사

답변

7

당신이 <sys/system_properties.h>에 정의되어 __system_property_get()를 사용할 것 소리. 해당 머리글에서 :

/* 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을 반환하므로 쉽게이 속성을 보완 할 수 있습니다. 여기

내가 내 자신의 네이티브 코드에서 문제를 해결 한 방법이며, (그것은 더 나은 솔루션이 될 것입니다 버퍼 오버 플로우 검사를, 부족하지만) 나를 위해 잘 작동합니다 :

#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; 
} 
6

당신

LOCAL_STATIC_LIBRARIES := libcutils libc 
: 당신의 android.mk에 libcutils에 소스 파일

#include <cutils/properties.h> 

를 링크에 추가해야

관련 문제