Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: TuxD3v on January 30, 2011, 01:00:08 am

Title: Problems with code blocks threading
Post by: TuxD3v on January 30, 2011, 01:00:08 am
hi,
i have some troubles with a C program that i made,... for compiling it in code blocks i am using gcc and i am in ubuntu.

this is my thread call function:
pthread_create(&gothreads,NULL, workload,&newuser);

when i try to compile the entire project the code blocks give me the following error message:
pthread_create(&gothreads,NULL, workload,&newuser);

 i put in compiler settings->other settings
-lpthread
what’s going wrong??
help please...

Title: Re: Problems with code blocks threading
Post by: TuxD3v on January 30, 2011, 01:31:09 am
sorry the error is :
xpto.c|188|undefined reference to `pthread_create'|
i made the #include <pthread.h>
wats wrong??
help please

thanks in advance
lmx
Title: Re: Problems with code blocks threading
Post by: stahta01 on January 30, 2011, 02:00:06 am
http://wiki.codeblocks.org/index.php?title=FAQ#Q:_How_do_I_troubleshoot_an_compiler_problem.3F
Title: Re: Problems with code blocks threading
Post by: TuxD3v on January 30, 2011, 04:08:16 am
hi,
thanks for the attention, but i am in Ubuntu, and my problem is how i can put the flag -lpthread in the compiler...for now i have a dynamic library for the linker:
/usr/lib/libpthread.so and it is working but its a dynamic library, i want to compile with a static library.....how i can do something like this gcc -c --lpthread....xpto ?

thanks for the attention.
lmx
Title: Re: Problems with code blocks threading
Post by: oBFusCATed on January 30, 2011, 12:22:38 pm
Project -> Build options -> Linker -> Other

Also you've not read the gcc docs carefully ... the correct flag is -pthread and you should pass it in both stages: compilation and linking
Title: Re: Problems with code blocks threading
Post by: TuxD3v on January 30, 2011, 06:42:40 pm
hi,
 thanks for the help...
 what you are saying to me is that i need to do the same for the compiler and the linker like this :
Project -> Build options -> Compiler settings -> Other Options--> "-pthread"
Project -> Build options -> Linker settings -> Other Linker Options-->"-pthread"
is this...?
In codeblocks is possible to make debuging in a multithread program?

thanks in advance.
lmx
Title: Re: Problems with code blocks threading
Post by: oBFusCATed on January 30, 2011, 07:48:14 pm
1. Yes, you need both, but you can check in the docs, I've read them long ago, so I might remember it wrongly...
2. Yes, you can debug multi-threaded programs, have you tried?