우분투 이클립스 상에서 c++11 thread 사용 시 에러에 관련한 질문입니다.
글쓴이: balgarac1 / 작성시간: 월, 2015/11/23 - 2:00오후
thread 를 사용하려 해서 사진에 나와있는 것 처럼 설정해줬는데
되지 않네요... 구글링해서 하라는대로 했는데 안되서 왜 안되는지 모르겠습니다.
추가적으로 해줘야 할 건 뭐가 있나요??
#include <iostream>
#include <thread>
using namespace std;
void call_from_thread(int i);
int main(int argc, char * argv[])
{
thread t[10];
for(auto i = 0; i < 10; i++)
t[i] = thread(call_from_thread, i);
cout << "main function()" << endl;
}
void call_from_thread(int i)
{
cout << "thread" << endl;
}auto 키워드는 에러가 뜨지 않습니다만 스레드에서만 빨간줄이 지워지지 않아요..
Forums:


pthread 로 입력되어 있습니다.
-------------------------------------------------
ubuntu thread 로 찾아보면. -lpthread 나 -pthread 를 추가해주라고 합니다.
그런데. 여기 화면에는 pthread 만 입력되어 있습니다.
Linux Multi Thread 예제 (ubuntu 12.04, Eclipse)
http://zeal74.tistory.com/1200
Linux(Ubuntu)에서 std::thread(std::async 등등) 사용하기
http://yonomi.tistory.com/352
ubuntu linux thread ex
http://radionalog.tistory.com/16
-------------------------------------------------
DevC++ 에서는 이정도만 해놓아도 되네요.
-std=c++11
-static-libgcc
대신. join() 을 해줘야 한다고 합니다.
http://arer.tistory.com/45
순서대로 출력하려면. puts() 를 사용합니다.
#include <iostream> #include <thread> using namespace std; void call_from_thread(int i) { // cout < < "thread : " < < i < < endl; char buf[10]; sprintf(buf, "%d", i); puts(buf); } int main(int argc, char** argv) { thread t[10]; for(auto i = 0; i < 10; i++) { t[i] = thread(call_from_thread, i); t[i].join(); } cout < < "main function()" < < endl; return 0; } #if 0 terminate called without an active exception This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. #endif----------------------------------------------------------------------------
젊음'은 모든것을 가능하게 만든다.
매일 1억명이 사용하는 프로그램을 함께 만들어보고 싶습니다.
정규 근로 시간을 지키는. 야근 없는 회사와 거래합니다.
각 분야별. 좋은 책'이나 사이트' 블로그' 링크 소개 받습니다. shintx@naver.com
음.. 2번 첨부화면에..
2번 첨부화면 보시면 -pthread라고 되어 있습니당... ㅜ
네
사용하신건 -pthread 인데요.
다른 블로그 화면에는 pthread 로 되어 있습니다.
그리고. thread와 pthread 는 별도에 함수가 있나봅니다.
여기를 참고해보세요.
http://www.devpia.com/Maeul/Contents/Detail.aspx?BoardID=50&MAEULNo=20&no=960988&ref=960988
----------------------------------------------------------------------------
젊음'은 모든것을 가능하게 만든다.
매일 1억명이 사용하는 프로그램을 함께 만들어보고 싶습니다.
정규 근로 시간을 지키는. 야근 없는 회사와 거래합니다.
각 분야별. 좋은 책'이나 사이트' 블로그' 링크 소개 받습니다. shintx@naver.com
댓글 달기