Solved

Problems building DLLs in VC++ 5.0

Posted on 1997-05-07
2
300 Views
Last Modified: 2010-04-10

In Visual C++ I use the App Wizard to generate a DLL shell (with the MFC stuff not statically linked),
and add in some objects that I've pre-written, and wish to add to the library. I run Dllxprt32.exe to generate a DEF file from the compiled objects and build the DLL.

So far, so good...

I then build a test app to call into the DLL, and this works fine.

However, when I go back and try to rebuild the DLL at this point I get the following linker error...

mfcs42d.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in
MSVCRTD.lib(dllmain.obj)
mfcs42d.lib(dllmodul.obj) : warning LNK4006: _DllMain@12 already defined in
MSVCRTD.lib(dllmain.obj); second definition ignored
   Creating library Debug/MfcDLL.lib and object Debug/MfcDLL.exp
Debug/MfcDLL.dll : fatal error LNK1169: one or more multiply defined
symbols found

Now I'm prepared to accept that the two libraries both have a definition of DllMain(),
but how come it built the first time OK?
I need both mfcs42d.lib and msvcrtd.lib to build the DLL...

I'm using Visual C++ 5.0, with Win95
Can anyone tell me what I'm doing wrong?


Thanks,
Steve Hobley.
0
Comment
Question by:sjhobley
2 Comments
 

Author Comment

by:sjhobley
ID: 1163340
Edited text of question
0
 
LVL 1

Accepted Solution

by:
jungel earned 100 total points
ID: 1163341
This is an odd bug that can be take care of by reversing the defualt include/link order.  In project settings,linker tab, input category, place both msvcrtd.lib and mfcs42d.lib in the "Ignore Libraries" text box, separated by commas.

Then, put both of them into the object/library modules text box.  Do a full re-build .  If that doesn't work, reverse the order of the libraries in the object/library modules text box.

What you're doing here is forcing the linker to link in a certain order.  This should solve your problem  (and don't forget to change the settings for the release version as well).

Good luck!!
-Alex
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

778 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question