linker error LNK2005, _DllMain@12 already defined
Author: Onega (www.fruitfruit.com)
The project is an ATL ActiveX DLL project, does not use MFC. It compiles OK. There are only two link warnings.
LINK : warning LNK4098: defaultlib "LIBCMTD" conflicts with use of other libs; use /NODEFAULTLIB:library
MSVCRTD.lib(cinitexe.obj) : warning LNK4098: defaultlib "msvcrt.lib" conflicts with use of other libs; use /NODEFAULTLIB:library
After I add a file to the project, which use STL (no MFC). Then I got the link error.
I read http://support.microsoft.com/kb/148652/EN-US/ (Q148652)
create Forcelib.h and include it in stdafx.h, it does not solve the problem.
I put MSVCRTD.lib,mfcs42d.lib in Ignore libraries, and put mfcs42d.lib MSVCRTD.lib in Object/library modules, it does not help.
Oh, My god.
The first thing I add a new .cpp to the project is #include "stdafx.h" in the first line of the cpp.
But after I remove this line, the project can be linked!
Strange enough:
if I don't #include "myfile.h" in imagintr.h
then the compiler accepts
class ImageView
{
...
ImageView::Init(ImageDispRegion *pdisprgn, ImageIntrf *pii);
...
}
After "myfile.h" is included, the compiler complains.
So I change it to:
class ImageView
{
...
int Init(ImageDispRegion *pdisprgn, ImageIntrf *pii);
...
}
after some other staff is added to myfile.cpp,
#include
...
stringstream os;
oss<<__file__<<__line__;>
...
OutputDebugString("aa");
...
After numerous effort, I found that project settings was chagned to Debug Multithreaded instead of Debug Multithreaded DLL.
After I change to /MDd, everything works fine now.
I just want to scold VC++ for its uninformative errors.
Q148652 is badly written. It is the first time I want to add comment to that article, but I can't find a link to comment it.
The project is an ATL ActiveX DLL project, does not use MFC. It compiles OK. There are only two link warnings.
LINK : warning LNK4098: defaultlib "LIBCMTD" conflicts with use of other libs; use /NODEFAULTLIB:library
MSVCRTD.lib(cinitexe.obj) : warning LNK4098: defaultlib "msvcrt.lib" conflicts with use of other libs; use /NODEFAULTLIB:library
After I add a file to the project, which use STL (no MFC). Then I got the link error.
I read http://support.microsoft.com/kb/148652/EN-US/ (Q148652)
create Forcelib.h and include it in stdafx.h, it does not solve the problem.
I put MSVCRTD.lib,mfcs42d.lib in Ignore libraries, and put mfcs42d.lib MSVCRTD.lib in Object/library modules, it does not help.
Oh, My god.
The first thing I add a new .cpp to the project is #include "stdafx.h" in the first line of the cpp.
But after I remove this line, the project can be linked!
Strange enough:
if I don't #include "myfile.h" in imagintr.h
then the compiler accepts
class ImageView
{
...
ImageView::Init(ImageDispRegion *pdisprgn, ImageIntrf *pii);
...
}
After "myfile.h" is included, the compiler complains.
So I change it to:
class ImageView
{
...
int Init(ImageDispRegion *pdisprgn, ImageIntrf *pii);
...
}
after some other staff is added to myfile.cpp,
#include
...
stringstream os;
oss<<__file__<<__line__;>
...
OutputDebugString("aa");
...
After numerous effort, I found that project settings was chagned to Debug Multithreaded instead of Debug Multithreaded DLL.
After I change to /MDd, everything works fine now.
I just want to scold VC++ for its uninformative errors.
Q148652 is badly written. It is the first time I want to add comment to that article, but I can't find a link to comment it.
0 Comments:
Post a Comment
<< Home