[Threads-list] can't build test.cpp, with threads
Brought to you by:
hanseno
From: Shea M. <sh...@sh...> - 2002-02-01 04:44:01
|
I am relatively new to g++. I am trying to build a simple test program using C++Threads, and the pthreads class. I am pretty sure I have the implementation correct, but I keep getting this compiler output. username# g++ test.cpp /tmp/ccuC6dDp.o: In function `numbers::numbers(int)': /tmp/ccuC6dDp.o(.text+0x13): undefined reference to `cpp_threads::pthread::pthread(int)' /tmp/ccuC6dDp.o(.text+0x37): undefined reference to `cpp_threads::pthread::~pthread(void)' /tmp/ccuC6dDp.o: In function `numbers::~numbers(void)': /tmp/ccuC6dDp.o(.text+0x76): undefined reference to `cpp_threads::pthread::~pthread(void)' /tmp/ccuC6dDp.o: In function `numbers type_info function': /tmp/ccuC6dDp.o(.gnu.linkonce.t.__tf7numbers+0x10): undefined reference to `cpp_threads::pthread type_info function' /tmp/ccuC6dDp.o(.gnu.linkonce.t.__tf7numbers+0x1a): undefined reference to `cpp_threads::pthread type_info node' collect2: ld returned 1 exit status It looks to me like a linking issue. I am guessing that I need another option in my build command "g++ test.cpp". Below is my code: #include <iostream> #include <string> #include <thread.h> using namespace std; using namespace cpp_threads; class numbers : public pthread { public: numbers(int id); ~numbers(); int thread(void *ptr); }; /* numbers::numbers(void *ptr) : pthread(ptr) {} */ numbers::numbers(int id) :pthread(id) { } numbers::~numbers() {} int numbers::thread(void *ptr) { int i; for(i=0; i<1000; i++) { cout <<"->"<< i << endl; } return 0; } int main() { cout <<"before calling thread.\n"; //this is where I want my test thread() to start. cout <<"AFTER calling the thread\n"; return 0; } |