PC Review


Reply
Thread Tools Rate Thread

Linker error __argv, __argc, __mbctype

 
 
=?Utf-8?B?U2FyYW4=?=
Guest
Posts: n/a
 
      3rd Aug 2004
Hi All,

I'm getting the following linker error when I try to build a library.

nafxcw.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argv
nafxcw.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argc
nafxcw.lib(apphelp.obj) : error LNK2001: unresolved external symbol __mbctype
nafxcw.lib(filelist.obj) : error LNK2019: unresolved external symbol __mbctype referenced in function "void __stdcall _AfxAbbreviateName(char *,int,int)" (?_AfxAbbreviateName@@YGXPADHH@Z)

1) Use MFC in a shared DLL
2) Multi-Threaded DLL

I'm using VC++ .NET 2003. It is compiling without any error in VC++ 6 (We are in the process of proting to .NET)

Can any one help me in resolving the errors?

--
Thanks much
Saran
 
Reply With Quote
 
 
 
 
Doug Harrison [MVP]
Guest
Posts: n/a
 
      3rd Aug 2004
Saran wrote:

>Hi All,
>
>I'm getting the following linker error when I try to build a library.
>
>nafxcw.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argv
>nafxcw.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argc
>nafxcw.lib(apphelp.obj) : error LNK2001: unresolved external symbol __mbctype
>nafxcw.lib(filelist.obj) : error LNK2019: unresolved external symbol __mbctype referenced in function "void __stdcall _AfxAbbreviateName(char *,int,int)" (?_AfxAbbreviateName@@YGXPADHH@Z)
>
>1) Use MFC in a shared DLL
>2) Multi-Threaded DLL
>
>I'm using VC++ .NET 2003. It is compiling without any error in VC++ 6 (We are in the process of proting to .NET)
>
>Can any one help me in resolving the errors?


If you look inside <afx.h>, you'll find:

#ifndef _AFXDLL
#ifndef _UNICODE
#ifdef _DEBUG
#pragma comment(lib, "nafxcwd.lib")
....

So it appears that for some reason, _AFXDLL is not #defined, so the static
MFC library is selected. You should look at the preprocessor settings for
your project and make sure this symbol is listed there.

--
Doug Harrison
Microsoft MVP - Visual C++
 
Reply With Quote
 
Ben Schwehn
Guest
Posts: n/a
 
      3rd Aug 2004
> I'm getting the following linker error when I try to build a library.
>
> nafxcw.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argv
> nafxcw.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argc
> nafxcw.lib(apphelp.obj) : error LNK2001: unresolved external symbol __mbctype
> nafxcw.lib(filelist.obj) : error LNK2019: unresolved external symbol __mbctype referenced in function "void __stdcall _AfxAbbreviateName(char *,int,int)" (?_AfxAbbreviateName@@YGXPADHH@Z)
>
> 1) Use MFC in a shared DLL
> 2) Multi-Threaded DLL


Q166504 perhaps?

ben
--
http://bschwehn.de
 
Reply With Quote
 
Doug Harrison [MVP]
Guest
Posts: n/a
 
      4th Aug 2004
Saran wrote:

>Hi Doug,
>
>I checked the project settings and it seems that it already got it from inherited value but when I built it, it didn't show up in the log. So I tried to add it to preprocessor definition for the project and still didn't show up in the log. Finally I added it to individual file setting to see it in the logfile but still got the same linker errors.
>
>Here is the log:
>
>/I ".." /I "../.." /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MANAGERBASE_EXPORTS" /D "NOMINMAX" /D "PC_ANSOFT" /D "_AFXDLL" /FD /EHsc /MD /GR /Fp".\Release/managerbase.pch" /Fo".\Release/" /Fd".\Release/" /W3 /c
>.\SolveSetupMgr.cpp
>.\SolveSetupCmdInfo.cpp
>.\SolveSetup.cpp
>.\ManagerBase.cpp
>]
>Creating command line "cl.exe @c:\viewstore\hfdebug_net_porting\nextgen\lib\managerbase\source\Release\RSP0002F2.rsp /nologo"
>Creating temporary file "c:\viewstore\hfdebug_net_porting\nextgen\lib\managerbase\source\Release\RSP0002F3.rsp" with contents
>[
>/OUT:".\../../../Release/managerbase.dll" /INCREMENTAL:NO /NOLOGO /DLL /NODEFAULTLIB:"nafxcw.lib msvcrt.lib" /PDB:".\../../../Release/managerbase.pdb" /IMPLIB:".\../../../Release/managerbase.lib" /MACHINE:X86 nafxcw.lib msvcrt.lib \viewstore\hfdebug_net_porting\nextgen\Release\ngcore.lib
>.\Release\ManagerBase.obj
>.\Release\SolveSetup.obj
>.\Release\SolveSetupCmdInfo.obj
>.\Release\SolveSetupMgr.obj
>]
>
>Actually I added nafxcw.lib msvcrt.lib to get rid of several linker errors. I also confirmed that ngcore.lib has _AFXDLL defined.


Try getting rid of these parts of the linker command:

/NODEFAULTLIB:"nafxcw.lib msvcrt.lib"
nafxcw.lib msvcrt.lib

If that doesn't help, see if the linker /VERBOSE switch sheds any light.

--
Doug Harrison
Microsoft MVP - Visual C++
 
Reply With Quote
 
=?Utf-8?B?U2FyYW4=?=
Guest
Posts: n/a
 
      4th Aug 2004
Hi Doug,

Removing nafxcw.lib and adding msvrt.lib helped solve the problem.

Thanks for your help.

--
Thanks much
Saran


"Doug Harrison [MVP]" wrote:

> Saran wrote:
>
> >Hi Doug,
> >
> >I checked the project settings and it seems that it already got it from inherited value but when I built it, it didn't show up in the log. So I tried to add it to preprocessor definition for the project and still didn't show up in the log. Finally I added it to individual file setting to see it in the logfile but still got the same linker errors.
> >
> >Here is the log:
> >
> >/I ".." /I "../.." /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MANAGERBASE_EXPORTS" /D "NOMINMAX" /D "PC_ANSOFT" /D "_AFXDLL" /FD /EHsc /MD /GR /Fp".\Release/managerbase.pch" /Fo".\Release/" /Fd".\Release/" /W3 /c
> >.\SolveSetupMgr.cpp
> >.\SolveSetupCmdInfo.cpp
> >.\SolveSetup.cpp
> >.\ManagerBase.cpp
> >]
> >Creating command line "cl.exe @c:\viewstore\hfdebug_net_porting\nextgen\lib\managerbase\source\Release\RSP0002F2.rsp /nologo"
> >Creating temporary file "c:\viewstore\hfdebug_net_porting\nextgen\lib\managerbase\source\Release\RSP0002F3.rsp" with contents
> >[
> >/OUT:".\../../../Release/managerbase.dll" /INCREMENTAL:NO /NOLOGO /DLL /NODEFAULTLIB:"nafxcw.lib msvcrt.lib" /PDB:".\../../../Release/managerbase.pdb" /IMPLIB:".\../../../Release/managerbase.lib" /MACHINE:X86 nafxcw.lib msvcrt.lib \viewstore\hfdebug_net_porting\nextgen\Release\ngcore.lib
> >.\Release\ManagerBase.obj
> >.\Release\SolveSetup.obj
> >.\Release\SolveSetupCmdInfo.obj
> >.\Release\SolveSetupMgr.obj
> >]
> >
> >Actually I added nafxcw.lib msvcrt.lib to get rid of several linker errors. I also confirmed that ngcore.lib has _AFXDLL defined.

>
> Try getting rid of these parts of the linker command:
>
> /NODEFAULTLIB:"nafxcw.lib msvcrt.lib"
> nafxcw.lib msvcrt.lib
>
> If that doesn't help, see if the linker /VERBOSE switch sheds any light.
>
> --
> Doug Harrison
> Microsoft MVP - Visual C++
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Linker error Jack Microsoft VC .NET 3 27th Feb 2008 02:34 AM
Linker Error Joel Whitehouse Microsoft VC .NET 4 20th Jul 2005 07:28 PM
Linker error when using VC7 Deepa via .NET 247 Microsoft VC .NET 3 30th Aug 2004 11:20 PM
linker error with 'new' Ffelagund Microsoft Dot NET Framework 3 1st Mar 2004 08:32 PM
LINKER error Itay_k Microsoft VC .NET 0 12th Jul 2003 08:09 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:40 AM.