Connect with Expertise | Find Experts, Get Answers, Share Insights

Linker error __argv, __argc, __mbctype

Saran
 
Posts: n/a
#1: Nov 17 '05
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

Doug Harrison [MVP]
 
Posts: n/a
#2: Nov 17 '05

re: Linker error __argv, __argc, __mbctype


Saran wrote:
[color=blue]
>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?[/color]

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++
Ben Schwehn
 
Posts: n/a
#3: Nov 17 '05

re: Linker error __argv, __argc, __mbctype


> I'm getting the following linker error when I try to build a library.[color=blue]
>
> 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[/color]

Q166504 perhaps?

ben
--
http://bschwehn.de
Doug Harrison [MVP]
 
Posts: n/a
#4: Nov 17 '05

re: Linker error __argv, __argc, __mbctype


Saran wrote:
[color=blue]
>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\mana gerbase\source\Release\RSP0002F2.rsp /nologo"
>Creating temporary file "c:\viewstore\hfdebug_net_porting\nextgen\lib\mana gerbase\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\ngc ore.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.[/color]

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++
Saran
 
Posts: n/a
#5: Nov 17 '05

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:
[color=blue]
> Saran wrote:
>[color=green]
> >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\mana gerbase\source\Release\RSP0002F2.rsp /nologo"
> >Creating temporary file "c:\viewstore\hfdebug_net_porting\nextgen\lib\mana gerbase\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\ngc ore.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.[/color]
>
> 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++
>[/color]
Closed Thread