Linker error __argv, __argc, __mbctype

G

Guest

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?
 
D

Doug Harrison [MVP]

Saran said:
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.
 
B

Ben Schwehn

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
 
D

Doug Harrison [MVP]

Saran said:
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.
 
G

Guest

Hi Doug,

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

Thanks for your help.

--
Thanks much
Saran


Doug Harrison said:
Saran said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top