Page 1 of 1

Stucking with pthreads

Posted: Sun Jul 13, 2014 11:11 am
by merk666
Hello! I have in my workspace 3 projects, two - console applications (Ubuntu14.04. GCC), and common library - static now.
The library uses pthreads, implementing wrappers for multitasking... when i make library - all is ok... but when i make any of my console apps - it finishes with error - "undefined reference to `pthread_create'"...which hints that pthread code is not linked into my library.
internet speaks a lot about this issue, and recommends to add -lpthread option to gcc options... but add it after a list of object files... but "compiler additional options" adds new options before object files list... (it i added -lpthread there, problem is not solved)...
So i m searching a way to easy add compiler options after object files list.
Regards, Alex

Re: Stucking with pthreads

Posted: Sun Jul 13, 2014 11:19 am
by merk666
Ahh! problem solved... i just need to add additional -lpthread option to Linker! not to compiler.
At least my problem, easy to be solved will be useful for some novices.
Regards Alex.

Re: Stucking with pthreads

Posted: Sun Jul 13, 2014 11:22 am
by eranif
First, this is not a codelite issue, but a general C/C++ issue.
merk666 wrote:which hints that pthread code is not linked into my library
A library does not get "linked", you can think of a static library as an archive of objects - thats it
merk666 wrote:internet speaks a lot about this issue, and recommends to add -lpthread option to gcc options... but add it after a list of object files... but "compiler additional options" adds new options before object files list... (it i added -lpthread there, problem is not solved)...
So i m searching a way to easy add compiler options after object files list.
Regards, Alex
You need to add

Code: Select all

pthread
to your executables projects

Right click on the project settings (of the console applications)->settings->linker->libraries and type

Code: Select all

pthread
Eran