# unresolved external symbol _Direct3DCreate9@4

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

## Recommended Posts

HI there, im fairly new to DirectX3D and there are many topics similar to this, alas, i cant find and answer - I am using the example code in the Direct X SDK <CreateDevice> - I am Using MS Visual C++ 2008 - My Problem, HRESULT InitD3D( HWND hWnd ) { // Create the D3D object, which is needed to create the D3DDevice. if( NULL == ( g_pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) ) return E_FAIL; //More code } g_pD3D is defined earlier. When i compile and run, i get the following error 1>Main.obj : error LNK2019: unresolved external symbol _Direct3DCreate9@4 referenced in function "long __cdecl InitD3D(struct HWND__ *)" (?InitD3D@@YAJPAUHWND__@@@Z) i have made sure i am linking d3dx9 and d3d9 libraries to the project when i install the main Project from the SDK and open it, compiler and run, it works perfectly. yet if i open a new Project i wont work am i missing somthing here?

##### Share on other sites
You need to link with the d3d9 lib:
#pragma comment(lib,"d3d9.lib") in one of your source files
or
project properties => linker => input (off the top of my head)

##### Share on other sites
Quote:
 Original post by Andy474i have made sure i am linking d3dx9 and d3d9 libraries to the project
How are you doing that? It doesn't appear to be working.

In Project Settings -> Configuration Properties -> Linker -> Input, make sure "d3d9.lib; d3dx9.lib" is in the "Additional Dependencies" box (Without quotes, obviously).

##### Share on other sites

Thank you so much, I included that earlier and it didn't work, I just copied the #pragma comment(lib,"d3d9.lib"); and it works like clockwork :P

##### Share on other sites
Ok, so I'm trying to do something in d3d9 and ran into a problem ... my search brought me here.
Essentially I have the issue Andy describes in his next to last post.

I can get vs2008 to compile and run my program if I use the #pragma comment(lib,"d3d9.lib") method ... but I wanted to link it "properly" so to speak.

Unfortunately whenever I attempt to link it properly, essentially just as Evil Steve described, I get a fatal error exclaiming that "d3d9.lib" cannot be opened.

Does anyone know what I might be doing wrong here?

##### Share on other sites
your not linking to the lib by the sounds of it, Can you post the error or try making sure that the file d3d9.lib is links specifically. Sometimes I didn't like it if I linked to the folder that contained it, I had to link to the exact .lib file

##### Share on other sites
Quote:
 Original post by brent_wOk, so I'm trying to do something in d3d9 and ran into a problem ... my search brought me here. Essentially I have the issue Andy describes in his next to last post. I can get vs2008 to compile and run my program if I use the #pragma comment(lib,"d3d9.lib") method ... but I wanted to link it "properly" so to speak. Unfortunately whenever I attempt to link it properly, essentially just as Evil Steve described, I get a fatal error exclaiming that "d3d9.lib" cannot be opened. Does anyone know what I might be doing wrong here?
Sounds like you haven't Set up the SDK paths properly.

##### Share on other sites
Quote:
Original post by Evil Steve
Quote:
 Original post by brent_wOk, so I'm trying to do something in d3d9 and ran into a problem ... my search brought me here. Essentially I have the issue Andy describes in his next to last post. I can get vs2008 to compile and run my program if I use the #pragma comment(lib,"d3d9.lib") method ... but I wanted to link it "properly" so to speak. Unfortunately whenever I attempt to link it properly, essentially just as Evil Steve described, I get a fatal error exclaiming that "d3d9.lib" cannot be opened. Does anyone know what I might be doing wrong here?
Sounds like you haven't Set up the SDK paths properly.

Hmm, when I read your post I was sure that was indeed my problem.

But I've just followed your tutorial.
And even updated to the most recent version of the DirectX sdk.

But I'm still getting this error:
1>LINK : fatal error LNK1104: cannot open file 'd3d9.lib;'

##### Share on other sites
Quote:
 Original post by brent_wBut I've just followed your tutorial. And even updated to the most recent version of the DirectX sdk. But I'm still getting this error:1>LINK : fatal error LNK1104: cannot open file 'd3d9.lib;'
Are you sure you added the lib/x86 directory rather than just lib? Can we see a screenshot of your project directories -> Library Files window?

##### Share on other sites

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

This topic is now closed to further replies.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 13
• 11
• 26
• 15
• 39
• ### Forum Statistics

• Total Topics
634833
• Total Posts
3019528
×