News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

Problems with code blocks threading

Started by TuxD3v, January 30, 2011, 01:00:08 AM

Previous topic - Next topic

TuxD3v

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...


TuxD3v

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

stahta01

C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

TuxD3v

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

oBFusCATed

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
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

TuxD3v

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

oBFusCATed

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?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]