Author Topic: Problems with code blocks threading  (Read 17585 times)

Offline TuxD3v

  • Multiple posting newcomer
  • *
  • Posts: 12
Problems with code blocks threading
« 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...


Offline TuxD3v

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: Problems with code blocks threading
« Reply #1 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

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7588
    • My Best Post
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline TuxD3v

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: Problems with code blocks threading
« Reply #3 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

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Problems with code blocks threading
« Reply #4 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
(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!]

Offline TuxD3v

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: Problems with code blocks threading
« Reply #5 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

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Problems with code blocks threading
« Reply #6 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?
(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!]