Summary: My attempt to build a procedure dll failed with error LNK2005 : _DLLMain@12 already defined.
Process: I am trying to build a procedure dll using VC++ 2003. I created the project from the Extended Stored Procedure template. This template compiles OK. I replaced #include <windows.h> with #include <afxcoll.h> in stdafx.h because I need to use the collection classes in the functions. Build this project again and get the error messages:
------ Build started: Project: testdll3, Configuration: Release Win32 ------
Compiling...
stdafx.cpp
WINVER not defined. Defaulting to 0x0501 (Windows XP and Windows .NET Server)
Compiling...
proc.cpp
testdll3.cpp
Generating Code...
Linking...
nafxcw.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in testdll3.obj
nafxcw.lib(dllmodul.obj) : warning LNK4006: _DllMain@12 already defined in testdll3.obj; second definition ignored
Release/testdll3.dll : fatal error LNK1120: 3 unresolved externals
---------------------- Done ----------------------
By the way, using afxtempl.h instead of afxcoll.h would give the same result. I searched MSDN library and found a few leads to the problem, but none of them apply to this situation.
Can anyone help me
Thanks.
xzhutiger

Build dll failed (_DLLMain@12 already defined), but why?
ward0093
Another issue that might cause it is described at http://support.microsoft.com/default.aspx scid=kb;en-us;148652.
Hope this help!
Thanks,
Ayman Shoukry
VC++ Team