Solved

Win32 console app and MFC library incompatible during release compile

Posted on 2015-01-10
3
211 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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
What is Python programming? 3 113
C# code editing and collaboration 3 115
How can my static class become undefined?? 8 49
backup program with robocopy 6 22
A short article about problems I had with the new location API and permissions in Marshmallow
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

809 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