Author Topic: Project Dependencies & Static Libraries  (Read 16505 times)

Offline Cinolt

  • Multiple posting newcomer
  • *
  • Posts: 22
Project Dependencies & Static Libraries
« on: October 30, 2010, 10:21:43 am »
I have two projects in my workspace, one is a program that depends on the other project which is a static library. I set up the program's project to depend on the library and link against the library, and when I go to build the program it indeed builds the static library first, then itself.

But what happens is, when I go to edit one of the static library's source files and build the program without editing the program, it builds the library and does not link the program against the updated library, which means I have to manually rebuild the program (including compiling, since Code::Blocks doesn't seem to provide a feature to just link). Is there any way to have Code::Blocks automatically link against the updated library in that case?
« Last Edit: October 30, 2010, 10:25:03 am by Cinolt »

Offline cacb

  • Regular
  • ***
  • Posts: 399
Re: Project Dependencies & Static Libraries
« Reply #1 on: October 30, 2010, 10:45:07 am »
Hi, I agree with your observation and expectation. I started a thread about the same subject a couple of years ago see
 http://forums.codeblocks.org/index.php/topic,9707.0.html

In my opinion, C::B should indeed relink any application depending on a static library, when that library has been declared as one of the dependencies of the project and when the library has been updated since the last time the application was built.

To make it even clearer: When you build your application today, and that application depends on a static library in the same workspace, the application is not relinked even if the static library has changed since last application build. I consider that a bug.

Observe that this does not imply any expectation of automatically resolving undeclared external libraries, that is something I don't want. I mention this because it caused some confusion in the old thread linked above.
« Last Edit: October 30, 2010, 10:51:34 am by cacb »

Offline Cinolt

  • Multiple posting newcomer
  • *
  • Posts: 22
Re: Project Dependencies & Static Libraries
« Reply #2 on: October 30, 2010, 11:53:21 am »
Thanks for showing me that thread; I got it to work with external dependency files. Incidentally, I'm also in agreement that a project that depends on another library project should relink with it when the latter is updated.

Offline surdules

  • Single posting newcomer
  • *
  • Posts: 2
Re: Project Dependencies & Static Libraries
« Reply #3 on: November 20, 2010, 07:13:51 am »
I am running into the same exact problem, but for some reason it does not work for me to setup the external dependency as you suggest.

Specifically:

1). I have project A that compiles to liba.a
2). I have project B that compiles to b.exe and depends on A
3). Project B is setup such that Properties -> Build Targets -> Dependencies -> External dependency files points to liba.a

When I change something in liba.a's source code, I can see that liba.a is re-generated and has a newer timestamp than b.exe; however b.exe is not being re-linked. The only way to re-link is to delete b.exe, which is a pain.

How do I debug this?

I'm using Code::Blocks 10.05 on Windows XP.

Thanks,

Razvan.

Offline surdules

  • Single posting newcomer
  • *
  • Posts: 2
Re: Project Dependencies & Static Libraries
« Reply #4 on: November 20, 2010, 08:16:45 am »
I figured it out, and it's a Code::Blocks bug.

The dialog with the "External dependency files" actually had more than one dependency in it:

libx.a
liba.a

It turns out that the path to "libx.a" was incorrect, so it's as-if CodeBlocks didn't "see" any of the other dependencies that followed-it. Once I fixed the path to "libx.a", CodeBlocks also "noticed" that liba.a had changed (due to a prior recompile) and re-linked my executable.

Razvan.

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7265
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: Project Dependencies & Static Libraries
« Reply #5 on: November 20, 2010, 08:41:40 am »
I just tried it and can confirm this issue.
 I will look into it.

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7265
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: Project Dependencies & Static Libraries
« Reply #6 on: November 20, 2010, 09:08:57 am »
I just tried it and can confirm this issue.
 I will look into it.

Should be fixed in trunk (svn r6856).