I started using POCO and have looked over the documentation of threads. From this, I created a test program which does not seem to work:
#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;
}
I get these errors:
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()'
I assume that these come from some fundamental flaw in my knowledge of POCO threads. Could someone supply a working program, or better, an explanation of exactly how POCO threads work. The documentation, though extensive, doesn’t explain what the multiple classes involved in threads do as a whole.
Your errors look like linker errors. According to the documentation here http://pocoproject.org/docs/Poco.Thread.html you need to ensure you link to the PocoFoundation library. Maybe you are already doing that but if not you need to.
You dont specify the OS you are using but if you are using g++ try adding
-lPocoFoundationto your build instructions to link to the library and provide the path to that library. If using windows addPocoFoundation.libto your project.