[질문] 리눅스에서 쓰레드... 뭐가 문제일까요?
글쓴이: 오로리 / 작성시간: 수, 2004/06/16 - 3:19오후
아래 코드를 g++ -o 로 컴파일 했습니다.
실행했더니 세그먼테이션 오류가 나오네요.
뭐가 문제 일까요?
gdb 로 돌려봤더니 pthread_create(&pt, NULL, ThreadFIFO, NULL);
부분에서 바로 죽네요. ㅡㅡ;
#include <pthread.h> #include <sys/poll.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <string> #include <iostream> using namespace std; void* ThreadFIFO(void* arg) { int i = 0; while (true) { printf(" thread : %d\n", i++ ); sleep(1); } } int main(int argc, char *argv[]) { int i=0; pthread_t pt; pthread_create(&pt, NULL, ThreadFIFO, NULL); while(1) { printf("Main: %d\n", i++ ); sleep(0); } return 0; }
Forums:
-lpthread ?
-lpthread ?
I thought what I'd do was,
I'd pretend I was one of those deaf-mutes.. or should I?
실행중에 오류가 나는것이니 -lpthread 는 상관없구요전 그
실행중에 오류가 나는것이니 -lpthread 는 상관없구요
전 그 소스로 하니까 아무 이상 없이 잘 수행됩니다
냠.
전 -lpthread 하니 pthread 라이브러리가 붙는 군요.
그리고 나서야 제대로 실행이 됩니다.
-------------------------------
== warning 대부분 틀린 얘기입니다 warning ===
댓글 달기