Problem linking static libs with common dependencies

G

Guest

MS VC++ 7.1 - I have a project with static libs A, B and C where A depends on
B anc C, also B depends on C. If I set this up in the project dependency
dialog for A the Build environment puts B and C in the command line (seen
in the Librarian view of the project settings for A) an as a result I get
LNK4006 warnings all over the place.

So I am trying to establish dependencies such that A gets rebuilt if source
in B or C changes. What I am getting is that PLUS the linker is trying to
link the other static libs into A which it should not be doing.

This has got to be a bug right?
 
C

Carl Daniel [VC++ MVP]

Eric W said:
MS VC++ 7.1 - I have a project with static libs A, B and C where A depends
on
B anc C, also B depends on C. If I set this up in the project dependency
dialog for A the Build environment puts B and C in the command line
(seen
in the Librarian view of the project settings for A) an as a result I get
LNK4006 warnings all over the place.

So I am trying to establish dependencies such that A gets rebuilt if
source
in B or C changes. What I am getting is that PLUS the linker is trying to
link the other static libs into A which it should not be doing.

This has got to be a bug right?

That does sound iffy.

On the other hand, building the way the IDE wants to, you only need to link
executables with library A, which some might see as a "feature".

-cd
 
S

Sean Cavanaugh

Eric said:
MS VC++ 7.1 - I have a project with static libs A, B and C where A depends on
B anc C, also B depends on C. If I set this up in the project dependency
dialog for A the Build environment puts B and C in the command line (seen
in the Librarian view of the project settings for A) an as a result I get
LNK4006 warnings all over the place.

So I am trying to establish dependencies such that A gets rebuilt if source
in B or C changes. What I am getting is that PLUS the linker is trying to
link the other static libs into A which it should not be doing.

This has got to be a bug right?

If you set a dll or lib as a dependant project in VC, the IDE
automagically tries to link its lib or export library to the dependee.
This can incredibly annoying for plug-in style DLL projects with
abstract DLL interfaces (but you wish to enforce a build order).
Luckily after many many many months of being annoyed at MS for this
behavior, I discovered it could be turned off with a rather esoteric
project setting.

For the dependant project, under the project properties

set 'Linker->Ignore Import Library' to 'Yes' and it will not cause other
projects which depend on it to link the import library generated by it.
And all will be sane and right in your universe.
 
G

Guest

Sean Cavanaugh said:
If you set a dll or lib as a dependant project in VC, the IDE
automagically tries to link its lib or export library to the dependee.
This can incredibly annoying for plug-in style DLL projects with
abstract DLL interfaces (but you wish to enforce a build order).
Luckily after many many many months of being annoyed at MS for this
behavior, I discovered it could be turned off with a rather esoteric
project setting.

For the dependant project, under the project properties

set 'Linker->Ignore Import Library' to 'Yes' and it will not cause other
projects which depend on it to link the import library generated by it.
And all will be sane and right in your universe.
Didn't work. I can't remember if it was ever any different but in VC 7.1
static lib projects don't have a linker options view. They have "Librarian"
view which doesn't have the ignore import lib option. I tried your suggestion
in the linker options for the exe but still get the same warnings when the
static lib project creates the lib. I have used project dependencies in many
projects and this the first time I have run into this. This is the first time
I have used 7.1 I have used 7.0 with no problem. I am going to verify on a
machine with 7.0 that it doesn't happen there.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top