barkhashah
asked on
error LNK2001: unresolved external symbol ___argv
Hi All,
Can anyone tell me how to resolve the following linking error:
nafxcwd.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argv
nafxcwd.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argc
nafxcwd.lib(apphelp.obj) : error LNK2001: unresolved external symbol __mbctype
nafxcwd.lib(filelist.obj) : error LNK2001: unresolved external symbol __mbctype
nafxcwd.lib(viewedit.obj) : error LNK2019: unresolved external symbol __mbctype referenced in function "protected: long __thiscall CEditView::OnFindReplaceCm d(unsigned int,long)" (?OnFindReplaceCmd@CEditVi ew@@IAEJIJ @Z)
.\Debug/XAgentISAPIExtensi on.dll : fatal error LNK1120: 3 unresolved externals
Configuration Properties are set as follows:
1) Use MFC in a shared Dll
2)Runtime library = Multi-threaded Debug DLL (/MDd)
Can anyone tell me how to resolve the following linking error:
nafxcwd.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argv
nafxcwd.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argc
nafxcwd.lib(apphelp.obj) : error LNK2001: unresolved external symbol __mbctype
nafxcwd.lib(filelist.obj) : error LNK2001: unresolved external symbol __mbctype
nafxcwd.lib(viewedit.obj) : error LNK2019: unresolved external symbol __mbctype referenced in function "protected: long __thiscall CEditView::OnFindReplaceCm
.\Debug/XAgentISAPIExtensi
Configuration Properties are set as follows:
1) Use MFC in a shared Dll
2)Runtime library = Multi-threaded Debug DLL (/MDd)
ASKER
yes i am sure i am using shared mfc libraries. Can you please make me clear about the solution you mentioned in including mfcXXd.lib.
Thanks
Thanks
project properties->linker->'Input ' page. Do you have nafcwd.lib in the 'Additional Dependencies' field? Do you have anything there?
ASKER
I dont have anything in the additional dependencies tab.
By using verbose:lib option i get to know all the libraries that application will use.
One of them is
Searching C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\lib\nafxcw d.lib:
When i have already used shared mfc debug library then how come is the vc++ compiler adding this static one.
Please tell me what to ignore and what to include in the library.
Sorry to bother you again.
By using verbose:lib option i get to know all the libraries that application will use.
One of them is
Searching C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\lib\nafxcw
When i have already used shared mfc debug library then how come is the vc++ compiler adding this static one.
Please tell me what to ignore and what to include in the library.
Sorry to bother you again.
I really don't know how that you're linking with nafcwd.lib
Try putting it in the 'Ignore specific library' field and build again.
Try putting it in the 'Ignore specific library' field and build again.
ASKER
I cant do that because i get umpteen linking errors:
LNK2001: unresolved external symbol __afxForceEXCLUDE
LNK2001: unresolved external symbol "void __stdcall AfxThrowOleException(long) " (?AfxThrowOleException@@YG XJ@Z)
error LNK2019: unresolved external symbol "void __stdcall AfxThrowMemoryException(vo id)" (?AfxThrowMemoryException@ @YGXXZ) referenced in function "void __stdcall ATL::AtlThrow(long)" (?AtlThrow@ATL@@YGXJ@Z)
LNK2001: unresolved external symbol __afxForceEXCLUDE
LNK2001: unresolved external symbol "void __stdcall AfxThrowOleException(long)
error LNK2019: unresolved external symbol "void __stdcall AfxThrowMemoryException(vo
do you have defined _AFXDLL in your 'Preprocessor definitions' under C++ page?
ASKER
NO. I tried putting this also but to no avail.
Can you just build a new MFC dll project with your desired settings and then add all your files (re/sources, headers, etc) in it?
I'm clueless right now...
hmm, how did exactly you get this linker error? I mean after what operation
did your dll ever linked errorless?
I'm clueless right now...
hmm, how did exactly you get this linker error? I mean after what operation
did your dll ever linked errorless?
ASKER
okay i will do . I am myself lost as to when i started getting this linking error.
Let me make a fresh application and try my hands out.
Thanks very much for your help.
Let me make a fresh application and try my hands out.
Thanks very much for your help.
ASKER
I have a dll with following settings:
Use of MFC: Use standard windows library
When i compile and link the application, everything runs successfully.
Now i change the settings as follows:
Use of MFC: Use MFC in a shared Dll
I get the following linking error:
IsapiRequest.obj : error LNK2019: unresolved external symbol __imp__RevertToSelf@0 referenced in function "public: int __thiscall ISAPI_REQUEST::Unimpersona teClient(v oid)" (?UnimpersonateClient@ISAP I_REQUEST@ @QAEHXZ)
IsapiRequest.obj : error LNK2019: unresolved external symbol __imp__SetThreadToken@8 referenced in function "public: int __thiscall ISAPI_REQUEST::Impersonate Client(voi d)" (?ImpersonateClient@ISAPI_ REQUEST@@Q AEHXZ)
I then go to the code and comment these functions and run them again with the later settings.
To my surprise the code compiles successfully even with the later settings. Now this function is not using any thing new( MFC based) that other functions in the code using .
????????
Use of MFC: Use standard windows library
When i compile and link the application, everything runs successfully.
Now i change the settings as follows:
Use of MFC: Use MFC in a shared Dll
I get the following linking error:
IsapiRequest.obj : error LNK2019: unresolved external symbol __imp__RevertToSelf@0 referenced in function "public: int __thiscall ISAPI_REQUEST::Unimpersona
IsapiRequest.obj : error LNK2019: unresolved external symbol __imp__SetThreadToken@8 referenced in function "public: int __thiscall ISAPI_REQUEST::Impersonate
I then go to the code and comment these functions and run them again with the later settings.
To my surprise the code compiles successfully even with the later settings. Now this function is not using any thing new( MFC based) that other functions in the code using .
????????
ASKER
Ah! These 2 functions are further returning a parameter by calling a function in winbase.h whose calling convention is __stdcall. However, in my application the project settings are __cdecl (/Gd).
Is there any clue you get?????
Is there any clue you get?????
So what's the question?
ASKER
Suppose there is a function whose calling convention is __cdecl
.
This function returns with another function whose calling convention is __stdcall.
This leads to a linking error.
How do i make the first function's convention changed to the __stdcall.
Ex:
int fun() // calling convention __cdecl
{
return abc() // calling convention __stdcall ( windows function defined in winbase.h
}
.
This function returns with another function whose calling convention is __stdcall.
This leads to a linking error.
How do i make the first function's convention changed to the __stdcall.
Ex:
int fun() // calling convention __cdecl
{
return abc() // calling convention __stdcall ( windows function defined in winbase.h
}
try changing to /Gz
Are you sure you link against Advapi32.lib ?
That's where RevertToSelf and SetThreadToken are
That's where RevertToSelf and SetThreadToken are
ASKER
Hey how did you come to know that my application is finally calling RevertToSelf and SetThreadToken functions.
Magic! :)
You said that:
>IsapiRequest.obj : error LNK2019: unresolved external symbol __imp__RevertToSelf@0 referenced in function "public: int >__thiscall ISAPI_REQUEST::Unimpersona teClient(v oid)" (?UnimpersonateClient@ISAP I_REQUEST@ @QAEHXZ)
You said that:
>IsapiRequest.obj : error LNK2019: unresolved external symbol __imp__RevertToSelf@0 referenced in function "public: int >__thiscall ISAPI_REQUEST::Unimpersona
ASKER
My problem is solved by adding Advapi32.lib in the settings.
This is great. Thanks very much.
This is great. Thanks very much.
Great!
ASKER
Good catch. Thanks again
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Are you sure that you're usein MFC in a shared DLL? Have you changed your project setting from static MFC to shared?
If so, in the linker settings for your project, if you have nafxcwd.lib, change it to mfcXXd.lib