Hey,

I'm trying to learn DirectX from this book (Beginning Game Design by John S. Harbour, if anyone knows the book). I keep getting a LNK2019 error because Direct3DCreate9(D3D_SDK_VERSION) is an "unresolved external symbol". Based on my slightly limited knowledge on libraries and include files and a little of my research, I'm assuming this means that C++ doesn't know what Direct3DCreate9() is (or that there's some difference between the definition of the function and it's use here). Does anyone know how to fix this. I've set d3d9.lib as a library file and C:\Program Files\Microsoft DirectX SDK (August 2007)\Include as an include. The code that's not working is:

int Game_Init(HWND hWnd)
{
	MessageBox(hWnd,"Program is about to start","Game_Init",MB_OK);

	d3d = Direct3DCreate9(D3D_SDK_VERSION);
	if(d3d == NULL)

line 5 above. If anyone can help I'd be very thankful. Learning by doing can get annoying at times like this...

Recommended Answers

All 4 Replies

how did you tell your compiler that it needs to link with d3d9.lib ? My guess is that you didn't.

Using Visual C++ 2008, I went to Tools->Options, expanded projects and solutions, went to VC++ directories, changed the drop-down to library files, and added C:\Program Files\Microsoft DirectX SDK (August 2007)\Lib\x86\d3d9.lib as a new entry. Would that do it?

>>Would that do it?
That only tells the compiler where to find the libraries. It does not tell the compiler what libraries to use.

There are a couple ways to do it
1) add a #pragma comment(lib,"d3d9.lib") near the top of one of your *.cpp or *.c files. That forces the compiler to link with that library

2) Project --> Properties -->Configuration Properties --> Linker --> Input, then in the panel on the right add the library name in Additional Dependencies edit control.

That did it. Thanks again!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.