-5

Getting the following linker error in VS 2013 C++:

Error 2 error LNK2019: unresolved external symbol "void __stdcall DbgAssert(wchar_t const *,wchar_t const *,int)" (?DbgAssert@@YGXPB_W0H@Z) referenced in function "public: __thiscall CTextureRendererLeft::CTextureRendererLeft(struct IUnknown *,long *)" (??0CTextureRendererLeft@@QAE@PAUIUnknown@@PAJ@Z) C:\Users\Kapil\Documents\Visual Studio 2013\Projects\MarkerTest\MarkerTest\Max3DCaptureVideo.obj MarkerTest

tomrozb
  • 25,773
  • 31
  • 101
  • 122
Kapil
  • 11
  • 3
  • 1
    This is such a common question on here. Have: http://stackoverflow.com/questions/5373152/linker-error-lnk2019-in-c?rq=1 http://stackoverflow.com/questions/4961678/problem-compiling-eliza-chatbot-c-error-lnk2019?rq=1 http://stackoverflow.com/questions/7318362/linker-error-lnk2019-from-3rd-party-library?rq=1 http://stackoverflow.com/questions/7828136/visual-c-lnk2019-error?rq=1 – AStopher Aug 10 '14 at 10:41
  • What's your first error? You're not giving us the whole picture here.. – AStopher Aug 10 '14 at 10:43

1 Answers1

0

DbgAssert isn't defined properly.

To fix, ensure you have #included all header files correctly, and that you are not missing any #includes. Somebody else just told me that the error can be caused by a required library not being linked, or that you've forgotten the body of DbgAssert.

It is possible to get the exact same error with this:

int myFunc();

int main()
{
    myFunc();
    return 0;
}

Official solution to your problem from MSDN (first link on Google, I might add!):

An undefined external symbol (symbol) was found in function. To resolve this error, provide a definition for symbol or remove the code that references it.

AStopher
  • 4,207
  • 11
  • 50
  • 75
  • Downvoter- explain why you downvoted. The fact that `DbgAssert` isn't defined IS the exact problem here, and I stated the resolution. – AStopher Aug 10 '14 at 11:03
  • The issue is not `#include`s, he has a symbol that is declared (if it was an undeclared symbol, then `#include`s might be the issue) but not defined. Unless by #`include`d all source files" you mean that he included the source files in the project - then that might be the issue if he has a header included from some file, but the source file associated with that header is not included in the project). That might be what you mean since you don't generally `#include` "source" files (.cpp vs .h "header" files). – Peter Clark Aug 10 '14 at 11:05
  • @PeterClark Fixed the error. – AStopher Aug 10 '14 at 11:07
  • Your edit clarified that your solution is infact not valid for this issue. See the first part of my comment "The issue is not `#include`[ing headers], he has a symbol that is declared (if it was an undeclared symbol, then `#include`[ing headers] might be the issue) but not defined.". – Peter Clark Aug 10 '14 at 11:08
  • The fact that he does not have an "undeclared identifier" error (which would be a compile error not a linker error as well), indicated he **is** including the appropriate header. He is not compiling a definition for the included symbol. – Peter Clark Aug 10 '14 at 11:11
  • 1
    @PeterClark I've had this issue before, and I fixed it by using `#include` to define a header that I missed. This is why I commented on the question asking what error #1 was (they only put the error #2), and that error could potentially aid us in answering this question properly. – AStopher Aug 10 '14 at 11:11
  • 1
    There's some side possibilities where it could have an effect, but it is likely not the root cause (only case that I can think of where it would be the root cause is if you move a template definition into another file and include that from the header file). Given these side possibilities and your edits I've removed my downvote. – Peter Clark Aug 10 '14 at 11:22
  • You shouldn't post a duplicate *and* an answer. If you feel you have new information to add which the duplicate doesn't have, then post an answer there. – JBentley Aug 10 '14 at 11:39
  • @JBentley There's no rule against this. – AStopher Aug 10 '14 at 11:51
  • 2
    @zyboxinternational It is discouraged - [*"the fundamental goal of closing duplicate questions is to help people find the right answer by getting all of those answers in one place"*](http://stackoverflow.com/help/closed-questions). Posting an answer when you are aware of a duplicate spreads the information across multiple questions (which are often heavily downvoted, as in this case), which is contrary to this goal. You'll also note that once a duplicate has been confirmed (voted for), no further answers are possible (for the same reason). – JBentley Aug 10 '14 at 14:52