Adding a library to all projects in a workspace

General questions regarding the usage of CodeLite
drh
CodeLite Curious
Posts: 2
Joined: Thu May 03, 2012 7:34 am
Genuine User: Yes
IDE Question: C++
Contact:

Adding a library to all projects in a workspace

Post by drh »

I have a workspace with multiple projects. They all use the rt lib and a Utility lib.

I tried adding them as a switch in Settings->Build Settings->gnu g++->Linker options but that didn't work.

Can I set it up so that I don't have to add them to each projects global settings?


Version 3.5.5375 on Ubuntu
User avatar
eranif
CodeLite Plugin
Posts: 6372
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Adding a library to all projects in a workspace

Post by eranif »

drh wrote:I tried adding them as a switch in Settings->Build Settings->gnu g++->Linker options but that didn't work.
this is not the place to add them. If you wanted to add it on the compiler level, you should do it from:
"Settings->Build Settings->gnu g++->Tools->Linker Name"
and replace "g++" with "g++ -lrt -lUtils"

But I am not sure that this is the correct thing to do. I would clone g++ compiler and create a new one named "g++ with rt" (or something like this) and then do this change
drh wrote:Can I set it up so that I don't have to add them to each projects global settings?
Read my previous answer ^^

Eran
Make sure you have read the HOW TO POST thread
drh
CodeLite Curious
Posts: 2
Joined: Thu May 03, 2012 7:34 am
Genuine User: Yes
IDE Question: C++
Contact:

Re: Adding a library to all projects in a workspace

Post by drh »

No joy. I added it to the linker line and my make now produces:

g++ -lrt -lFASTLib -lUtilityLib -o ./Release/SER_GPS @"/home/test/dev/FASTTrac/SER_GPS/SER_GPS.txt"

And it leaves everything unresolved.

The original compile that works uses (with libraries defined in the project settings)
g++ -o ./Release/SER_GPS @"/home/dhuff/dev/FASTTrac/SER_GPS/SER_GPS.txt" -lrt -lFASTLib -lUtilityLib

I know that order for the libs matters (I had something in FASTLib that relied on UtilityLib and if the order was rt;UtilityLIb;FASTLib and I was again left with unresolved items).
I guess it also matters in the linking command line as well.

Any ideas?
User avatar
eranif
CodeLite Plugin
Posts: 6372
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Adding a library to all projects in a workspace

Post by eranif »

Ok, here is a better way of doing it - its a much nicer hack ;)

right click on your workspace, and select "Workspace Settings"
In the "Environment" tab. In the "Specify here an additional environment variables" box, type"

Code: Select all

LinkOptions=$(LinkOptions)  -lrt -lFASTLib -lUtilityLib
This will append " -lrt -lFASTLib -lUtilityLib " to the end of your project link options and it should work

Eran
Make sure you have read the HOW TO POST thread
User avatar
Jarod42
CodeLite Expert
Posts: 237
Joined: Wed Sep 30, 2009 5:54 pm
Genuine User: Yes
IDE Question: C++
Location: France
Contact:

Re: Adding a library to all projects in a workspace

Post by Jarod42 »

An alternative is to use a tool to generate Codelite project (like Premake).

With it, you can set settings at solution level, and the tool does the job to "dispatch" setting per project.
Post Reply