도와주세요 - pthread 컴파일 에러

jaeung24k의 이미지

분명 pthread.h를 include 했음에도 불구하고 아래와 같은 에러가 발생합니다..

O_CLOEXEC 플래그의 경우 해당플래그의 값인 0으로 선언해 주면 에러가 없어집니다만, pthread.h 헤더를 추가했는데도 불구하고 pthread_setname_np 함수를 인지하지 못하는 것은 이해가 안됩니다..

짐작가는 부분으로는 시스템의 pthread.h 버전이 낮아서가 아닐까 생각도 듭니다만...

선배님들의 조언 부탁드립니다.....

Compiling posix_ostools:
../common/os_shim/src/posix_ostools.c: In function 'posix_create_message_queue':
../common/os_shim/src/posix_ostools.c:245: error: 'O_CLOEXEC' undeclared (first use in this function)
../common/os_shim/src/posix_ostools.c:245: error: (Each undeclared identifier is reported only once
		../common/os_shim/src/posix_ostools.c:245: error: for each function it appears in.)
cc1: warnings being treated as errors
../common/os_shim/src/posix_ostools.c: In function 'posix_create_thread':
../common/os_shim/src/posix_ostools.c:389: warning: implicit declaration of function 'pthread_setname_np'
../common/os_shim/src/posix_ostools.c: In function 'posix_sem_open':
../common/os_shim/src/posix_ostools.c:473: error: 'O_CLOEXEC' undeclared (first use in this function)
make[1]: *** [../posix_ostools.o] 오류 1
make: *** [common/os_shim] 오류 2
tyhan의 이미지

jaeung24k의 이미지

감사합니다. 조언해주신대로 아래 코드를 삽입하면 O_CLOEXEC 관련 에러는 발생하지 않습니다.

#ifndef O_CLOEXEC
#define O_CLOEXEC 0
#endif

그런데 pthread.h에 정의되어 있는 함수인 pthread_setname_np()는 여전히 implicit declaration 에러가 발생하네요...

오늘도 생명과 호흡을 주심에 감사합니다.

hys545의 이미지

#define _GNU_SOURCE
#inlcude

이런 식으로

pthread_setname_np
man 페이비 보면
#define _GNU_SOURCE /* See feature_test_macros(7) */
#include
int pthread_setname_np(pthread_t *thread, const char *name);
int pthread_getname_np(pthread_t *thread,
const char *name, size_t len);
Compile and link with -pthread.
식으로 사용하라고 하네여

즐린

익명 사용자의 이미지

답변감사합니다..

코드가 원래 다른 컴퓨터에서는 컴파일이 잘 되고 있는데 제 컴퓨터에서만 유독 pthread 관련 에러를 내고있습니다...

시스템의 라이브러리를 가져다가 사용하는 것 같은데 좀더 찾아봐야겠네요... ㅠㅠ

오늘 해결 못하면 이제 3주째로 넘어가겠군요......

jaeung24k의 이미지

2주가 지났지만... 문제를 해결하여 코멘트를 적습니다.

문제는 코드상의 문제가 아닌 툴체인 상의 문제였습니다.

호스트의 라이브러리를 참조하여 발생하는 문제인줄 알고 호스트에 여러 라이브러리를 재설치해보았지만 해결되지 않았구요,

툴체인을 안정적인 버전으로 받아서 컴파일하니 저절로 해결되었습니다.

답변주신분들 감사합니다.

오늘도 생명과 호흡을 주심에 감사합니다.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.