Stucking with pthreads

General questions regarding the usage of CodeLite
merk666
CodeLite Curious
Posts: 7
Joined: Sun Jul 13, 2014 10:20 am
Genuine User: Yes
IDE Question: c++
Contact:

Stucking with pthreads

Post 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
Ubuntu 14.04, Codelite, GCC
merk666
CodeLite Curious
Posts: 7
Joined: Sun Jul 13, 2014 10:20 am
Genuine User: Yes
IDE Question: c++
Contact:

Re: Stucking with pthreads

Post 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.
Ubuntu 14.04, Codelite, GCC
User avatar
eranif
CodeLite Plugin
Posts: 6375
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Stucking with pthreads

Post 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
Make sure you have read the HOW TO POST thread
Post Reply