Jump to content
  • Advertisement
Sign in to follow this  
Britmonkey

Visual Studio C++ with DirectX

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

Hello,
I am trying to get back into programming however having installed the DirectX and Visual Studio Express 2010 I get the error that the it can't find the include file 'd3d11.h'.
I have been trying to follow the tutorials included with the directx documentation. The program complies fine when I open the included sample files however I get the above error when I copy the .cpp file into my own project.
I am also mystified by the idea of External Dependencies because it is empty when I create a new project however when I compile even a simple 'hello world' program the list quickly fills up with over 50 files.

Please could someone help me to get me back on my feet.

Share this post


Link to post
Share on other sites
Advertisement
Hi,

You are missing include directories. There are serveral ways you can fix this.

1) Straight forward option is to right click your project -> choose Properties -> C/C++ --> General. In the table on the right. Add an additional entry for "Additional Include Directories". (Click into the edit box then click the ellipis, add a new entry and browse for the include directory, which should be something like c:\Program Files\DirectX SDK\...)

Now the comiler should work, but the linker will complain about unresolved exernals. You can fix that by adding an additional lib directory ( Linker --> General --> Additional library directory )


2) A fore flexible variant is by adding a property sheet. To do this open the property manager. View --> Other Windows --> Property Manager. Right click the project and choose add new property sheet. Now make the above changes in the property sheet. The benefit is, that you can reuse the property sheet in your next program.

Best Jochen

Share this post


Link to post
Share on other sites
Thank you for your reply. The first step worked however i am unable to add the lib library to resolve the error whihc you predicted. Are you able to tell me why I have not encountered these problems before on visual studio 2008 and also whether I can expect them every time I start a new project?

Share this post


Link to post
Share on other sites
Quote:

The first step worked however i am unable to add the lib library to resolve the error whihc you predicted.


The libraries should be located in a directory "lib" which should be right next to the "include" directory in your directX SDK installation directory.

Quote:

Are you able to tell me why I have not encountered these problems before on visual studio 2008


You probably used an older version of direct X which already is included in the MSVC version you were using. So the default include and lib paths already pointed to the correct locations.

Just a hint, maybe you should google a little about c++ / compiler / linker / include files / libraries / dynamic / static linking / object files / source fieles etc.

Once you understand what all these things are there for, the solution to an "unresolved extenal" will become obvious to you as you see it.

However this is nothing you can grasp over night. It will take you months if not years to fully understand all the little details about c++.

Best Jochen

Share this post


Link to post
Share on other sites
Here are the errors:
1>copy.obj : error LNK2019: unresolved external symbol _D3D10CreateDeviceAndSwapChain@32 referenced in function "long __cdecl InitDevice(void)" (?InitDevice@@YAJXZ)
1>c:\users\jeremy\documents\visual studio 2010\Projects\directtest\Debug\directtest.exe : fatal error LNK1120: 1 unresolved externals

I found the files in C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Lib with x64 and x86 versions. Whichever file I select in the additional library directory I still get the same errors (above) and there seems to be no effect.

Share this post


Link to post
Share on other sites
I have now solved my problem and the program runs. I did what you suggested correctly and also found that I needed to copy some additional dependencies from the original file:
d3d11.lib
d3dcompiler.lib
d3dx11d.lib
d3dx9d.lib
dxerr.lib

Unfortunately I do not understand why this was necessary. Any help?

Share this post


Link to post
Share on other sites
Ups, I got so used to my directX property sheets...
I even assumed directX had link dependencies via #pragmas.

Well the problem is, that the linker knows where to look for the external dependency (you told him via the lib directories), but actually it doesn't know that it has to link with it yet.

Solution: add d3d11.lib to Linker --> Input --> Additional dependencies.

I'm not sure about the correctness of d3d11.lib. I don't have a development machine available atm. But you can eassily find the correct dependency in the documentation that is shipped with the SDK. The documentation for D3D10CreateDeviceAndSwapChain should mention which file to include and which lib to link against.

Best Jochen


*edit: added a missin you an din.

Share this post


Link to post
Share on other sites
Sorted. Are you able to tell me what to write in a .props file to get the same thing to happen through your second method? (Or anyone else?)

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!