-3

this is the error i am getting

Error   13  error LNK2019: unresolved external symbol "public: bool
__thiscall ConfigInfo::GetDefaultTargetConfigSettings(class ATL::CStringT<char,class StrTraitMFC_DLL<char,class ATL::ChTraitsCRT<char> > > const &,class CAdsTargetEditDlg &)" (?GetDefaultTargetConfigSettings@ConfigInfo@@QAE_NABV?$CStringT@DV?$StrTraitMFC_DLL@DV?$ChTraitsCRT@D@ATL@@@@@ATL@@AAVCAdsTargetEditDlg@@@Z) referenced in function "struct IADsUser * __cdecl __GetAdsUser(wchar_t const *,wchar_t const *)" (?__GetAdsUser@@YAPAUIADsUser@@PB_W0@Z)    AdsUser.obj
Onkar Nirhali
  • 216
  • 2
  • 8
  • 2
    Linker errors are almost always unrelated to header files. Linker errors usually is because you forgot to link with some source-, object- or library-file. Or because you forgot to define (implement) some functions, or you [define templated functions in source files instead of header files](https://stackoverflow.com/questions/495021/why-can-templates-only-be-implemented-in-the-header-file). – Some programmer dude Sep 25 '19 at 11:21
  • Is the function defined in your .cpp file? – Kiran Thilak Sep 25 '19 at 11:23
  • yes, but in other file i.e the header file So i have added #include config.h file has been added with its path config.h file has the function in it Am i doing it the right way? – Onkar Nirhali Sep 25 '19 at 11:31
  • show what you added in config.cpp – RoQuOTriX Sep 25 '19 at 11:32
  • Please produce a minimal compiling (not linking obviously) example. It is hard to say what is wrong in code without seeing the code. – Fëamarto Sep 25 '19 at 11:35
  • Please create a [mcve] to show us. What is this "config.h" file? What does it contain? How do you use the code in that header file? Where are the ***implementation*** of the functions declared in the header file? How do you build? What files are you building with? – Some programmer dude Sep 25 '19 at 11:37
  • bool ConfigInfo::GetDefaultTargetConfigSettings(const CString &Module, CAdsTargetEditDlg &dlg) this is how the funtion starts in config.cpp config.cpp is located in ADSReset Project of ADSModule solution and I have linked the config.h as the header file in ADSUser.cpp where the error is present. ADSUser.cpp is present in ADSModule project of the same solution – Onkar Nirhali Sep 25 '19 at 11:50
  • 2
    @OnkarNirhali Don't describe the code. Show the code. You have been asked to provide [mcve] multiple times, why haven't you done so? – Algirdas Preidžius Sep 25 '19 at 12:17
  • 1
    Possible duplicate of [What is an undefined reference/unresolved external symbol error and how do I fix it?](https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – Toby Speight Sep 25 '19 at 14:34

1 Answers1

0

Lets try to teach you to read the error you're getting.

The process of compilation in C++ is split into 2 parts: Compile your code (.cpp files) into object (.obj) files. This part is successful. Once that's done, the .obj files are handed off to what's called the linker, which is essentially responsible for taking all of the relevant components in the .obj files and hooking them all together in your .exe file. This is where the error is.

So lets take a look at the error you're getting:

Error   13  error LNK2019: unresolved external symbol "public: bool
__thiscall ConfigInfo::GetDefaultTargetConfigSettings(class ATL::CStringT<char,class StrTraitMFC_DLL<char,class ATL::ChTraitsCRT<char> > > const &,class CAdsTargetEditDlg &)" (?GetDefaultTargetConfigSettings@ConfigInfo@@QAE_NABV?$CStringT@DV?$StrTraitMFC_DLL@DV?$ChTraitsCRT@D@ATL@@@@@ATL@@AAVCAdsTargetEditDlg@@@Z) referenced in function "struct IADsUser * __cdecl __GetAdsUser(wchar_t const *,wchar_t const *)" (?__GetAdsUser@@YAPAUIADsUser@@PB_W0@Z)    AdsUser.obj

The first part Error 13 error LNK2019: unresolved external symbol says that the linker was looking for something, but wasn't able to find it in any of the object files.

The first quoted string public: bool __thiscall ConfigInfo::GetDefaultTargetConfigSettings(class ATL::CStringT<char,class StrTraitMFC_DLL<char,class ATL::ChTraitsCRT<char> > > const &,class CAdsTargetEditDlg &) is the signature or declaration of what (a function) it's looking for, but can't find.

The part that follows the string in parenthesis is essentially an alternate form of the same thing, I suspect some people are really familiar with that format... but it's really of no use to most people.

After the parenthesis it says referenced in function followed by another quoted string struct IADsUser * __cdecl __GetAdsUser(wchar_t const *,wchar_t const *). The second quoted string is the signature of the function that is calling the missing one.

So, all together this error says 'Hey, function "IADsUser* GetAdsUser(wchar_t const *,wchar_t const *)" is looking for a function "bool ConfigInfo::GetDefaultTargetConfigSettings(class ATL::CStringT > > const &,class CAdsTargetEditDlg &)" but I can't find it.'

Because it made it to the linker stage, we know the function declaration is included in the header file(functions won't compile if they can't find a valid declaration)... but it's not in any of the object files. That means it was declared, but never defined. You've either got a call somewhere in GetAdsUser to ConfigInfo::GetDefaultTargetConfigSettings that is bad or you're missing the definition/body of the function somewhere.

Learning to read the errors you're getting in extremely important.

Darinth
  • 511
  • 3
  • 14