# Ubuntu – Multithreading in codeblocks

code-blocks

I tried to implement multithreading using codeblocks in ubuntu.
I typed the following program.

void *myThreadFun(void *vargp)
{

sleep(1);
printf("Printing hi from Thread \n");
return NULL;
}

int main()
{

exit(0);
}


But I couldn't compile and run the program in codeblocks.
I got the following error

multithread.c  undefined reference to 'pthread_create'


can someone help me out

I had used the following header files in the code:

pthread.h
stdio.h
stdlib.h


• In Code::Blocks if you are using the GNU gcc compiler, you will probably need to add the -pthread compiler flag to both the compiler and linker options (under `Project --> Build options...)