• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
SFN

error LNK2019: unresolved external symbol

2 posts in this topic

The full error message is this:

Error 2 error LNK2019: unresolved external symbol "bool __cdecl InitializeD3DApp(struct HINSTANCE__ *)" (?InitializeD3DApp@@YA_NPAUHINSTANCE__@@@Z) referenced in function _WinMain@16

and

Error 3 error LNK2019: unresolved external symbol _D3D10CreateDeviceAndSwapChain@32 referenced in function "bool __cdecl InitializeD3DDevice(struct HINSTANCE__ *)" (?InitializeD3DDevice@@YA_NPAUHINSTANCE__@@@Z) C:\Users\Tony\Desktop\C++ DX Apps\Test\Test\main.obj

 

Now, let me start by saying that I've done a solid amount of research on this, and the problem usually results in not linking the D3D10.lib library. I, however have done that and I still get this error. I've been able to get rid of the second error by including the x86 library (in the VC++ Directories) instead of the x64 (I am running a 64 bit CPU), but the first one still exists. So, why else could I be getting this error?
 

Here is the full code:
 

main.h:

#ifndef _MAIN_H_
#define _MAIN_H_

// LINKING /////////////////////////////////////////////////////////////////////////////////////////////////////////////
#pragma comment(lib, "d3d10.lib")
#pragma comment(lib, "d3dx10.lib")
#pragma comment(lib, "dxgi.lib")

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


// INCLUDES ////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <Windows.h>
#include <WindowsX.h>
#include <d3d10.h>
#include <d3dx10.h>

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


// DEFINITIONS /////////////////////////////////////////////////////////////////////////////////////////////////////////
#define WIN32_LEAN_AND_MEAN

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


// FUNCTION PROTOTYPES /////////////////////////////////////////////////////////////////////////////////////////////////
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
bool InitializeWindow(HINSTANCE hInstance, int showWnd, int wndWidth, int wndHeight, bool windowed, 
						LPCWSTR& outErrorTitle, LPCWSTR& outErrorText, UINT& outUType);
int MessageLoop();

bool InitializeD3DApp(HINSTANCE hInstance);
bool InitScene();
void DrawScene();

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


// GLOBAL VARIABLES ////////////////////////////////////////////////////////////////////////////////////////////////////
HWND m_hwnd = NULL;
LPCWSTR m_wndClassName = L"WindowClass1";

const int m_windowWidth  = 800;
const int m_windowHeight = 600;

// Message Box Error Params
LPCWSTR m_errorTitle, m_errorText;
UINT m_uType;

ID3D10Device* m_d3dDevice;
IDXGISwapChain* m_swapChain;
ID3D10RenderTargetView* m_renderTargetView;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


#endif // _MAIN_H_

main.cpp:

#include "main.h"

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
	if (!InitializeWindow(hInstance, nCmdShow, m_windowWidth, m_windowHeight, true, m_errorTitle, m_errorText, m_uType))
	{
		MessageBox(m_hwnd, m_errorText, m_errorTitle, m_uType);
		return 0;
	}

	if (!InitializeD3DApp(hInstance))
	{
		MessageBox(m_hwnd, L"Could not initialize D3D device", L"Error", MB_OK | MB_ICONERROR);
		return 0;
	}

	if (!InitScene())
	{
		MessageBox(m_hwnd, L"Could not initialize scene", L"Error", MB_OK | MB_ICONERROR);
		return 0;
	}

	MessageLoop();

	return 0;
}

bool InitializeWindow(HINSTANCE hInstance, int showWnd, int wndWidth, int wndHeight, bool windowed, 
						LPCWSTR& outErrorTitle, LPCWSTR& outErrorText, UINT& outUType)
{
	WNDCLASSEX wc;
	ZeroMemory(&wc, sizeof(WNDCLASSEX));

	wc.cbSize = sizeof(WNDCLASSEX);
	wc.style = CS_HREDRAW | CS_VREDRAW;
	wc.lpfnWndProc = WndProc;
	wc.cbClsExtra = 0;
	wc.cbWndExtra = 0;
	wc.hInstance = hInstance;
	wc.hIcon = LoadIcon(NULL, IDI_WINLOGO);
	wc.hCursor = LoadCursor(NULL, IDC_ARROW);
	wc.hbrBackground = (HBRUSH)COLOR_WINDOW;
	wc.lpszMenuName = NULL;
	wc.lpszClassName = m_wndClassName;
	wc.hIconSm = LoadIcon(NULL, IDI_WINLOGO);

	if (!RegisterClassEx(&wc))
	{
		outErrorTitle = L"Error";
		outErrorText  = L"Could not register class";
		outUType      = MB_OK | MB_ICONERROR;
		return false;
	}

	m_hwnd = CreateWindowEx(NULL, m_wndClassName, L"Window Title", WS_OVERLAPPEDWINDOW, 0, 0, wndWidth, wndHeight, NULL, NULL, hInstance, NULL);
	if (!m_hwnd)
	{
		outErrorTitle = L"Error";
		outErrorText  = L"Could not create window";
		outUType      = MB_OK | MB_ICONERROR;
	}

	ShowWindow(m_hwnd, showWnd);
	UpdateWindow(m_hwnd);

	return true;
}

int MessageLoop()
{
	MSG msg;
	ZeroMemory(&msg, sizeof(MSG));

	while (true)
	{
		while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}

		if (msg.message == WM_QUIT)
			break;
		else
		{
			// Run game code
			InitScene();
			DrawScene();
		}
	}

	return msg.wParam;
}

LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch (message)
	{
	case WM_KEYDOWN:
		if (wParam == VK_ESCAPE)
		{
			if (MessageBox(NULL, L"Are you sure you would like to exit?", L"Exit", MB_YESNO | MB_ICONQUESTION) == IDYES)
				DestroyWindow(hwnd);
			return 0;
		}
	case WM_DESTROY:
		PostQuitMessage(0);
		return 0;
	}

	return DefWindowProc(hwnd, message, wParam, lParam);
}

bool InitializeD3DDevice(HINSTANCE hInstance)
{
	DXGI_SWAP_CHAIN_DESC swapChainDesc;
	ID3D10Texture2D* backBuffer;
	D3D10_VIEWPORT viewport;

	ZeroMemory(&swapChainDesc, sizeof(DXGI_SWAP_CHAIN_DESC));
	swapChainDesc.BufferDesc.Width = m_windowWidth;
	swapChainDesc.BufferDesc.Height = m_windowHeight;
	swapChainDesc.BufferDesc.RefreshRate.Numerator = 60;
	swapChainDesc.BufferDesc.RefreshRate.Denominator = 1;
	swapChainDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
	swapChainDesc.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
	swapChainDesc.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
	swapChainDesc.SampleDesc.Count = 1;
	swapChainDesc.SampleDesc.Quality = 0;
	swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
	swapChainDesc.BufferCount = 1;
	swapChainDesc.OutputWindow = m_hwnd;
	swapChainDesc.Windowed = true;
	swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
	swapChainDesc.Flags = 0;

	D3D10CreateDeviceAndSwapChain(NULL, D3D10_DRIVER_TYPE_HARDWARE, NULL, 0, D3D10_SDK_VERSION, &swapChainDesc, &m_swapChain, &m_d3dDevice);

	m_swapChain->GetBuffer(0, __uuidof(ID3D10Texture2D), (LPVOID*)(&backBuffer));

	m_d3dDevice->CreateRenderTargetView(backBuffer, 0, &m_renderTargetView);
	backBuffer->Release();

	m_d3dDevice->OMSetRenderTargets(1, &m_renderTargetView, NULL);

	viewport.Width = m_windowWidth;
	viewport.Height = m_windowHeight;
	viewport.TopLeftX = 0;
	viewport.TopLeftY = 0;
	viewport.MinDepth = 0.1f;
	viewport.MaxDepth = 100.0f;

	m_d3dDevice->RSSetViewports(1, &viewport);
	
	return true;
}

bool InitScene()
{
	return true;
}

void DrawScene()
{
	m_d3dDevice->ClearRenderTargetView(m_renderTargetView, D3DXCOLOR(0.0f, 0.0f, 0.0f, 1.0f));
	m_swapChain->Present(0, 0);
}


0

Share this post


Link to post
Share on other sites

There is no InitializeD3DApp function in your post, so the linker is complaining that it's missing, when WinMain is trying to call it.

Is the InitializeD3DDevice function meant to be named InitializeD3DApp?

Edited by Hodgman
2

Share this post


Link to post
Share on other sites

I spent like two days trying to figure this out. I am very upset. Thank you hodgman

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0