Solved

ATL and MFC support

Posted on 2001-06-02
5
517 Views
Last Modified: 2013-12-14
I'm new to ATL programming so kindly bare with my ignorance, please...

I've written an ATL COM .dll that populates a recordset and returns it to a VB Caller.  Everything works great.

I followed a couple of examples and used the Wizard to build this .dll.  When I compile it (with MFC support), the resulting .dll is about 45k long.

If I go to setting and specify No MFC support and complile it, I get a couple of warnings:

INK : warning LNK4089: all references to "SHELL32.dll" discarded by /OPT:REF
LINK : warning LNK4089: all references to "comdlg32.dll" discarded by /OPT:REF

The .dll still works as expected but the resulting .dll grows to approx. 128K long (I am expecting a smaller .dll not a larger one!)

Ok, so if I am trying to produce the lightest weight .dll, which way do I go - MFC support or not. (Or perhaps you have a different suggestion).

Thanks in advance for your assistance!
0
Comment
Question by:khampton
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 32

Expert Comment

by:jhance
ID: 6148900
These two warning messages are fine. What they mean is that you (or actually the Project Wizard) told the linker to include SHELL32.LIB and COMDLG32.LIB in the list of libraries to link the project against but that no functions were used out of either of these libs.

It's not an error, just the linker doing what you told it to do, that is remove all unused library code, and telling you that you specified unneeded library files.

In most cases, you'll just want to ignore this.
0
 
LVL 1

Author Comment

by:khampton
ID: 6149641
That's what I thought.  But my real question is why did the dll size grow from 45k to 128K.  AND how do I get the lightest weight .dll?  (ie: since including MFC support results in a smaller .dll, is it really lighter weight OR will I actually be having to download the MFC with it if I use it over the Web for instance?)
0
 

Expert Comment

by:robertmitchell_99
ID: 6150187
hi khampton,

Whats happening is this...

When your dll is built using MFC support, you are linking in to the resident MFC dll at runtime to access the code for some calls.

This requires the big ugly MFC dll to be loaded.

If you search in your windows or winnt directory for mfc*.dll you will find it lurking there.  its about 1 meg.

When you build without MFC support you are telling the compiler that the MFC*.dll file will not be present when the dll is used, so the compiler includes the code previously linked into the MFC dll in your dll.
Thats why it's bigger.

The previous answerer was not quite correct. The warnings are informing you that the linker no longer requires the references as the code is now built into your dll.

What this all means is:
If youre going to ship without the MFC dll and you want to build TRULY lightweight components you have to make your gui stuff either use API calls, or use something like atlcontrols.h or the windows template library.

best of luck with your ATL programming,

Robert.

0
 
LVL 1

Author Comment

by:khampton
ID: 6150453
Ok, even after the RobertMitchell response, I'm still a little fuzzy --

Am I lighter weight by not including MFC support?  My guess is that I am because I'm using only what I need and compiling it into my component RATHER that dynamically calling MFC runtime routines that may be the wrong version on the user's machine.

Also, since I built this ATL .dll from the wizard, I thought I WAS using the Windows Template Library.  Right?
0
 

Accepted Solution

by:
robertmitchell_99 earned 50 total points
ID: 6152382
Hi khampton,

Sorry if my answer was not clear enough.

You are correct in that your component is larger because you are not using MFC support as this means the code is compiled into your dll and not linked in at runtime.

My final comment about lightweight components was prompted by the fact that shell32.lib and commdlg.lib are both windows gui libraries.  I assumed that calls to these dlls were what was handled previously by MFC. Without seeing the code i can't comment more firmly on the size difference.

If you used API for your gui there should have been little or no difference in the dll size.

The Windows Template Library is a not very well supported but lightweight template library for windows gui not to be confused with ATL(Active Template Library).

This was just a suggestion to maybe help you reduce dll size. Without seeing the code of course i cant help you any further.

Good Luck

Robert.
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

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 …
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
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++.

740 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