Jump to content
  • Advertisement
Sign in to follow this  
Andy474

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.

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

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
Share on other sites
Quote:
Original post by Andy474
i 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 this post


Link to post
Share on other sites
:O *Laughs his head off*

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 this post


Link to post
Share on other sites
yea, that's exactly how I was linking the files to the project. i spent many a day wondering about this :P

Share this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites
Quote:
Original post by brent_w
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?
Sounds like you haven't Set up the SDK paths properly.

Share this post


Link to post
Share on other sites
Quote:
Original post by Evil Steve
Quote:
Original post by brent_w
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?
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 this post


Link to post
Share on other sites
Quote:
Original post by brent_w
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;'
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 this post


Link to post
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.

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

Guest
This topic is now closed to further replies.
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!