Jump to content
  • Advertisement
Sign in to follow this  

LNK2019: Unresolved external symbol from a function within a function

This topic is 2836 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Here's the code:

bool InitDirect3D(HWND hWnd, int width, int height, ID3D10Device* pDevice, IDXGISwapChain* pSwapChain, ID3D10RenderTargetView* pTarget)
ZeroMemory(&SwapChain, sizeof(DXGI_SWAP_CHAIN_DESC));
SwapChain.BufferCount = 1;
SwapChain.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
SwapChain.BufferDesc.Height = height;
SwapChain.BufferDesc.RefreshRate.Denominator = 1;
SwapChain.BufferDesc.RefreshRate.Numerator = 60;
SwapChain.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
SwapChain.BufferDesc.Width = width;
SwapChain.Flags = NULL;
SwapChain.OutputWindow = hWnd;
SwapChain.SampleDesc.Count = 1;
SwapChain.SampleDesc.Quality = 0;
SwapChain.Windowed = TRUE;

HRESULT hResult = D3D10CreateDeviceAndSwapChain( NULL,
if (FAILED(hResult))
MessageBox(NULL, TEXT("Error: D3D10CreateDeviceAndSwapChain() failed. Hard one, indeed."), TEXT("Error!"), MB_OK);
return false;
ID3D10Texture2D* pBackBuffer;
hResult = pSwapChain->GetBuffer(0, __uuidof(ID3D10Texture2D), (LPVOID*)&pBackBuffer);
if (FAILED(hResult))
MessageBox(NULL, TEXT("Error: GetBuffer() failed. Can't get back buffer."), TEXT("Error!"), MB_OK);
return false;
hResult = pDevice->CreateRenderTargetView(pBackBuffer, NULL, &pTarget);
if (FAILED(hResult))
MessageBox(NULL, TEXT("Error: CreateRenderTargetView() failed. Something's wrong with the back buffer."), TEXT("Error!"), MB_OK);
return false;
pDevice->OMSetRenderTargets(1, &pTarget, NULL);

D3D10_VIEWPORT viewport;
viewport.Height = height;
viewport.MaxDepth = 1.0f;
viewport.MinDepth = 0.0f;
viewport.TopLeftX = 0;
viewport.TopLeftY = 0;
viewport.Width = width;
pDevice->RSSetViewports(1, &viewport);
return true;

And here's a picture:


I tried to make 3 global variables ID3D10Device, IDXGISwapChain and ID3D10RenderTargetView into a local variable, which is shown in the code at the top. And whether those 3 variables are either global, or local, I still get the same LNK2019 errors. How can I get rid of it?

Note that:
1. windows.h is included.
2. d3d10.h is included.
3. d3dx10.h is included.
4. a small window application works if InitDirect3D() (The code at top) is disabled (commented out, etc.). That means all the rest of my code are working normally.
5. The errors only mentioned InitDirect3D() and D3D10CreateDeviceAndSwapChain(), and nothing else.

I hate LNK2019 errors. /VERBOSE, undname.exe, and DUMPBIN.exe just don't seem to give more hints to it. (Especially the undname.exe, the function name is already undecorated in the error list, within the parentheses).

Share this post

Link to post
Share on other sites

Are you linking against d3d10.lib (and if you use any of the D3DX... functions d3dx10.lib)?

Yes, I did. It's still the same.



I went around and looked for some clues, and couldn't find anything. People made suggestions, but rechecking it, I have what they suggested already. The Library files are included already, directory came up correct, anything else I missed?

Share this post

Link to post
Share on other sites
Don't know if it's applicable (or if it makes a difference): you're in debug mode and linking the release libraries. Try linking to d3dx10d.lib instead of d3dx10.lib.

Share this post

Link to post
Share on other sites
Another Google search reveals that when you add a directory to the project properties, especially the library folder, you included all of the library files in that folder. So, adding library files in the "Additional Dependencies" itself is rendered useless, or duplicate of the above settings.

After more searching, I see that DirectX programs are commonly developed in x86 environment. I thought, hm, my operating system is Windows 7 x64, why would I try adding an x86 to the directory when my environment is x64? I'd give it a shot.

So I did, and I run/debug my program, and guess what? It worked.

So, I should ask Microsoft and heed them to add a notice, that the x64 library folder must [color="#ff0000"]depend on x86 library folder. That is, x64 LIB files depend on x86 LIB files, which if not included in the directories of the project properties, it wil cause this LNK2019 error.

Can anyone agree with me?

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!