2012-06-15 2 views
4

안드로이드는 pthread를 지원합니까? 그리고 내가 -pthread 옵션을 사용할 때 내가 링커 오류 참조 이유 :Android가 스레드를 지원합니까?

는 i686 - 안드로이드 - 리눅스/빈/LD를 : 지금까지 내가 워드 프로세서에서 볼 수있는 바와 같이 -lpthread

#include <pthread.h> 
#include <cxxabi.h> 
extern "C" int printf (const char *, ...); 
int main() 
{ 
    try 
    { 
     pthread_exit (0); 
    } 
    catch (abi::__forced_unwind &) 
    { 
     printf ("caught forced unwind\n"); 
     throw; 
    } 
    catch (...) 
    { 
     printf ("caught ...\n"); 
     return 1; 
    } 
} 
+0

-lpthread를 사용해야합니까? "pthread.h를 포함하는 것만으로 충분하지 않아야합니까? –

답변

7

을 찾을 수 없습니다 당신 "-pthread"를 사용할 필요가 없습니다. 체크 아웃 다음 NDK offical 한 문서에서
http://mobilepearls.com/labs/native-android-api/#pthreads

정보의 상태가 (안드로이드 NDK-R8 \의 문서 \ SYSTEM \ libc의 \ OVERVIEW.html) :

PThread implementation:
Bionic's C library comes with its own pthread implementation bundled in. This is different from other historical C libraries which: - place it in an external library (-lpthread) - play linker tricks with weak symbols at dynamic link time

그래서 슈퍼맨이 포함 명심 (-lpthread를 사용하여) 익숙한 표준 방식과 반대되는 방식으로 직접 pthread합니다.

+0

이 링크를 신뢰할 수 있습니까? developer.android.com 또는 해당 Google 그룹이 아니기 때문에 ... – Arseniy

+0

다음을 확인하십시오. https://groups.google. 일반적으로 생체 공학은 많은 pthread 기능을 포함하지만 모든 기능을 포함하지는 않습니다 (예 : pthread_barrier_wait()가 누락되었습니다). – gfour

관련 문제