Boost logo

Boost-Build :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2004-02-02 05:35:22

it seems like "Duplicate name of actual target" error became quite popular
recently ;-)

Still we don't have it in docs, and diagnosing it is not as easy. We only
print the names of files which conflict and without properties it hard to
understand the problem.

For example:

stage dist : b b/<threading>multi ;

is one case which can cause a lot of research in non-trivial case (imagine
'stage' traverses dependencies, so conflicting targets are defined somewhere
deep inside your project).

I attach two things for review. First is the docs about the error message.
It's based on the recent thread on topic.

Second is the example of the new error message. While it does not shows the
problem point, it provides all the necessary information. In this case, it's
possible to find that two 'b' targets differ in value of 'threading'
property. The new error message is actually implemented and can be comitted
any moment.

Comments are welcome!

- Volodya

 --Boundary-00=_qfiHAlOYCFBWGbi Content-Type: text/plain;
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;

Q. I'm getting "Duplicate name of actual target" errors.
What does it mean?

A. The most likely case is that you're trying to
compile the same file twice, with almost the same,
but differing properties. For example:

exe a : a.cpp : <include>/usr/local/include ;
exe b : a.cpp ;

The above snippet requires two different compilations
of 'a.cpp', which differ only in 'include' property.
Since the 'include' property is free, Boost.Build
can't generate two ojects files into different directories.
On the other hand, it's dangerous to compile the file only
once -- maybe you really want to compile with different

To solve this issue, you need to decide if file should
be compiled once or twice.

1. Two compile file only once, make sure that properties
are the same:

exe a : a.cpp : <include>/usr/local/include ;
exe b : a.cpp : <include>/usr/local/include ;

2. If changing the properties is not desirable, for example
if 'a' and 'b' target have other sources which need
specific properties, separate 'a.cpp' into it's own target:

obj a_obj : a.cpp : <include>/usr/local/include ;
exe a : a_obj ;
exe b : a_obj ;

3. To compile file twice, you can object file local to the
main target:

exe a : [ obj a_obj : a.cpp ] : <include>/usr/local/include ;
exe b : [ obj a_obj : a.cpp ] ;

A good question is why Boost.Build can't use some of the above
approaches automatically. The problems is that such magic would
require additional implementation complexities and would only
help in half of the cases, while in other half we'd be silently
doing wrong thing. It's simpler and safe to ask user to clarify
his intention in such cases.


Boost-Build list run by bdawes at, david.abrahams at, gregod at, cpdaniel at, john at