ajtaylor@hushmail.com wrote in
news:1154622733.357081.103630@h48g2000cwc.googlegr oups.com:
Quote:
If I make the project not use CLR and only set the managed files to
use CLR then I get the link error
>
[...]
>
I sort of understand why the linker is expecting a lib file as I
suppose by making the project settings not to use CLR then it looks
like a normal dll project.
>
What I dont understand is that if there is some unmanged code in the
project then surely the output is an .NET assembly and thus there is
no lib file.
You are hitting a "bug" in the Visual C++ build system. We are not
supposed to try to link in an import library when the dependent DLL is
a managed DLL with no native exports.
However, there are a couple of reason why this "bug" exists. There are
also some workarounds that you can use.
Let me start with the reasons why this "bug" exists:
1. In a mixed-mode DLL, you can actually have both managed and native
exports. If you had native exports, we would need the import library. We
can't tell if you have native exports unless we inspect the binary.
Inspecting the binary is something that we currently do not do and would
be quite a significant change in how the build system works.
2. To determine that a DLL is a mixed-mode DLL when the project says
that /clr is not being used, we'd have to inspect the options on every
file in the project to see if any file has /clr. This will need to be
done on every build and can be quite expensive (imagine projects with
thousands of files). It will slow down the build for the standard "i'm
building a large native DLL" case which we consider an "evil" thing.
Ok. So what is the workaround? On the general linker settings page of
the consuming project, set "Link Library Dependencies" to "No". This
will have the effect of not linking the import library (which is what
you want) but will also have the effect of not linking in any static or
import libraries that this project depends on (which is probably not
what you want). To avoid the latter side-effect, you'll need to manually
add any dependent libraries you want linked in on the linker line
manually.
I hope this helps.
Thanks,
Tarek Madkour
Lead Program Manager
Microsoft Visual C++