Sign in to follow this  
Mizipzor

MFC question

Recommended Posts

Hi there... Ive spent some time learning c++, Ive been coding in console but now I want to move on into real windows apps. Im trying to get my head around this MFC concept. Im using Microsoft Visual C++ 6.0 compiler and the code works if the compiler is set to debug mode. But if I then give the .exe to my friends who wants to try it out the program complains about missing DLL's. I think I need to set the compiler to release mode but if I do, it complains about not being able to find a .lib file. Dont remember which, Im at school now. I think thats pretty much all the information Im able to give, is there anyone who knows whats going on? And what I should do about it?

Share this post


Link to post
Share on other sites
You should never distribure debug builds of your projects, one reason is that they link to debug versions of the runtime libraries which won't be present on the average users computer so chances are the program won't run anyway.

If you can post more specific details about the errors you are getting then we can help you better than making educated guesses as to whats wrong.

Share this post


Link to post
Share on other sites
[edit] Ehhh... all you have to do is step 2 & 3 below. I thought you were saying that the other people couldn't use the program. After that it should compile just fine. When you do so, the other problem will also be solved.[smile]


Well here's what you need to do. If you have VS6, you can use the "Dependency Walker" -> "X:\Program Files\Microsoft Visual Studio\Common\Tools\DEPENDS.EXE" to see ehat .dlls you will need. However, I would suggest changing the project properties to use MFC in a static lib rather than dynamic. It will save you a lot of time and space! I know this because on my current audio lib demo, I used MFC as the GUI. At first I had used .dll's and everything ended up being around 2MB. It compressed down to around 1mb, but that was still a lot. I switched over the static lib, and it was much smaller! It is now around 488kb, but 200 of that is from OGG-Vorbis.

Here's what you should do now:

1. Switch to Release Mode and use the "Dependecny Walker" to know what .dlls you will need.
- I just made a test MFC program in vs6 and it says that I need "MFC42.DLL".
2. Now switch the project to use MFC as a Static Linked library
- To do this go to "Project->Settings->General Tab". Make sure it says "Microsoft Foundation Classes" -> Use MFC in a Static Library
3. Rebuild your release version
4. Use the Walker again and now see that it makes no reference to MFC

Now you should be able to distribute with no problems. I hope this helps, if you run into any troubles feel free to ask. One thing I do want to warn you of is that MFC is a pain to work with, although really awesome for GUI's. It breaks very very easily and for the dumbest reasons too. Keep that in mind if you run into other problems. I've had to redo entire projects becauase the MFC project simply just stopped working when I added a control. It's very sensitive to chagnes...So if your code should be working and it doesn't, try it in console to see if it's MFC or your code. (Lesson learned from testing audio library right now)

- Drew

Share this post


Link to post
Share on other sites
Just one quick question, in "Microsoft Foundation Classes" I only got; "Use MFC in a Shared DLL" and "Not Using MFC".

Now Im pretty lost here, I want to change so it says a dynamic library but obviously i cant. Any ideas why?

Thanks for the help so far. :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this