User forums > Using Code::Blocks

Linux threads

(1/1)

Dark867:
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!

Jenna:
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:
Thanks so much!
I already feared to be condamned to use gedit+console :D

Navigation

[0] Message Index

Go to full version