Solved

ATL and MFC support

Posted on 2001-06-02
5
505 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
  • 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
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.

705 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

19 Experts available now in Live!

Get 1:1 Help Now