Solved

Win32 console app and MFC library incompatible during release compile

Posted on 2015-01-10
3
215 Views
Last Modified: 2015-01-10
I have a win32 console application that uses some MFC functions (Cobject, Cstring etc), it compiles and runs without problem under debug mode using the following configs:

Configuration: Active(Debug) Platform: Active(Win32)
General->Use of MFC->Use MFC in a Static Library
C/C++->Code Generation->Runtime Library:Multi-threaded Debug DLL(/MDd)
However, when I tried to compile for Release mode (still Win32 platform) using the following configs, it starts to have problems:

Configuration: Active(Release) Platform: Active(Win32)
General->Use of MFC->Use MFC in a Static Library
C/C++->Code Generation->Runtime Library: Multi-threaded (/MT)
The problem is with the conversion between MFC's 'wchar_t *' to 'char *' and string literals to 'LPCTSTR' etc. But such problem is not happening when I compile it for 'Debug'!!!

I know I can employ things like the _T macro etc, but there are so many of them and these clearly worked under debug mode, so I am really hoping it just some simple flag(s) that I change in the properties to make it work for 'Release' mode compilation. Help?
0
Comment
Question by:TongZ
  • 2
3 Comments
 
LVL 69

Accepted Solution

by:
Qlemo earned 500 total points
ID: 40542386
Check for Unicode, _Unicode and MBCS settings in Release. You don't have those in Debug, obviously.
0
 

Author Comment

by:TongZ
ID: 40542515
@Qlemo:
I don't have _Unicode in preprocessor under either debug nor release mode.
0
 

Author Closing Comment

by:TongZ
ID: 40542723
In Visual Studio VC++ 2008, under debug mode, for Configuration Properties -> General -> Project Defaults -> Character Set property, it is 'Use Multi-Byte Character Set'

However, when i change compile mode to 'Release', it automatically changes that setting to 'Use Unicode Character Set'. Thus, creating incompatibility between MFC string classes and functions with normal string, i.e. char *

So, after i change to 'Release' mode, I made sure the Character Set property is Use Multi-byte character set. The project compiled successfully.

Also, since I have MFC class and functions in project, the 'Use of MFC' setting is 'Use MFC in a Static Library' to ensure necessary libraries are included.
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

861 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