creating a Thread

I am writing a program in ubuntu in which a thread is to be created. A snippet from the code is as follows:
-------------------------------------------------------
1
2
3
4
5
6
7
8
9
10
#include <pthread.h>
void *updater (unsigned char matrix[8][8]);

int main (int argc, char **argv)
{
	pthread_t mat_thread;
	int iret, i, x;

	iret = pthread_create( &mat_thread, NULL, updater, matrix )

the program compiles in codeblocks with one error which reads:

undefined reference to 'pthread_create'


This I believe means that the file libpthread.so is not available. I have downloaded and installed the gcc and gdb for unbuntu and can find no other source for the missing library.

Can anyone tell me if my diagnosis is correct and how to to remedy it???
You need to link pthread:
g++ *.cpp -pthread
Last edited on
http://www.cplusplus.com/forum/unices/87391/#msg468917
man wrote:
-pthread
Adds support for multithreading with the pthreads library. This option sets flags for both the preprocessor and linker.

Topic archived. No new replies allowed.