• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 262
  • Last Modified:

Win32 console app and MFC library incompatible during release compile

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
TongZ
Asked:
TongZ
  • 2
1 Solution
 
QlemoC++ DeveloperCommented:
Check for Unicode, _Unicode and MBCS settings in Release. You don't have those in Debug, obviously.
0
 
TongZAuthor Commented:
@Qlemo:
I don't have _Unicode in preprocessor under either debug nor release mode.
0
 
TongZAuthor Commented:
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

Free recovery tool for Microsoft Active Directory

Veeam Explorer for Microsoft Active Directory provides fast and reliable object-level recovery for Active Directory from a single-pass, agentless backup or storage snapshot — without the need to restore an entire virtual machine or use third-party tools.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now