From: Marc Oden on
I have a ATL simple object project which uses MFC that I can build for
awhile and then it starts getting the following error:

Error LNK2005: _DllMain(a)12 already defined in msvcrtd.lib(dllmain.obj)
mfcs90ud.lib

I have tried all the solutions in http://support.microsoft.com/kb/148652

So far:

I have added the value "mfcs90ud.lib; msvcrtd.lib" to the Ignore Specfic
Library Linker property and the Add Module to Assembly propery. This results
in many undefined entry points.

I have moved the include of afx.h up to the top of stdafx.h

I have created a new header file forcelib.h and included it in dlldatax.c.

The only way that I have found to get around the problem is to completely
rebuild it using the New project wizard. It will then build properly for
awhile then start getting the same errors.

From: Joseph M. Newcomer on
It appears you are linking some object file or library created with an earlier version of
VS, which has included the directive

#pragma comment(lib, "msvcrtd.lib")

Of course, such a module is completely inconsistent with something built under any other
version of VS. So you need to find which obsolete object file you are linking in, and
obtain an object file consistent with the new compiler, by either rebuilding it (if you
have the source) or obtaining the updated version (if you are using an externally-supplied
library).

You cannot mix-and-match object files from older versions of the compiler with those
created by the current compiler.
joe

On Thu, 10 Dec 2009 07:20:55 -0600, "Marc Oden" <moden(a)avioninc.com> wrote:

>I have a ATL simple object project which uses MFC that I can build for
>awhile and then it starts getting the following error:
>
>Error LNK2005: _DllMain(a)12 already defined in msvcrtd.lib(dllmain.obj)
>mfcs90ud.lib
>
>I have tried all the solutions in http://support.microsoft.com/kb/148652
>
>So far:
>
>I have added the value "mfcs90ud.lib; msvcrtd.lib" to the Ignore Specfic
>Library Linker property and the Add Module to Assembly propery. This results
>in many undefined entry points.
>
>I have moved the include of afx.h up to the top of stdafx.h
>
>I have created a new header file forcelib.h and included it in dlldatax.c.
>
>The only way that I have found to get around the problem is to completely
>rebuild it using the New project wizard. It will then build properly for
>awhile then start getting the same errors.
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
From: Giovanni Dicanio on
"Marc Oden" <moden(a)avioninc.com> ha scritto nel messaggio
news:13552B9F-CDE1-473D-8E15-42D6738683A5(a)microsoft.com...

> I have a ATL simple object project which uses MFC that I can build for
> awhile and then it starts getting the following error:
>
> Error LNK2005: _DllMain(a)12 already defined in msvcrtd.lib(dllmain.obj)
> mfcs90ud.lib

I would suggest you to create a new ATL project using the Visual Studio
wizard; you can specify MFC support in an ATL project using the wizard.
The wizard will take care of details and then you can write your ATL/MFC
code.

If you have some legacy code built with a previous version of VS, I would
suggest you to recreate the ATL simple object using your current version of
VS, and then copy-and-paste code of ATL object methods from previous version
to new one, method by method.

For better help on ATL, the microsoft.public.vc.atl newsgroup is a great
place to ask.

HTH,
Giovanni


From: Marc Oden on
Giovanni,

Thank you for replying. The method you described is exactly how I created
the project. My project does contain a shared libarary that came from a
hardware vendor (I do not have the source) that I believe is compiled with
the MBCS instead of UNICODE. This might be causing the problem.

"Giovanni Dicanio" <giovanniDOTdicanio(a)REMOVEMEgmail.com> wrote in message
news:Oi5ZbGceKHA.2188(a)TK2MSFTNGP04.phx.gbl...
> "Marc Oden" <moden(a)avioninc.com> ha scritto nel messaggio
> news:13552B9F-CDE1-473D-8E15-42D6738683A5(a)microsoft.com...
>
>> I have a ATL simple object project which uses MFC that I can build for
>> awhile and then it starts getting the following error:
>>
>> Error LNK2005: _DllMain(a)12 already defined in msvcrtd.lib(dllmain.obj)
>> mfcs90ud.lib
>
> I would suggest you to create a new ATL project using the Visual Studio
> wizard; you can specify MFC support in an ATL project using the wizard.
> The wizard will take care of details and then you can write your ATL/MFC
> code.
>
> If you have some legacy code built with a previous version of VS, I would
> suggest you to recreate the ATL simple object using your current version
> of VS, and then copy-and-paste code of ATL object methods from previous
> version to new one, method by method.
>
> For better help on ATL, the microsoft.public.vc.atl newsgroup is a great
> place to ask.
>
> HTH,
> Giovanni
>
>

From: Marc Oden on
Joe, Thanks I do have a shared library from a hardware vender was compiled
with VS2005. I do not have the source code so I will have rebuild my
project under VS2005.

"Joseph M. Newcomer" <newcomer(a)flounder.com> wrote in message
news:3952i51s8c7jg0oovf3e0870tp4frpovco(a)4ax.com...
> It appears you are linking some object file or library created with an
> earlier version of
> VS, which has included the directive
>
> #pragma comment(lib, "msvcrtd.lib")
>
> Of course, such a module is completely inconsistent with something built
> under any other
> version of VS. So you need to find which obsolete object file you are
> linking in, and
> obtain an object file consistent with the new compiler, by either
> rebuilding it (if you
> have the source) or obtaining the updated version (if you are using an
> externally-supplied
> library).
>
> You cannot mix-and-match object files from older versions of the compiler
> with those
> created by the current compiler.
> joe
>
> On Thu, 10 Dec 2009 07:20:55 -0600, "Marc Oden" <moden(a)avioninc.com>
> wrote:
>
>>I have a ATL simple object project which uses MFC that I can build for
>>awhile and then it starts getting the following error:
>>
>>Error LNK2005: _DllMain(a)12 already defined in msvcrtd.lib(dllmain.obj)
>>mfcs90ud.lib
>>
>>I have tried all the solutions in http://support.microsoft.com/kb/148652
>>
>>So far:
>>
>>I have added the value "mfcs90ud.lib; msvcrtd.lib" to the Ignore Specfic
>>Library Linker property and the Add Module to Assembly propery. This
>>results
>>in many undefined entry points.
>>
>>I have moved the include of afx.h up to the top of stdafx.h
>>
>>I have created a new header file forcelib.h and included it in dlldatax.c.
>>
>>The only way that I have found to get around the problem is to completely
>>rebuild it using the New project wizard. It will then build properly for
>>awhile then start getting the same errors.
> Joseph M. Newcomer [MVP]
> email: newcomer(a)flounder.com
> Web: http://www.flounder.com
> MVP Tips: http://www.flounder.com/mvp_tips.htm