Author Topic: Linux threads  (Read 8073 times)

Dark867

  • Guest
Linux threads
« on: May 12, 2008, 03:55:32 pm »
Hi,I'm starting thread programming using Linux's pthread.h library and I got this error with code::blocks:

||=== pthread, Debug ===|
obj/Debug/main.o||In function `main':|
/home/xxx/workspace/pthread/main.cpp|17|undefined reference to `pthread_create'|
||=== Build finished: 2 errors, 0 warnings ===|

The problem seems to be in the linker,in fact if I try to compile the same program from console using the istruction

g++ -lpthread -o <program_name> main.o

everything works perfectly.
How to make code::blocks use the same istruction?Thanks much for answers!

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Linux threads
« Reply #1 on: May 12, 2008, 04:40:21 pm »
Put "pthread" to your lin-libraries in the prohjects build options.

Right-click your project in the manager and click "Build options".
In the dialog chose your project (not one of the build-targets), click  "Linker Settings" and add "pthread" (without the quotes) to the link libraries.

Dark867

  • Guest
Re: Linux threads
« Reply #2 on: May 12, 2008, 05:08:06 pm »
Thanks so much!
I already feared to be condamned to use gedit+console :D