views:

2544

answers:

2

I am getting this linker error.

mfcs80.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in MSVCRT.lib(dllmain.obj)

Please tell me the correct way of eliminating this bug. I read solution on microsoft support site about this bug but it didnt helped much.

I am using VS 2005 with Platform SDK

+2  A: 

If you're defining your own DllMain, in your project settigns you need to set 'Use of MFC' in the 'Configuration Properties/General' to 'Use Standard Windows Libraries'.

You should do a clean rebuild after changing it.

James Hopkin
+3  A: 

If you read the linker error thoroughly, and apply some knowledge, you may get there yourself:

The linker links a number of compiled objects and libraries together to get a binary.

Each object/library describes

  • what symbols it expects to be present in other objects
  • what symbols it defines

If two objects define the same symbol, you get exactly this linker error. In your case, both mfcs80.lib and MSVCRT.lib define the _DllMain@12 symbol.

Getting rid of the error:

  1. find out which of both libraries you actually need
  2. find out how to tell the linker not to use the other one (using e.g. the tip from James Hopkin)
xtofl
+1 Good point - I didn't quite read the error properly. I had a similar linker error myself recently when the MFC libraries option had mysteriously turned itself on.
James Hopkin
Accurate Explaination. Thanks for that. :)
mahesh