How to set one Project to link to another while building

CodeLite installation/troubleshooting forum
CTMacUser
CodeLite Curious
Posts: 3
Joined: Sat Jul 27, 2013 7:21 am
Genuine User: Yes
IDE Question: C++
Contact:

How to set one Project to link to another while building

Post by CTMacUser »

(Sorry if this is covered somewhere in the documentation. Also, I hope the subject will help others when searching for the same problem.)
  • 32-bit Windows 8 Pro (originally Vista) laptop
  • wxWidgets 2.9.5 and CodeLite 5.2 (w/ MinGW 4.7.1) downloaded from SourceForge site
(I pieced together a version of the above, but erased them to start over; I'm new at CodeLite.)

When one has multiple projects in a workspace, how is the output in one project supposed to be added to the other project? And how is the second project supposed to have the first listed as a dependency? Hopefully with substitution variables and/or relative paths, and not absolute paths (which would have to change if I move stuff around). It should be possible; having multiple projects per workspace is COMPLETELY POINTLESS without this capability. Also, with a given configuration for Project 2, the corresponding configuration of Project 1 should be used.

I've seen hints about this capability on these forums, but nothing explicit here or at the wiki site. I put my unit-test support code in a static-library project, and about to make another (command-line program) project for the actual unit tests, but realized I don't know how to connect them together.
User avatar
eranif
CodeLite Plugin
Posts: 6372
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: How to set one Project to link to another while building

Post by eranif »

CTMacUser wrote:how is the output in one project supposed to be added to the other project?
Right click on the target project and select "Common Settings -> Linker" in the Libraries field, you can add libraries (or the output of another project...). Libraries are added as a semi-colon list
CTMacUser wrote:Hopefully with substitution variables and/or relative paths, and not absolute paths (which would have to change if I move stuff around)
I use relative paths for this exact reason (to move things around). You can also use environment variables as well
Also, with a given configuration for Project 2, the corresponding configuration of Project 1 should be used
Build -> Configuration Manager is where you "link" between projects configurations
And how is the second project supposed to have the first listed as a dependency?
Right click on the project and select 'Build Order'

Links to read:
http://codelite.org/LiteEditor/ConfigurationManager
http://codelite.org/LiteEditor/ProjectSettingsSummary

Eran
Make sure you have read the HOW TO POST thread
CTMacUser
CodeLite Curious
Posts: 3
Joined: Sat Jul 27, 2013 7:21 am
Genuine User: Yes
IDE Question: C++
Contact:

Re: How to set one Project to link to another while building

Post by CTMacUser »

eranif wrote:
CTMacUser wrote:how is the output in one project supposed to be added to the other project?
Right click on the target project and select "Common Settings -> Linker" in the Libraries field, you can add libraries (or the output of another project...). Libraries are added as a semi-colon list
It wasn't as easy as that looks.
  • I had to recreate both projects, with the create-a-sub-directory option disabled in both. This setting dumps object, library, and executable files into workspace-level repositories. Since I did this with both projects, they can access each others' stuff.
  • (As explained by eranif, set the"Build Order" so the library is made before the console app.) Since the default name of the library is its project name, use that same name in the console app's linked-to libraries list (without any "lib" prefix and/or ".a" suffix). The important part is to also add "$(IntermediateDirectory)" to the console app's list of library search directories.
Post Reply