Problem creating multiple .dlls that depend on each other

G

Guest

I am in VS2003, building C++ .dll libraries.

I want to create a single .dll that combines its own code with code from
other dlls. For example, I want to build B.dll, where B has its own source
code, and also refers to routines in A.dll. I have another app C.exe that
will link to B.dll (and/or A.dll).

Clearly there is a dependency: B depends on A.

I can build and link A.dll just fine on its own. But when I try to build
B.dll, I get problems.

The first problem was that when I tried to build B.dll on its own, the
routines in A that B wants were not there, so I got a slew of LNK2001 and
LNK2019 (unresolved external symbol) errors, for all the routines in A that
are referred to in B.

My attempt to fix this was to set A.dll as input to the linker in B, in
Additional Dependencies. However, when I do this, it fails with LNK1136
(invalid or corrupt file), presumably because I am linking in a .dll, not a
..lib

There is no A.lib, and I don't know where else the linker for B can find the
routines in A that it needs.

What can I do to fix this?

Thanks
 
M

Martin Richter [MVP]

Hallo Michael L!
I want to create a single .dll that combines its own code with code from
other dlls. For example, I want to build B.dll, where B has its own source
code, and also refers to routines in A.dll. I have another app C.exe that
will link to B.dll (and/or A.dll).

Clearly there is a dependency: B depends on A.

I can build and link A.dll just fine on its own. But when I try to build
B.dll, I get problems.

The first problem was that when I tried to build B.dll on its own, the
routines in A that B wants were not there, so I got a slew of LNK2001 and
LNK2019 (unresolved external symbol) errors, for all the routines in A that
are referred to in B.

My attempt to fix this was to set A.dll as input to the linker in B, in
Additional Dependencies. However, when I do this, it fails with LNK1136
(invalid or corrupt file), presumably because I am linking in a .dll, not a
.lib

There is no A.lib, and I don't know where else the linker for B can find the
routines in A that it needs.

What can I do to fix this?

There must be a LIB file for A. Otherwies force creation of it. Include
this as an input file for B.
Usually if I have constructs like this I just create a great solution
hat include EXE and DLL's then I define dependiencies and usually this
is enough.
 
G

Guest

There must be a LIB file for A. Otherwies force creation of it. Include
this as an input file for B.
Usually if I have constructs like this I just create a great solution
hat include EXE and DLL's then I define dependiencies and usually this
is enough.

Thanks, Martin. That starts to make sense.

Is there a way to tell it to build both a .lib and a .dll for A at the same
time, or do I have to choose only one that is built at a time?

Thanks, Michael
 
M

Martin Richter [MVP]

Hallo Michael L!
Thanks, Martin. That starts to make sense.

Is there a way to tell it to build both a .lib and a .dll for A at the same
time, or do I have to choose only one that is built at a time?

Usually lib and dll are produced at the same time. The default project
settings ofthe linker are adjusted in tis way. Look into the linker
properties.
 

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