PC Review Forums Newsgroups Microsoft DotNet Microsoft VC .NET Linker error __argv, __argc, __mbctype



Reply

Linker error __argv, __argc, __mbctype

 
Thread Tools Rate Thread
Old 03-08-2004, 10:19 PM   #1
=?Utf-8?B?U2FyYW4=?=
Guest
 
Posts: n/a
Default Linker error __argv, __argc, __mbctype

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
Old 03-08-2004, 10:43 PM   #2
Doug Harrison [MVP]
Guest
 
Posts: n/a
Default Re: Linker error __argv, __argc, __mbctype

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
Old 03-08-2004, 10:49 PM   #3
Ben Schwehn
Guest
 
Posts: n/a
Default Re: Linker error __argv, __argc, __mbctype

> 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
Old 04-08-2004, 05:00 PM   #4
Doug Harrison [MVP]
Guest
 
Posts: n/a
Default Re: Linker error __argv, __argc, __mbctype

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
Old 04-08-2004, 07:03 PM   #5
=?Utf-8?B?U2FyYW4=?=
Guest
 
Posts: n/a
Default Re: Linker error __argv, __argc, __mbctype

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off