Author Topic: How do I specify dependencies across Targets? (SOLVED)  (Read 3783 times)

Offline kfmfe04

  • Multiple posting newcomer
  • *
  • Posts: 27
How do I specify dependencies across Targets? (SOLVED)
« on: June 25, 2009, 05:03:43 pm »
Hi,

I have a dependency problem that is driving me nuts.  I have three Targets:

A. Debug Static Lib that depends on foo.cpp and bar.cpp, builds lib/Debug/libfoobar.a
B. Release Static Lib that depends on foo.cpp and bar.cpp, builds lib/Release/libfoobar.a
C. A Console executable that depends on/links with B. and main.cpp

I can build A., B., and C., individually, with no problems.

However, when I am targeting C., and I modify foo.cpp or bar.cpp, how do I set up my dependencies in C::B so that it knows to build B. (the static release lib) first, before attempting a link at C.?

In other words, although I am targeting C., I want it to make B. before making C., when foo.cpp or bar.cpp is modified.

I am running C::B 8.02 on Ubuntu 8.10 amd64.  Any help would be greatly appreciated.

Regards,
Ken
« Last Edit: June 25, 2009, 07:19:53 pm by kfmfe04 »

Offline kfmfe04

  • Multiple posting newcomer
  • *
  • Posts: 27
Re: How do I specify dependencies across Targets?
« Reply #1 on: June 25, 2009, 05:53:30 pm »
I searched around the this site and found this:

http://forums.codeblocks.org/index.php?topic=10458.0;prev_next=next

You can set dependencies to external files in the projects properties.

Right-click your project and chose "Properties -> Build targets". For every build target (e.g. Release, Debug) you can click on "Dependencies" and set the static lib(s) it depends on as external file.

If you want to make sure the lib is checked for changes and eventually build before the actual project, include the project containing the lib in "Project's dependencies" (on "Project settings" tab).

I tried the first suggestion while A., B., and C. were all in the same project and that didn't work.

Then I tried the second suggestion after I broke out C. into a second project.  I didn't have to manually go through the steps because the system seemed to know to do the second step automagically when I picked the library dependency.  But when I modified foo.cpp while targeting C. to build, B. still did not build first.  I tried doing the first suggestion, too, but again, B. did not build first.

...still scrounging around for a solution...

- Ken

Offline kfmfe04

  • Multiple posting newcomer
  • *
  • Posts: 27
Re: How do I specify dependencies across Targets?
« Reply #2 on: June 25, 2009, 06:01:25 pm »
I think I may have a hack-y workaround...

...in the Pre-build steps for C., if I can figure out the command-line to make B. in the other project, then this should work.

If foo.cpp hasn't been changed, it will just be a small wasted check to ensure B. is current.
If foo.cpp changed, this pre-build should force B. to build first.

Hmm...  now, I need to figure out: how to build B. from the command line (which is in the other proejct)...

- Ken

Offline kfmfe04

  • Multiple posting newcomer
  • *
  • Posts: 27
Re: How do I specify dependencies across Targets?
« Reply #3 on: June 25, 2009, 07:19:33 pm »
My mistake. 

I found this link:

http://wiki.codeblocks.org/index.php?title=The_build_process_of_Code::Blocks#Using_project_dependencies

and I reread Jens suggestions - his 2nd suggestion worked for me - my blurry eyes didn't notice that the checkbox was not selected - after checking it off, the build works as expected...

- K