Solved

Problems building DLLs in VC++ 5.0

Posted on 1997-05-07
2
287 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
Comment Utility
Edited text of question
0
 
LVL 1

Accepted Solution

by:
jungel earned 100 total points
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now