Page 1 of 1

How to set one Project to link to another while building

Posted: Sat Jul 27, 2013 9:18 pm
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.

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

Posted: Sun Jul 28, 2013 10:01 am
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

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

Posted: Wed Jul 31, 2013 8:48 pm
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.