C++ Compiling Linking - c++

I am currently getting into some DirectX Programming and just installed the DX-SDK. However, when I open the most basic sample File (Tutorial01, just displays a blue background) in Visual Studio (2012, but that seems to be irrelevant) and compile it I get a working output.
When I start an empty c++ project, make a new file called main.cpp and copy and paste the code from the tutorial, do the same with the resource.h file and also go to Project settings->Configuration Properties->Linker and copy the "Input" from the sample to my own project and then compile my project I get the following error output:
fatal error C1083: Cannot open include file: 'd3dx11.h': No such file or directory
The Header is included via #includein both, the sample and my project. However my project won't compile.

Your new project is missing VC++ Directories settings to find the DirectX SDK include/lib paths. Starting with VS 2010, you have to explicitly set up the include/lib paths to get the DirectX SDK integrated with Visual Studio.
Since you are trying to use VS 2012 with the legacy DirectX SDK, you should be aware that the VC++ Directories settings for VS 2010 are backwards from what you should be using with VS 2012/VS2013. This is because the Windows 8.x SDK includes newer versions of most of the DirectX headers in the now outdated and deprecated legacy DirectX SDK.
The further complication is that D3DX is not present in the Windows 8.x SDK and is itself deprecated. You can make it work per the instructions on MSDN, but keep in mind there are now alternatives to using D3DX for Direct3D 11 you should consider.

Related

Visual Studio 2013 and Kinect SDK 2.0 Cannot find or include <NuiApi.h>

I am learning Kinect development using C++ in Visual Studio 2013 (Desktop version on Windows 8.1). I have downloaded the Kinect SDK 2.0 from Microsoft. According to my understanding, NuiApi.h is part of Kinect SDK 2.0. However, I cannot include it (#include says Cannot open source file). Have searched my computer for the file but couldn't find it. Reinstalled Kinect SDK with no luck. Below is the related part of the code:
#include<iostream>
#include<Windows.h>
#include<kinect.h>
#include<NuiApi.h>
A similar header, NuiKinectFusionApi.h, can be included without a problem.
You are mixing the 2 kinect versions!
for the kinect v1, you need to download kinect v1.8 drivers and then use the NuiApi.h
for the kinect v2, you need to download kinect v2.0 drivers and then use the kinect.h
You need to follow these steps to include #include.
1)Include windows.h in your source code.
2)To use the NUI API, include MSR_NuiApi.h. Location: Program Files\Microsoft Research KinectSDK\inc
To do this, you probably want to add that path to your project
Right-click on your project, properties, VC++ directories
Add ;C:\Program Files\Microsoft Research KinectSDK\inc to the end of the include paths
Add ;C:\Program Files\Microsoft Research KinectSDK\lib to the end of the libraries paths
then add #include <MSR_NuiApi.h>
to the includes at top of your source file. If you're using precompiled headers then you should put it below the stdafx.h include, or just add it to stdafx.h instead.
3) To use the Kinect Audio API, include MSRKinectAudio.h. Location: Program Files\Microsoft Research KinectSDK\inc
4)Link to MSRKinectNUI.lib. Location: Program Files\Microsoft Research KinectSDK\lib
5.Ensure that the beta SDK DLLs are on your path when you run your project. Location: \Program Files\Microsoft Research KinectSDK
This means that your binary needs to be able to find these files at runtime.
The easiest way to do this is to add them to your system path; go to
start menu
right-click computer, properties
advanced system settings
environment variables
PATH, in your user or system settings - edit and append ; then the path given
You may then need to restart Visual Studio to pick this up, or it should be registered when you open a new command prompt.
Or, if you don't want to change the system settings, you can e.g. add it to an open command prompt with
PATH=%PATH%;C:\Program Files\Microsoft Research KinectSDK
or you can work out exactly which files there are necessary and copy them into the same directory as your binary, etc.
Source : Getting the Kinect SDK to work with visual studio 2010 in c++
Hope that helps :)

Eclipse CDT - Cannot open include file: 'windows.h' (Microsoft SDK)

I'm trying to get Eclipse to build a project which was originally designed using Visual C++ (version 2008). I'm using the Microsoft Visual C++ toolchain.
When I try to build the project, I get the following error:
C:\...\types.h(25) : fatal error C1083: Cannot open include file: 'windows.h': No such file or directory
I've found some posts suggesting that I should download the Microsoft SDK and add the directory containing windows.h to the path. The problem is, Microsoft SDK (at least the version I downloaded, which is Windows SDK for Windows 8.1) does not contain such file.
Is there a way to obtain windows.h and all of its underlying headers (assuming that is the problem)? And if that's not the problem, what could be the solution?
Please notice I'm a real beginner to Eclipse and I have never used Visual, so I think there's no such thing as a too detailed answer.
If you need further information or did not understand something I wrote (English is not my mother tongue) please let me know.

DirectX11 release VS 2010 C++

I compiled my code in VS C++ 2010. If I use debug version, everything is okay!
If I want to make release version, I've got communicat:
main.cpp(7): fatal error C1083: Cannot open include file: 'd3dx11.h': No such file or directory
I use DirectX 11. What should I do?
As noted on MSDN, all versions of D3DX are deprecated including D3DX9, D3DX10, and D3DX11. You can certainly continue to use the deprecated libraries by using the legacy DirectX SDK. Remember that with VS 2010, you have to manually add the include/lib paths to your VC++ Directories properties page of your project to use the DirectX SDK with it.
For 32-bit Win32 configurations:
$(DXSDK_DIR)Utilities\bin\x86;$(ExecutablePath)
$(DXSDK_DIR)Include;$(IncludePath)
$(DXSDK_DIR)Lib\x86;$(LibraryPath)
For x64 native configurations:
$(DXSDK_DIR)Utilities\bin\x64;$(DXSDK_DIR)Utilities\bin\x86;$(ExecutablePath)
$(DXSDK_DIR)Include;$(IncludePath)
$(DXSDK_DIR)Lib\x64;$(LibraryPath)
If you were able to get #include <d3dx11.h> to work for DEBUG builds, but not RELEASE, you probably failed to set the VC++ Directories for All Configurations / All Platforms.
Another option would instead be to move to VS 2012 or VS 2013 which includes the Windows 8.x SDK which has the DirectX SDK integrated into it. There you'd make use of DirectX Tool Kit, DirectXTex, DirectXMesh, and/or other replacements for legacy D3DX.
Note if you were making use of the legacy DirectX SDK to continue to use D3DX11 and were also using the Windows 8.x SDK (such as with VS 2012 or VS 2013), then you'd have to reverse the include order above because the legacy DirectX SDK headers are older than the ones in the Windows 8.x SDK.
$(ExecutablePath);$(DXSDK_DIR)Utilities\bin\x86
$(IncludePath);$(DXSDK_DIR)Include
$(LibraryPath);$(DXSDK_DIR)Lib\x86
For x64 native configurations:
$(ExecutablePath);$(DXSDK_DIR)Utilities\bin\x64;$(DXSDK_DIR)Utilities\bin\x86
$(IncludePath);$(DXSDK_DIR)Include
$(LibraryPath);$(DXSDK_DIR)Lib\x64
Note you can get the Windows 8.1 SDK and DirectX Tool Kit to work with VS 2010 as noted here, but if you can I'd highly recommend using the VS 2013 Community edition if you don't have the budget for VS 2013 Professional or better.

Where can I find 'winmm.lib' (I'm using Visual Studio 2012)

My OS is 64Bit Windows 7.
I wanted to build the DirectX Sample in
C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Samples\C++\Direct3D10\Tutorials\Tutorial02.
but when I build error occured with fatal error
LNK1104: 'winmm.lib' can't open the file.
I reinstalled Direct SDK, but no change. I also added the path (include, lib) to the settings.
If I remove 'winmm.lib' from the project settings, 'comctl32.lib' can't be opened.
both libs were already present in properties>Linker>Input.
How can I solve this problem?
Just put the line below in stdafx.h
#pragma comment(lib, "winmm.lib")
winmm.lib isn't part of the DirectX SDK but is part of the Windows SDK.
Latest Windows SDK versions were also heavily reorganized but it includes the library you're looking for.
If you are trying to build any of the legacy DirectX SDK samples with VS 2012 or VS 2013, you need to modify the include/libs paths per the instructions on bottom of the page on MSDN. The most important change is that you must reverse the Include/Lib path order:
For VS 2010 it was:
$(DXSDK_DIR)Include;$(IncludePath)
$(DXSDK_DIR)Lib\x86;$(LibraryPath) or $(DXSDK_DIR)Lib\x64;$(LibraryPath)
For VS 2012/2013 it has to be:
$(IncludePath);$(DXSDK_DIR)Include
$(LibraryPath);$(DXSDK_DIR)Lib\x86 or $(LibraryPath);$(DXSDK_DIR)Lib\x64
Of course a better option is not spend time learning the older Direct3D 10 API at all, and use the latest Direct3D 11 Win32 desktop tutorials on MSDN Code Gallery. In fact, I've posted many of the legacy DirectX SDK samples there so they work fine with VS 2012/2013 Express for Windows Desktop and VS 2012/2013 Pro+ as-is without the DirectX SDK at all.
Read these blog posts:
DirectX SDK Samples Catalog
DirectX SDK Tools Catalog
Living without D3DX
DirectX SDKs of a certain age
And review these CodePlex projects:
DirectX Tool Kit
DirectXMesh
DirectXTex
DXUT for Direct3D 11
Effects 11

'dxerr9.h': No such file or directory

I am trying to compile a program I took off a cd from a book that uses directx to render 3d objects. when i press compile I get the following error
C1083: Cannot open include file: 'dxerr9.h': No such file or directory
I am using VC++ 2008 Express Edition and i am running off of Vista. I went to the following folder
[edit]
C:\Program Files (x86)\Microsoft DirectX SDK (February 2010)\Include
I was able to find dxerr.h in the folder and the path is also being included in the VC++ Directories tab in the options window. dont know whats going on.
It seems your program was written using older version of DirectX SDK. The 'dxerr9.h' is present at least in "Microsoft DirectX 9.0 SDK (December 2004)", but is absent at least in "Microsoft DirectX SDK (August 2009)".
I think VitalyVal was right. about the following:
It seems your program was written using an older version of DirectX SDK. The 'dxerr9.h' is present at least in "Microsoft DirectX 9.0 SDK (December 2004)", but is absent at least in "Microsoft DirectX SDK (August 2009)".
I think the files now go by dxerr.h. I removed the 9 to the header and lib files and it worked.
That header was precisely duped in Aug2009 SDK, though that shouldn't surprise since it was already two years older DX versions had been deprecated, thus allowing for just a single library for everything.
By the way, people might be interested to check this post for a kind of more updated version.