List Info

Thread: Duplicate target errors vs linking same file to both DLL and EXE?




Duplicate target errors vs linking same file to both DLL and EXE?
country flaguser name
United States
2007-02-08 19:25:34
Hi, fellow boost builders!

   I using bjam v. 3.1.13 NT, boost.build v. 2.0-m11,
msvc-8.0 sp1.

   I need to do something like this and can't seem to figure
out how:

lib library : library.cpp debug.cpp ;
exe program : program.cpp debug.cpp library ;

   In other words, I have DLL called "library"
which exports few 
functions, but also compiles in some service module
(debug.cpp in this 
case). Another "program" needs to use functions
exported by "library", 
but also needs to compile in copy of its own debug.cpp.
(making debug.cpp to export its functions via library.DLL is
not 
acceptable for many reasons). Unfortunately, this always
gives me 
duplicate target errors - when I try to build it using bjam,
I get this:

C:/Boost/boost-build/buildvirtual-target.jam:976: in 
virtual-target.register-actual-name from module
virtual-target
error: Duplicate name of actual target:
<pbinmsvc-8.0debug>debug.obj
error: previous virtual target {
msvc%msvc.compile.c++-debug.obj.OBJ { 
debug.cpp.CPP } }
error: created from ./library
error: another virtual target {
msvc%msvc.compile.c++-debug.obj.OBJ { 
debug.cpp.CPP } }
error: created from ./program
error: added properties: 
<dll-path>/C:/test/bin/msvc-8.0/debug 
<main-target-type>EXE
<xdll-path>/C:/test/bin/msvc-8.0/debug
error: removed properties:  <main-target-type>LIB
C:/Boost/boost-build/buildvirtual-target.jam:450: in 
actualize-no-scanner from module object(file-target)70
C:/Boost/boost-build/buildvirtual-target.jam:110: in 
object(file-target)70.actualize from module
object(file-target)70
C:/Boost/boost-build/buildvirtual-target.jam:723: in 
actualize-source-type from module object(action)71
C:/Boost/boost-build/buildvirtual-target.jam:744: in
actualize-sources 
from module object(action)71
C:/Boost/boost-build/buildvirtual-target.jam:689: in 
object(action)71.actualize from module
object(action)71
C:/Boost/boost-build/buildvirtual-target.jam:273: in
actualize-action 
from module object(file-target)72
C:/Boost/boost-build/buildvirtual-target.jam:458: in 
actualize-no-scanner from module object(file-target)72
C:/Boost/boost-build/buildvirtual-target.jam:110: in 
object(file-target)72.actualize from module
object(file-target)72
C:/Boost/boost-buildbuild-system.jam:372: in load from
module build-system
C:Boostboost-build/kernelmodules.jam:261: in import from
module modules
C:Boostboost-build/kernel/bootstrap.jam:132: in
boost-build from module
C:Boostboost-buildboost-build.jam:1: in module scope from
module



I am aware of this FAQ item: 
http://www.boost.org/doc/html/bbv2/faq.html#id2861593,
but it only talks 
about two executables partially derived from the same source
files.

My trouble is that my target types are different - one is
DLL, another 
is EXE.

I tried to play with making object file local to main target
(solution 
3), but I just couldn't make it work.
Actually, in reality I need more than one extra file to be
compiled 
multiple times, but I guess I should make it work one
first.

Does anyone know how to get past this? It is really a big
bummer for me :-(


I have created small testcase which shows the problem
(inline here and also as an attachment):

// debug.cpp contents:

#include <stdio.h>

void debug(char* string) {
     printf(string);
}

// debug.h contents:

void debug(char* string);

#// Jamroot contents:

lib library : library.cpp debug.cpp ;
exe program : program.cpp library ;

// library.cpp contents:

#include "debug.h"

_declspec(dllexport) int __stdcall libfoo() {
    debug("In libfoon");
    return 100;
}

// library.h contents:

_declspec(dllexport) int __stdcall  libfoo();

// program.cpp contents:

#include "library.h"
#include "debug.h"

int main() {
     debug("In mainn");
     libfoo();
     return 0;
}


Vadim.

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build

  
  
  
  
  
  
  
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )