Solved

Win32 console app and MFC library incompatible during release compile

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

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

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

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
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…

760 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

20 Experts available now in Live!

Get 1:1 Help Now