Home c++ UnreSolved External Symbol in C++ on scratch

UnreSolved External Symbol in C++ on scratch

Author

Date

Category

In the code, there is nothing under the _dxgi_debug_all or something in this spirit, there is only dxgi_debug_all (without lower underscore). When linking in Visual Studio 2019, issues:

lnk2001 | Unresolved EXTERNAL SYMBOL _DXGI_DEBUG_ALL | Dxgiinfomanager.obj | Line: 1.
LNK2120 | 1 unresolved externals | Dxgiinfomanager.obj | Line: 1.

And that’s what you can not do, but it worst on an emphasis!

DXGIINFOMANAGER.H code:

# pragma once
#Include "Win.h"
#Include & lt; wrl.h & gt;
#Include & lt; String & GT;
#Include & lt; vector & gt;
#Include & lt; dxgidebug.h & gt;
Class dxgiinfomanager
{
Public:
  Dxgiinfomanager ();
  ~ Dxgiinfomanager ();
  Dxgiinfomanager (Const dxgiinfomanager & amp;) = delete;
  DXGIINFOMANAGER & AMP; operator = (Const dxgiinfomanager & amp;) = delete;
  void set () noexcept;
  Std :: Vector & lt; Std :: String & GT; Getmessages () const;
Private:
  unsigned long Long Next = 0u;
  Struct idxgiinfoqueue * pdxgiinfoqueue = nullptr;
};

DXGIINFOMANAGER.CPP code:

# include "dxgiinfomanager.h"
#include "Window.h"
#Include "Graphics.h"
#Include & lt; dxgidebug.h & gt;
#Include & lt; Memory & gt;
#Include & lt; dxgidebug.h & gt;
#define GFX_THROW_Noinfo (HRCALL) if (Failed (HR = (HRCALL))) Throw Graphics :: HREXCEPTION (__Line __, __ File __, HR)
DXGIINFOMANAGER :: DXGIINFOMANAGER ()
{
  // Define Function Signature Of DXGigeTDebugInterface
  TypeDef HresultDebugInterface) (Refiid, void **);
  // Load The DLL That Contains The Function DXgigetdebugIngInterface
  const auto hmoddxgidebug = LoadLibraryEx ("dxgidebug.dll", nullptr, load_library_search_dll_load_dir);
  if (hmoddxgidebug == nullptr)
  {
    Throw WND_LAST_EXCEPT ();
  }
  // get Address of dxgigetdebuginterface
  const auto dxgigetdebuginterface = reinterpret_cast & lt; dxgigetdebuginterface & gt;
    REINTERPRET_CAST & LT; Void * & GT; (GetProcaddress (Hmoddxgidebug, "dxgigetdebuginterface"))
  );
  if (dxgigetdebuginterface == nullptr)
  {
    Throw WND_LAST_EXCEPT ();
  }
  HRESULT HR;
  Gfx_throw_noinfo (__ uuidof (idxgiinfoqueue), reinterpret_cast & lt; void ** & gt; (& amp; pdxgiinfoqueue)));
}
DXGIINFOMANAGER :: ~ DXGIINFOMANAGER ()
{
}
void dxgiinfomanager :: set () noexcept
{
  // Set The Index (Next) So That The Next All to getMessage ()
  // Will Only Get Errors Generated After All
  next = pdxgiinfoqueue- & gt; getNumStoredMessages (dxgi_debug_all);
}
Std :: Vector & lt; Std :: String & GT; DXGIINFOMANAGER :: getMessages () Const
{
  Std :: Vector & lt; Std :: String & GT; Messages;
  const auto end = pdxgiinfoqueue- & gt; getNumStoredMessages (dxgi_debug_all);
  FOR (AUTO I = NEXT; I & LT; END; I ++)
  {
    HRESULT HR;
    Size_t MessageLength;
    // Get The Size Of A Messsage I in Bytes
    Gfx_throw_noinfo (PDXGIInfoqueue- & gt; GetMessage (DXGI_DEBUG_ALL, I, NULLPTR, & AMP; Messagelength));
    // Alocate Memory for Message
    Auto bytes = std :: make_unique & lt; byte [] & gt; (MessageLength);
    AUTO PMESSAGE = REINTERPRET_CAST & LT; DXGI_INFO_QUEUE_MESSAGE * & GT; (bytes.get ());
    // Get The Message and Push Its Description INTO Vector
    Gfx_throw_noinfo (PDXGIInfoqueue- & gt; GetMessage (DXGI_DEBUG_ALL, I, PMESSAGE, & AMP; MessageLength));
    Messages.Emplace_back (PMESSAGE- & GT; PDESRIFTION);
  }
  Return Messages;
}

If you need additional information, I will try to add as soon as possible 🙂


Answer 1

C / C++ x86 Global variables and “C” -functions, when broadcasting to the assembler, the “_” prefix is ​​obtained. You have a variable dxgi_debug_all apparently described as extern, but it is not placed anywhere.

That is, the variable dxgi_debug_all must be specified in some CPP file without extern


Answer 2, Authority 100%

Add dxguid.lib to the library list for links.

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions