G
Gerhard Menzl
When creating a Managed C++ DLL using the Visual Studio 7.1 Solution
Explorer (by selecting Add New Project and then either choosing Class
Library (.NET) or Windows Control Library (.NET)), the IDE sets the
/MT(d) compiler switch (statically linked multithreaded C runtime
library) by default. This is fine with me, as it relieves me from having
to redistribute MSVCR71(D).DLL with my application.
However, as soon as a single runtime library function is used in my
DLL's code, the linker complains:
error LNK2019: unresolved external symbol _main referenced in
function _mainCRTStartup
main? In a DLL? Sure enough, the error goes away when I change /MT(d) to
/MD(d), but then I have to redistribute MSVCR71(D).DLL and risk all
kinds of version troubles.
I must say that information on this issue both on MSDN and the entire
Internet is rather poor. There is no indication that DLLs *require*
/MD(d) (my understanding is that the D refers to the runtime library,
not the client assembly, being a DLL), yet building them with /MT(d)
doesn't work. But why does the IDE set the latter option by default? Do
I really have to add a dummy main() function to my DLL when using
/MT(d)? Or have I missed something?
Explorer (by selecting Add New Project and then either choosing Class
Library (.NET) or Windows Control Library (.NET)), the IDE sets the
/MT(d) compiler switch (statically linked multithreaded C runtime
library) by default. This is fine with me, as it relieves me from having
to redistribute MSVCR71(D).DLL with my application.
However, as soon as a single runtime library function is used in my
DLL's code, the linker complains:
error LNK2019: unresolved external symbol _main referenced in
function _mainCRTStartup
main? In a DLL? Sure enough, the error goes away when I change /MT(d) to
/MD(d), but then I have to redistribute MSVCR71(D).DLL and risk all
kinds of version troubles.
I must say that information on this issue both on MSDN and the entire
Internet is rather poor. There is no indication that DLLs *require*
/MD(d) (my understanding is that the D refers to the runtime library,
not the client assembly, being a DLL), yet building them with /MT(d)
doesn't work. But why does the IDE set the latter option by default? Do
I really have to add a dummy main() function to my DLL when using
/MT(d)? Or have I missed something?