15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


Link error when using UNICODE.

Ronen Ashkenazi -- rashken@ms-israel.kla.com
Sunday, November 10, 1996


Environment:  VC++ 4.2, NT 4.0

Hi,

I have an MFC application that uses UNICODE. I defined _UNICODE in the   
beginning of StdAfx.h. At some point I started to get the following   
unresolved external symbol link error and I have no idea why:

msvcrtd.lib(crtexew.obj) : error LNK2001: unresolved external symbol   
_WinMain@16
Debug/DiagApp.exe : fatal error LNK1120: 1 unresolved externals

Its seems to be a problem with the real time library. I am using the   
sscanf function. Is there an API function or CString method that can be   
used instead of sscanf ?

Thanks,
Ronen Ashkenazi.




Mike Blaszczak -- mikeblas@nwlink.com
Sunday, November 10, 1996

At 13:08 11/10/96 PST, Ronen Ashkenazi wrote:

Environment:  VC++ 4.2, NT 4.0

Please upgrade to MFC 4.2b.  You can get it from 

>I have an MFC application that uses UNICODE. I defined _UNICODE in the   
>beginning of StdAfx.h.

You shouldn't do that: it's very unreliable. As the documentation
explains and as all the UNICODE-enabled samples demonstrate, you should
use the compiler's /D option to define _UNICODE right from the
command-line.

>At some point I started to get the following   
>unresolved external symbol link error and I have no idea why:

>msvcrtd.lib(crtexew.obj) : error LNK2001: unresolved external symbol   
>_WinMain@16
>Debug/DiagApp.exe : fatal error LNK1120: 1 unresolved externals

Odds are that you are including one of the C runtime header files
before you include STDAFX.H, and therefore are effectively trying to
link with the non-UNIOCDE version of the C runtimes startup code
while you're still getting the UNICODE version of MFC.


>Its seems to be a problem with the real time library.

I think you really mean "Runtime Library".

>I am using the sscanf function. Is there an API function
>or CString method that can be used instead of sscanf?

scanf() shouldn't be used in a UNICODE program unless, in a very
specific case, you're handling a rogue ANSI string.  You should 
use swscanf() or, preferably, _stscanf().

sscanf() is very, very flexible--you could be doing any
number of things with it.  Things that you might use to replace
sscanf() include:
       
        _ttoi()
        _ttol()
        _tsctok()
        _tscchr()
        _tscscan()
        _tcspsn()
       
in addition to any custom parsing routines you knocked out yourself.

But, again: while your use of sscanf() in a UNICODE program
seems supicious, I don't think it is causing your link problem.

.B ekiM
http://www.nwlink.com/~mikeblas/
I'm afraid I've become some sort of speed freak.
These words are my own. I do not speak on behalf of Microsoft.




Dave Ryan -- ryan@ymi.com
Monday, November 11, 1996

[Mini-digest: 2 responses]

You must also set the link option "output" to wWinMainCRTStartup as =
noted in the documentation as well as define _UNICODE with the /D =
option.

----------
From: 	Mike Blaszczak[SMTP:mikeblas@nwlink.com]
Sent: 	Sunday, November 10, 1996 4:14 PM
To: 	mfc-l@netcom.com
Subject: 	Re: Link error when using UNICODE.

At 13:08 11/10/96 PST, Ronen Ashkenazi wrote:

Environment:  VC++ 4.2, NT 4.0

Please upgrade to MFC 4.2b.  You can get it from=20

>I have an MFC application that uses UNICODE. I defined _UNICODE in the  =
=20
>beginning of StdAfx.h.

You shouldn't do that: it's very unreliable. As the documentation
explains and as all the UNICODE-enabled samples demonstrate, you should
use the compiler's /D option to define _UNICODE right from the
command-line.

>At some point I started to get the following  =20
>unresolved external symbol link error and I have no idea why:

>msvcrtd.lib(crtexew.obj) : error LNK2001: unresolved external symbol  =20
>_WinMain@16
>Debug/DiagApp.exe : fatal error LNK1120: 1 unresolved externals

Odds are that you are including one of the C runtime header files
before you include STDAFX.H, and therefore are effectively trying to
link with the non-UNIOCDE version of the C runtimes startup code
while you're still getting the UNICODE version of MFC.


>Its seems to be a problem with the real time library.

I think you really mean "Runtime Library".

>I am using the sscanf function. Is there an API function
>or CString method that can be used instead of sscanf?

scanf() shouldn't be used in a UNICODE program unless, in a very
specific case, you're handling a rogue ANSI string.  You should=20
use swscanf() or, preferably, _stscanf().

sscanf() is very, very flexible--you could be doing any
number of things with it.  Things that you might use to replace
sscanf() include:
      =20
        _ttoi()
        _ttol()
        _tsctok()
        _tscchr()
        _tscscan()
        _tcspsn()
      =20
in addition to any custom parsing routines you knocked out yourself.

But, again: while your use of sscanf() in a UNICODE program
seems supicious, I don't think it is causing your link problem.

.B ekiM
http://www.nwlink.com/~mikeblas/
I'm afraid I've become some sort of speed freak.
These words are my own. I do not speak on behalf of Microsoft.
-----From: "Dan Kirby" 

Hi,
The VC++ documentation states in the Programming Techniques book  under the
"Support for UNICODE" section:

Be sure to set wWinMainCRTStartup as the Entry Point symbol in the Output
category of the Link tab in the Project Settings dialog box.

Do this and you will see that the application links correctly. 

--dan



Brian Welsh -- WelsBR@cita.com
Monday, November 11, 1996

This one is a simple fix.

Go to Build | Settings and from your Project Settings dialog select your
Unicode configuration. Next, select the Link tab and select Output fromf
the Category dropdown. Finally in the Entry-point Symbol box enter
"wWinMainCRTStartup" (without quotes), then rebuild all.

>----------
>From: 	Ronen Ashkenazi[SMTP:rashken@ms-israel.kla.com]
>Sent: 	Sunday, November 10, 1996 3:08 PM
>To: 	'mfcl'
>Subject: 	Link error when using UNICODE.
>
>
>Environment:  VC++ 4.2, NT 4.0
>
>Hi,
>
>I have an MFC application that uses UNICODE. I defined _UNICODE in the
>beginning of StdAfx.h. At some point I started to get the following
>unresolved external symbol link error and I have no idea why:
>
>msvcrtd.lib(crtexew.obj) : error LNK2001: unresolved external symbol
>_WinMain@16
>Debug/DiagApp.exe : fatal error LNK1120: 1 unresolved externals
>
>Its seems to be a problem with the real time library. I am using the sscanf
>function. Is there an API function or CString method that can be used instead
>of sscanf ?
>
>Thanks,
>Ronen Ashkenazi.
>
>



Michael Iles -- michaeli@dra.com
Monday, November 11, 1996


> Environment:  VC++ 4.2, NT 4.0
>
> Hi,
>
> I have an MFC application that uses UNICODE. I defined _UNICODE in the   
    

> beginning of StdAfx.h. At some point I started to get the following
> unresolved external symbol link error and I have no idea why:
>
> msvcrtd.lib(crtexew.obj) : error LNK2001: unresolved external symbol
> _WinMain@16
> Debug/DiagApp.exe : fatal error LNK1120: 1 unresolved externals

Have a look at,

Q125750, "PRB: Error LNK2001: '_WinMain@16': Unresolved External Symbol"

You have to explicitly change your entry point to wWinMainCRTStartup.

Mike
(michaeli@dra.com)





| Вернуться в корень Архива |