?
Solved

Win32 console app and MFC library incompatible during release compile

Posted on 2015-01-10
3
Medium Priority
?
237 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 70

Accepted Solution

by:
Qlemo earned 2000 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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
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 viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

770 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