2012-08-22 3 views
2

나는 POCO를 사용하기 시작했고 스레드의 문서를 살펴 봤다. 나는 이러한 오류를 얻을POCO 스레드를 사용하는 방법?

#include <iostream> 
#include <Poco/Thread.h> 
#include <Poco/ThreadTarget.h> 
using namespace std; 

void myfunc(){ 
cout << "test"; 
} 
int main(){ 
    Poco::ThreadTarget ra(&myfunc); 
    Poco::Thread thr; 
    thr.start(ra); 
    return 0; 
} 

:

C:\Users\M\workspace\Poco\Debug/../src/Poco.cpp:18: undefined reference to `Poco::ThreadTarget::ThreadTarget(void (*)())' 
C:\Users\M\workspace\Poco\Debug/../src/Poco.cpp:19: undefined reference to `Poco::Thread::Thread()' 
C:\Users\M\workspace\Poco\Debug/../src/Poco.cpp:20: undefined reference to `Poco::Thread::start(Poco::Runnable&)' 
C:\Users\M\workspace\Poco\Debug/../src/Poco.cpp:19: undefined reference to `Poco::Thread::~Thread()' 
C:\Users\M\workspace\Poco\Debug/../src/Poco.cpp:18: undefined reference to `Poco::ThreadTarget::~ThreadTarget()' 
C:\Users\M\workspace\Poco\Debug/../src/Poco.cpp:19: undefined reference to `Poco::Thread::~Thread()' 
C:\Users\M\workspace\Poco\Debug/../src/Poco.cpp:18: undefined reference to `Poco::ThreadTarget::~ThreadTarget()' 

나는 이러한 POCO 스레드 내 지식에 근본적인 결함에서 오는 가정이에서, 나는 작동하지 않는 테스트 프로그램을 만들었습니다. 누군가 POCO 스레드가 어떻게 작동하는지 정확하게 설명하는 작업 프로그램을 제공 할 수 있습니까? 문서는 포괄적이지만 스레드에 포함 된 여러 클래스가 전체적으로 무엇을하는지 설명하지 않습니다.

+0

링커 오류와 비슷합니다. 적절한 라이브러리에 연결하고 있습니까? – mathematician1975

+0

이것은 귀하의 질문과 관련이 없지만 Poco를 버리고 Boost를 사용하는 것이 좋습니다. –

+1

나는 thr.join()을 추가 할 것이다; 경쟁 조건을 피하기위한 문장 'int main() { Poco :: ThreadTarget ra (& myfunc); Poco :: Thread thr; thr.start (ra); thr.join(); return 0; }' –

답변

3

오류는 링커 오류와 유사합니다. 여기 http://pocoproject.org/docs/Poco.Thread.html 설명서에 따르면 PocoFoundation 라이브러리에 연결해야합니다. 어쩌면 당신은 이미 그것을하고 있지만 그렇지 않다면 당신은 필요합니다.

사용중인 OS를 지정하지 않았지만 g ++를 사용하는 경우 빌드 지침에 -lPocoFoundation을 추가하여 라이브러리에 연결하고 해당 라이브러리의 경로를 제공하십시오. 창을 사용하는 경우 PocoFoundation.lib을 프로젝트에 추가하십시오.