Jump to content
  • Advertisement
Sign in to follow this  
zee_ola05

LNK2019 error again :(

This topic is 2602 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


#include <Windows.h>
#include <D3D10.h>
#include <D3DX10.h>
#include "Misc.h"


HWND ghMainWnd = NULL;

bool InitWindowsApp(HINSTANCE instanceHandle, int show);
int Run();
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR pCmdLine, int nShowCmd)
{
if(!InitWindowsApp(hInstance, nShowCmd))
{
return 0;
}

return Run();
}

bool InitWindowsApp(HINSTANCE instanceHandle, int show)
{
int clientWidth = 640;
int clientHeight = 480;
HRESULT hr;

WNDCLASS wc;

//Fill in the wc struct
memset(&wc, 0, sizeof(wc));
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hInstance = instanceHandle;
wc.lpfnWndProc = WndProc;
wc.lpszClassName = L"BasicWndClass";
wc.lpszMenuName = NULL;
wc.style = CS_HREDRAW | CS_VREDRAW;

//Register Class
if(!RegisterClass(&wc))
{
ErrorExit(TEXT("RegisterClass"));
return false;
}

RECT rect = {0,0,clientWidth, clientHeight};
AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, false);

//Create Window
ghMainWnd = CreateWindow(L"BasicWndClass", L"Win32Basic", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, rect.right - rect.left, rect.bottom - rect.top, NULL, NULL, instanceHandle, NULL);
if(ghMainWnd == NULL)
{
ErrorExit(TEXT("CreateWindow"));
return false;
}

ShowWindow(ghMainWnd, show);
UpdateWindow(ghMainWnd);

/*D3D Initialization*/
DXGI_SWAP_CHAIN_DESC sd;
sd.BufferDesc.Width = clientWidth;
sd.BufferDesc.Height = clientHeight;
sd.BufferDesc.RefreshRate.Numerator = 60;
sd.BufferDesc.RefreshRate.Denominator = 1;
sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
sd.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
sd.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;

sd.SampleDesc.Count = 1;
sd.SampleDesc.Quality = 0;

sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
sd.BufferCount = 1;
sd.OutputWindow = ghMainWnd;
sd.Windowed = true;
sd.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
sd.Flags = 0;

/*Error Here*/
IDXGISwapChain * mSwapChain;
ID3D10Device * md3dDevice;
D3D10CreateDeviceAndSwapChain(NULL, D3D10_DRIVER_TYPE_REFERENCE, NULL, 0, D3D10_SDK_VERSION, &sd, &mSwapChain, &md3dDevice);
/*Error Here*/

return true;
}

int Run()
{
MSG msg = {0};

while(msg.message != WM_QUIT)
{
if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
//Do game logic here
else
{

}
}

return (int)msg.wParam;
}

LRESULT CALLBACK
WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_KEYDOWN:
if(wParam == VK_ESCAPE)
DestroyWindow(hWnd); //sends WM_DESTROY
return 0;
case WM_DESTROY:
PostQuitMessage(0); //sends WM_QUIT
return 0;
}

return DefWindowProc(hWnd, msg, wParam, lParam);
}


Error:

1>------ Build started: Project: WindowApp, Configuration: Debug Win32 ------
1> WinMain.cpp
1>c:\users\johnny\documents\visual studio 2010\projects\windowapp\windowapp\winmain.cpp(27): warning C4101: 'hr' : unreferenced local variable
1>WinMain.obj : error LNK2019: unresolved external symbol _D3D10CreateDeviceAndSwapChain@32 referenced in function "bool __cdecl InitWindowsApp(struct HINSTANCE__ *,int)" (?InitWindowsApp@@YA_NPAUHINSTANCE__@@H@Z)
1>C:\Users\johnny\documents\visual studio 2010\Projects\WindowApp\Debug\WindowApp.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


When I try to comment this line
D3D10CreateDeviceAndSwapChain(NULL, D3D10_DRIVER_TYPE_REFERENCE, NULL, 0, D3D10_SDK_VERSION, &sd, &mSwapChain, &md3dDevice);
the program compiles and runs fine. So, I'm guessing the error was here.

Help me.

I am using Windows 7 Professional 64bit. I have already installed the latest DX SDK (June).

at my project's properties->Configuration Properties->VC++ Directories
I set Include and Library Directories to..
Include Directories: C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Include;$(IncludePath)
Library Directories: C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Lib\x64;$(LibraryPath)

What am I missing?

TIA.

PS: What is the difference between
Microsoft DirectX SDK (June 2010)\Lib\x64 AND
Microsoft DirectX SDK (June 2010)\Lib\x86?
Should I use the x86 if I'm running on 32bit and x64 on 64bit?

Share this post


Link to post
Share on other sites
Advertisement
I set Include and Library Directories to..
Include Directories: C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Include;$(IncludePath)
Library Directories: C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Lib\x64;$(LibraryPath)

What am I missing? [/quote]

Huh, your directories look all messed up. It looked that way when I was converting my old visual c++ 2008-project to a 2010-project. Try to erase all the strange %28 / %29 and the $(IncludePath) at the end. Or try to copy the filepath again.

PS: What is the difference between
Microsoft DirectX SDK (June 2010)\Lib\x64 AND
Microsoft DirectX SDK (June 2010)\Lib\x86?
Should I use the x86 if I'm running on 32bit and x64 on 64bit? [/quote]

Not exactly, you should use x86 if you want to build a 32-bit-application, and x64 for a 64-bit, independantly from your OS.

Share this post


Link to post
Share on other sites
Thank you.

I tried this
Include Directories: C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include;$(IncludePath)
Library Directories: C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Lib\x64;$(LibraryPath)

and this
Include Directories: C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include;
Library Directories: C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Lib\x64;

Still doesn't fix the problem. I don't think there is problem with the %28, %29, and $(IncludePath)

Share this post


Link to post
Share on other sites
I got it working now i just added d3d10.lib and d3dx10.lib at
"properties", "linker->input", and "additional dependencies"

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!