Hi all,

I am trying to build two different dll files using a shared .cpp source file and two different header files using MSBUILD. So for an example, I want to use a.cpp and headera.h to compile a.dll , and a.cpp and headerb.h to compile b.dll. Let's suppose that the following are the directory A and B that contains the files in question.

# a.def lists an exported function "Func"
A\
a.cpp
a.def
headera.h
sources

# b.def lists an exported function "Func"
B\
b.def
headerb.h
sources

I am trying to achieve building 2 dlls by,

1) adding the following lines in the a.cpp file,
Code:
    #if defined CONSTANTA
    #include <headera.h>
    #elif defined CONSTANTB
    #include <headerb.h>
    #endif
2) adding the following line in the "A\sources" file
Code:
    C_DEFINES=$( C_DEFINES ) -DCONSTANTA
3) adding the following line in the "B\sources" file
Code:
    C_DEFINES=$( C_DEFINES ) -DCONSTANTB
    ...
    # no source file is listed under SOURCES macro, because I wanted to share the A\a.cpp file
    SOURCES=\ 
    TARGETLIBS=\
        ...add all the libraries listed under TARGETLIBS macro in "A\sources" file here...
        $(A_OBJ_FOLDER)\$(0)\a.obj
A folder builds fine, but B folder outputs the following errors,
1>errors in directory d:\B
1> d:\B\B.def : error LNK2001: unresolved external symbol Func
1>d:\B.obj.x86chk\objchk\i386\B.lib : error LNK1120: 1 unresolved externals
I confirmed that the file $(A_OBJ_FOLDER)\$(0)\a.obj is built before building the folder B. I tried to manipulate SOURCES file to make this work, but I am kind of stuck at this point. Would anyone familiar with the matter give me a few pointers? If you have an idea as to building the two dlls in a simpler way, I'd appreciate that as well. Thanks!