100分修改错误://unresolved external symbol _WinMain@16 referenced

teal 2004-04-14 08:25:32
一个奇怪的问题:
当设置configuration\ c/c++ \ preprocesor\ preprocessor definition:
为: WIN32;_WINDOWS;_DEBUG的时候,编译连接都没有错误。但是
当我在后面增加一项UNICODE 为;WIN32;_WINDOWS;_DEBUG;UNICODE 的时候,出现了下面的错误,请问这是怎么回事,我需要怎么修改??
我需要UNICODE 这一项:

config error LNK2019: unresolved external symbol _WinMain@16 referenced in function _WinMainCRTStartup
config fatal error LNK1120: 1 unresolved externals
...全文
1229 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
薛定谔之死猫 2004-04-15
  • 打赏
  • 举报
回复
mark
KyoUs 2004-04-15
  • 打赏
  • 举报
回复
在link中,Category选output,将Entry-Point Symbol设为wWinMainCRTStartup

就行了~~~
社会栋梁 2004-04-15
  • 打赏
  • 举报
回复
project-->setting中
C/C++ project option _windows改成_console
Link project option /subsystem:windows 改成console
社会栋梁 2004-04-14
  • 打赏
  • 举报
回复
gz
xstring 2004-04-14
  • 打赏
  • 举报
回复
在你的主.cpp文件中加上这样几行

#ifdef UNICODE
#pragma comment (linker, "/ENTRY:wWinMainCRTStartup")
#else
#pragma comment (linker, "/ENTRY:WinMainCRTStartup")
#endif

byf2002 2004-04-14
  • 打赏
  • 举报
回复
帮你顶
ColderRain 2004-04-14
  • 打赏
  • 举报
回复
Unicode Programming Summary

Define _UNICODE.
Define the symbol _UNICODE before you build your program.

Specify entry point.
In the Output category of the Link tab in the Project Settings dialog box, set the Entry Point Symbol to wWinMainCRTStartup.

Use “portable” run-time functions and types.
Use the proper C run-time functions for Unicode string handling. You can use the wcs family of functions, but you may prefer the fully “portable” (internationally enabled) _TCHAR macros. These macros are all prefixed with _tcs; they substitute, one for one, for the str family of functions. These functions are described in detail in the Internationalization section of the Run-Time Library Reference. For more information, see Generic-Text Mappings in TCHAR.H.

Use _TCHAR and the related portable data types described in Support for Unicode.

Handle literal strings properly.
The Visual C++ compiler interprets a literal string coded as

L"this is a literal string"

to mean a string of Unicode characters. You can use the same prefix for literal characters. Use the _T macro to code literal strings generically, so they compile as Unicode strings under Unicode or as ANSI strings (including MBCS) without Unicode. For example, instead of:

pWnd->SetWindowText( “Hello” );

use:

pWnd->SetWindowText( _T(“Hello”) );

With _UNICODE defined, _T translates the literal string to the L-prefixed form; otherwise, _T translates the string without the L prefix.

Tip The _T macro is identical to the _TEXT macro.

Be careful passing string lengths to functions.
Some functions want the number of characters in a string; others want the number of bytes. For example, if _UNICODE is defined, the following call to a CArchive object will not work (str is a CString):

archive.Write( str, str.GetLength( ) ); // invalid

In a Unicode application, the length gives you the number of characters but not the correct number of bytes, since each character is two bytes wide. Instead, you must use:

archive.Write( str, str.GetLength( ) * sizeof( _TCHAR ) ); // valid

which specifies the correct number of bytes to write.

However, MFC member functions that are character-oriented, rather than byte-oriented, work without this extra coding:

pDC->TextOut( str, str.GetLength( ) );

CDC::TextOut takes a number of characters, not a number of bytes.

To summarize, MFC and the run-time library provide the following support for Unicode programming under Windows NT:

Except for database class member functions, all MFC functions are Unicode-enabled, including CString. CString also provides Unicode/ANSI conversion functions.


The run-time library supplies Unicode versions of all string-handling functions. (The run-time library also supplies “portable” versions suitable for Unicode or for MBCS. These are the _tcs macros.)


TCHAR.H supplies portable data types and the _T macro for translating literal strings and characters. See Generic-Text Mappings in TCHAR.H.


The run-time library provides a wide-character version of main. Use wmain to make your application “Unicode-aware.”
teal 2004-04-14
  • 打赏
  • 举报
回复
我是在vc.net 环境下面写MFC 程序
_foo 2004-04-14
  • 打赏
  • 举报
回复
直接用_tWinMain不好吗?
bluebohe 2004-04-14
  • 打赏
  • 举报
回复
注意调试UNICODE程序时,需要在安装时VC选择所有选项,否则会缺少动态库和相应的.lib文件
bluebohe 2004-04-14
  • 打赏
  • 举报
回复
0).1.改语言定义:
在project settings的"C++"页中的"preprocessor definitions"中改_MBCS为_UNICODE
(0).2.改入口函数:
在"link"页中的"project Options"加入/entry:"wWinMainCRTStartup"
即可.
xstring 2004-04-14
  • 打赏
  • 举报
回复

将你的WinMain改成wWinMain就可以了

UNICODE的windows application入口不能是WinMain,只能是wWinMain

或者你可以加上一个宏

#if defined(UNICODE) || defined (_UNICODE)
#define WinMain wWinMain
#endif

16,466

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧