View Single Post
Old 14th November 2002, 06:57   #1
trausti
Junior Member
 
Join Date: Nov 2002
Posts: 1
Solution: Linker error in VS.net

Hi

I had a problem compiling under studio .net, when following the instructions.
(Hopefully these tips will save someone else from wasting many hours like I did.)

As per instructions, I created a fresh MFC-DLL project, deleted out the auto-generated stuff, and tried to follow the instructions given for older MS Studio version.

However, I got the error:

MyPlugin error LNK2005: _DllMain@12 already defined in MSVCRTD.lib(dllmain.obj)
Searching D:\Program Files\Microsoft Visual Studio .NET\Vc7\lib\kernel32.lib:
Searching D:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\lib\user32.lib:

and using the /link /VERBOSE:LIB linker directive, the linker output was:


Searching libraries
...
Searching D:\Program Files\Microsoft Visual Studio .NET\Vc7\lib\MSVCRTD.lib:
...
Searching D:\Program Files\Microsoft Visual Studio .NET\Vc7\atlmfc\lib\mfcs70d.lib:
mfcs70d.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in MSVCRTD.lib(dllmain.obj)

The solution was to change the setting

Property Pages -> C/C++ -> Preprocessor -> Preprocessor Definitions

and remove _USRDLL and add _AFXEXT.

so now the line reads:

WIN32;_WINDOWS;_DEBUG;_AFXEXT

hope this helps someone.

Cheers
T.K.
trausti is offline   Reply With Quote