Solved

Problems building DLLs in VC++ 5.0

Posted on 1997-05-07
2
307 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

733 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