打开项目
在前一篇的链接中得到源码之后,我们先进行编译,在编译过程中发现我们会遇到很多错误。下面我们一一来列出错误并给出解决方案。这里先给一个链接,里面说了怎么处理这些错误:
http://www.d3dcoder.net/Data/Book4/d3d11Win10.htm
其实这篇链接的文章给出的方案基本上能够解决我们遇到的问题了。
这里我们编译d3d11CodeSet1
这个项目。
先说说我的环境:
操作系统:Microsoft Windows [版本 10.0.18362.295]
编译器:Visual Studio 2017
现在我们打开解压文件夹中的任一项目:如第一个Chapter 8 Texturing
中的sln文件
打开后会提示:
直接升级,点“确定”按钮。
第一次编译
现在我们直接编译看看会报哪些错误:
1>------ 已启动生成: 项目: TexturedHillsAndWaves, 配置: Debug Win32 ------
1>fxc compile for debug: D:\D3D11\d3d11CodeSet1\Chapter 8 Texturing\TexturedHillsAndWaves\FX\Basic.fx
1>Microsoft (R) Direct3D Shader Compiler 10.1
1>Copyright (C) 2013 Microsoft. All rights reserved.
1>
1>CUSTOMBUILD : warning X4717: Effects deprecated for D3DCompiler_47
1>
1>compilation code save succeeded; see Basic.cod
1>compilation object save succeeded; see D:\D3D11\d3d11CodeSet1\Chapter 8 Texturing\TexturedHillsAndWaves\FX\Basic.fxo
1>d3dApp.cpp
1>d:\d3d11\d3d11codeset1\common\d3dutil.h(13): fatal error C1083: 无法打开包括文件: “d3dx11.h”: No such file or directory
1>d3dUtil.cpp
1>d:\d3d11\d3d11codeset1\common\d3dutil.h(13): fatal error C1083: 无法打开包括文件: “d3dx11.h”: No such file or directory
1>GameTimer.cpp
1>GeometryGenerator.cpp
1>d:\d3d11\d3d11codeset1\common\d3dutil.h(13): fatal error C1083: 无法打开包括文件: “d3dx11.h”: No such file or directory
1>LightHelper.cpp
1>d:\d3d11\d3d11codeset1\common\lighthelper.h(11): fatal error C1083: 无法打开包括文件: “xnamath.h”: No such file or directory
1>MathHelper.cpp
1>d:\d3d11\d3d11codeset1\common\mathhelper.h(11): fatal error C1083: 无法打开包括文件: “xnamath.h”: No such file or directory
1>Waves.cpp
1>d:\d3d11\d3d11codeset1\common\waves.h(13): fatal error C1083: 无法打开包括文件: “xnamath.h”: No such file or directory
1>Effects.cpp
1>d:\d3d11\d3d11codeset1\chapter 8 texturing\texturedhillsandwaves\effects.h(11): fatal error C1083: 无法打开包括文件: “d3dUtil.h”: No such file or directory
1>TexturedHillsAndWavesDemo.cpp
1>d:\d3d11\d3d11codeset1\chapter 8 texturing\texturedhillsandwaves\texturedhillsandwavesdemo.cpp(12): fatal error C1083: 无法打开包括文件: “d3dApp.h”: No such file or directory
1>Vertex.cpp
1>d:\d3d11\d3d11codeset1\chapter 8 texturing\texturedhillsandwaves\vertex.h(10): fatal error C1083: 无法打开包括文件: “d3dUtil.h”: No such file or directory
1>正在生成代码...
1>已完成生成项目“TexturedHillsAndWaves.vcxproj”的操作 - 失败。
========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========
在上述错误中,我们对照上面的链接描述:
- 1、
Remove all #include <d3dx11.h> and library dependencies to d3dx11.lib/d3dx11d.lib, as D3DX11 is no longer included with DirectX
- (1)、在整个解决方案中搜索:
#include <d3dx11.h>
并删除
- (2)、删除链接器中的d3dx11.lib(release)和d3dx11d.lib(Debug)
- (1)、在整个解决方案中搜索:
- 2、
Replace all references to #include <xnamath.h> with #include <DirectXMath.h> and #include <DirectXPackedVector.h>.
整个解决方案中搜索#include <xnamath.h>
并替换为:#include <DirectXMath.h>
及#include <DirectXPackedVector.h>
第二次编译
现在我们再次编译:
1>------ 已启动生成: 项目: TexturedHillsAndWaves, 配置: Debug Win32 ------
1>d3dApp.cpp
1>d:\d3d11\d3d11codeset1\common\d3dutil.h(20): fatal error C1083: 无法打开包括文件: “dxerr.h”: No such file or directory
1>d3dUtil.cpp
1>d:\d3d11\d3d11codeset1\common\d3dutil.h(20): fatal error C1083: 无法打开包括文件: “dxerr.h”: No such file or directory
1>GeometryGenerator.cpp
1>d:\d3d11\d3d11codeset1\common\d3dutil.h(20): fatal error C1083: 无法打开包括文件: “dxerr.h”: No such file or directory
1>LightHelper.cpp
1>d:\d3d11\d3d11codeset1\common\lighthelper.h(22): error C3646: “Ambient”: 未知重写说明符
1>d:\d3d11\d3d11codeset1\common\lighthelper.h(22): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
.....
我们一个一个来处理:
- 1、对于无法包括dxerr,我们看链接中有提到:
- (1)、
Finally, we need a replacement for dxerr.lib. This blog post summarizes the details of why we need this: https://blogs.msdn.microsoft.com/chuckw/2012/04/24/wheres-dxerr-lib/. In short, the preceding link has a link to dxerr_nov2015.zip, which contains two files dxerr.h and dxerr.cpp that we can drop in the book’s Common directory to get the dxerr.lib functionality we need. Add these two files to your project.
- (2)、
Remove the library dependency to dxerr.lib. Add dxerr.h/.cpp to the project and change #include <dxerr.h> to #include “dxerr.h.”
删除项目链接中的dxerr.lib
。
打开文章给出的链接:https://blogs.msdn.microsoft.com/chuckw/2012/04/24/wheres-dxerr-lib/
,进入链接,我们会发现:
是不是感觉有点不对,其实应该是原链接失效了,根据链接中的wheres-dxerr-lib
关键字,我们在博客里找到:
进入这篇博客:
根据前面提示,在这边文末有个链接:dxerr_nov2015.zip
下载后,解压
将dxerr.h 和 dxerr.cpp文件拷贝到common目录
添加到项目
在项目中找到:#include <dxerr.h>
并替换为#include "dxerr.h"
- (1)、
第三次编译
1>------ 已启动生成: 项目: TexturedHillsAndWaves, 配置: Debug Win32 ------
1>d3dApp.cpp
1>d:\d3d11\d3d11codeset1\common\mathhelper.h(56): error C3646: “InverseTranspose”: 未知重写说明符
1>d:\d3d11\d3d11codeset1\common\mathhelper.h(56): error C2065: “CXMMATRIX”: 未声明的标识符
1>d:\d3d11\d3d11codeset1\common\mathhelper.h(56): error C2146: 语法错误: 缺少“)”(在标识符“M”的前面)
1>d:\d3d11\d3d11codeset1\common\mathhelper.h(57): error C2334: “{”的前面有意外标记;跳过明显的函数体
1>d:\d3d11\d3d11codeset1\common\mathhelper.h(68): error C3646: “RandUnitVec3”: 未知重写说明符
1>d:\d3d11\d3d11codeset1\common\mathhelper.h(68): error C2059: 语法错误:“)”
1>d:\d3d11\d3d11codeset1\common\mathhelper.h(68): error C2238: 意外的标记位于“;”之前
1>d:\d3d11\d3d11codeset1\common\mathhelper.h(69): error C3646: “RandHemisphereUnitVec3”: 未知重写说明符
1>d:\d3d11\d3d11codeset1\common\mathhelper.h(69): error C2065: “XMVECTOR”: 未声明的标识符
1>d:\d3d11\d3d11codeset1\common\mathhelper.h(69): error C2146: 语法错误: 缺少“)”(在标识符“n”的前面)
1>d:\d3d11\d3d11codeset1\common\mathhelper.h(69): error C2238: 意外的标记位于“;”之前
1>d:\d3d11\d3d11codeset1\common\lighthelper.h(22): error C3646: “Ambient”: 未知重写说明符
1>d:\d3d11\d3d11codeset1\common\lighthelper.h(22): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\d3d11\d3d11codeset1\common\lighthelper.h(23): error C3646: “Diffuse”: 未知重写说明符
1>d:\d3d11\d3d11codeset1\common\lighthelper.h(23): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\d3d11\d3d11codeset1\common\lighthelper.h(24): error C3646: “Specular”: 未知重写说明符
1>d:\d3d11\d3d11codeset1\common\lighthelper.h(24): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\d3d11\d3d11codeset1\common\lighthelper.h(25): error C3646: “Direction”: 未知重写说明符
1>d:\d3d11\d3d11codeset1\common\lighthelper.h(25): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\d3d11\d3d11codeset1\common\lighthelper.h(33): error C3646: “Ambient”: 未知重写说明符
1>d:\d3d11\d3d11codeset1\common\lighthelper.h(33): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\d3d11\d3d11codeset1\common\lighthelper.h(34): error C3646: “Diffuse”: 未知重写说明符
1>d:\d3d11\d3d11codeset1\common\lighthelper.h(34): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\d3d11\d3d11codeset1\common\lighthelper.h(35): error C3646: “Specular”: 未知重写说明符
1>d:\d3d11\d3d11codeset1\common\lighthelper.h(35): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\d3d11\d3d11codeset1\common\lighthelper.h(38): error C3646: “Position”: 未知重写说明符
1>d:\d3d11\d3d11codeset1\common\lighthelper.h(38): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\d3d11\d3d11codeset1\common\lighthelper.h(42): error C3646: “Att”: 未知重写说明符
1>d:\d3d11\d3d11codeset1\common\lighthelper.h(42): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\d3d11\d3d11codeset1\common\lighthelper.h(50): error C3646: “Ambient”: 未知重写说明符
1>d:\d3d11\d3d11codeset1\common\lighthelper.h(50): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\d3d11\d3d11codeset1\common\lighthelper.h(51): error C3646: “Diffuse”: 未知重写说明符
1>d:\d3d11\d3d11codeset1\common\lighthelper.h(51): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\d3d11\d3d11codeset1\common\lighthelper.h(52): error C3646: “Specular”: 未知重写说明符
1>d:\d3d11\d3d11codeset1\common\lighthelper.h(52): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\d3d11\d3d11codeset1\common\lighthelper.h(55): error C3646: “Position”: 未知重写说明符
1>d:\d3d11\d3d11codeset1\common\lighthelper.h(55): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\d3d11\d3d11codeset1\common\lighthelper.h(59): error C3646: “Direction”: 未知重写说明符
1>d:\d3d11\d3d11codeset1\common\lighthelper.h(59): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\d3d11\d3d11codeset1\common\lighthelper.h(63): error C3646: “Att”: 未知重写说明符
1>d:\d3d11\d3d11codeset1\common\lighthelper.h(63): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
................
................
1>Effects.cpp
1>d:\d3d11\d3d11codeset1\chapter 8 texturing\texturedhillsandwaves\effects.h(11): fatal error C1083: 无法打开包括文件: “d3dUtil.h”: No such file or directory
1>TexturedHillsAndWavesDemo.cpp
1>d:\d3d11\d3d11codeset1\chapter 8 texturing\texturedhillsandwaves\texturedhillsandwavesdemo.cpp(12): fatal error C1083: 无法打开包括文件: “d3dApp.h”: No such file or directory
1>Vertex.cpp
1>d:\d3d11\d3d11codeset1\chapter 8 texturing\texturedhillsandwaves\vertex.h(10): fatal error C1083: 无法打开包括文件: “d3dUtil.h”: No such file or directory
1>正在生成代码...
1>已完成生成项目“TexturedHillsAndWaves.vcxproj”的操作 - 失败。
========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========
这里我们根据链接文章中:
- 1、
All DirectX math types (XMVECTOR, XMFLOAT4X4, XMMatrixTranspose, etc.) will need to be prefixed with “DirectX::” because they now live in the DirectX namespace.
- 2、
All references to XMCOLOR need to be prefixed with DirectX::PackedVector because XMCOLOR lives in the DirectX::PackedVector namespace.
- 3、
Remove all references to D3DX11INLINE. You can just delete it or replace with inline.
- 4、
Remove the helper function d3dHelper::CreateTexture2DArraySRV from d3dUtil.h for now. You can use the texassemble tool (https://directxtex.codeplex.com/wikipage?title=Texassemble&referringTitle=Texconv) to create a texture array offline, which would be the preferred process anyway.
在d3dUtil.h
、mathhelper.h
、LightHelper.h
、#include "Waves.h"
中加入using namespace DirectX;
在d3dUtil.h
中加入using namespace DirectX::PackedVector;
删除所有的D3DX11INLINE,或者用inline代替,我们这里用inline代替:
删除d3dutil.h中的CreateTexture2DArraySRV
删除d3dutil.cpp中的CreateTexture2DArraySRV
。
第四次编译
1>------ 已启动生成: 项目: TexturedHillsAndWaves, 配置: Debug Win32 ------
1>d3dApp.cpp
1>d:\d3d11\d3d11codeset1\common\d3dapp.cpp(146): error C2664: “HRESULT DXTraceW(const WCHAR *,DWORD,HRESULT,const WCHAR *,bool)”: 无法将参数 1 从“const char [41]”转换为“const WCHAR *”
.....
1>d:\d3d11\d3d11codeset1\common\d3dutil.cpp(53): note: 与指向的类型无关;强制转换要求 reinterpret_cast、C 样式强制转换或函数样式强制转换
1>d:\d3d11\d3d11codeset1\common\d3dutil.cpp(65): error C2064: 项不会计算为接受 2 个参数的函数
.......
1>Effects.cpp
1>d:\d3d11\d3d11codeset1\chapter 8 texturing\texturedhillsandwaves\effects.h(11): fatal error C1083: 无法打开包括文件: “d3dUtil.h”: No such file or directory
1>TexturedHillsAndWavesDemo.cpp
1>d:\d3d11\d3d11codeset1\chapter 8 texturing\texturedhillsandwaves\texturedhillsandwavesdemo.cpp(12): fatal error C1083: 无法打开包括文件: “d3dApp.h”: No such file or directory
1>Vertex.cpp
1>d:\d3d11\d3d11codeset1\chapter 8 texturing\texturedhillsandwaves\vertex.h(10): fatal error C1083: 无法打开包括文件: “d3dUtil.h”: No such file or directory
1>正在生成代码...
1>已完成生成项目“TexturedHillsAndWaves.vcxproj”的操作 - 失败。
========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========
继续根据链接中的:
- 1、
In d3dUtil.h, replace __FILE__ in the DXTrace call with __FILEW__ so we get the file as a wide string
- 2、
In d3dUtil.h, rewrite ExtractFrustumPlanes like so (the change is to convert the input matrix to XMFLOAT4X4 so we can use the overloaded parenthesis operator to get the elements):
将cpp中的ExtractFrustumPlanes整个函数替换如下:
void ExtractFrustumPlanes(XMFLOAT4 planes[6], CXMMATRIX T)
{
XMFLOAT4X4 M;
XMStoreFloat4x4(&M, T);
//
// Left
//
planes[0].x = M(0, 3) + M(0, 0);
planes[0].y = M(1, 3) + M(1, 0);
planes[0].z = M(2, 3) + M(2, 0);
planes[0].w = M(3, 3) + M(3, 0);
//
// Right
//
planes[1].x = M(0, 3) - M(0, 0);
planes[1].y = M(1, 3) - M(1, 0);
planes[1].z = M(2, 3) - M(2, 0);
planes[1].w = M(3, 3) - M(3, 0);
//
// Bottom
//
planes[2].x = M(0, 3) + M(0, 1);
planes[2].y = M(1, 3) + M(1, 1);
planes[2].z = M(2, 3) + M(2, 1);
planes[2].w = M(3, 3) + M(3, 1);
//
// Top
//
planes[3].x = M(0, 3) - M(0, 1);
planes[3].y = M(1, 3) - M(1, 1);
planes[3].z = M(2, 3) - M(2, 1);
planes[3].w = M(3, 3) - M(3, 1);
//
// Near
//
planes[4].x = M(0, 2);
planes[4].y = M(1, 2);
planes[4].z = M(2, 2);
planes[4].w = M(3, 2);
//
// Far
//
planes[5].x = M(0, 3) - M(0, 2);
planes[5].y = M(1, 3) - M(1, 2);
planes[5].z = M(2, 3) - M(2, 2);
planes[5].w = M(3, 3) - M(3, 2);
// Normalize the plane equations.
for (int i = 0; i < 6; ++i)
{
XMVECTOR v = XMPlaneNormalize(XMLoadFloat4(&planes[i]));
XMStoreFloat4(&planes[i], v);
}
}
第五次编译
1>------ 已启动生成: 项目: TexturedHillsAndWaves, 配置: Debug Win32 ------
1>Waves.cpp
1>Effects.cpp
1>d:\d3d11\d3d11codeset1\chapter 8 texturing\texturedhillsandwaves\effects.h(11): fatal error C1083: 无法打开包括文件: “d3dUtil.h”: No such file or directory
1>TexturedHillsAndWavesDemo.cpp
1>d:\d3d11\d3d11codeset1\chapter 8 texturing\texturedhillsandwaves\texturedhillsandwavesdemo.cpp(12): fatal error C1083: 无法打开包括文件: “d3dApp.h”: No such file or directory
1>Vertex.cpp
1>d:\d3d11\d3d11codeset1\chapter 8 texturing\texturedhillsandwaves\vertex.h(10): fatal error C1083: 无法打开包括文件: “d3dUtil.h”: No such file or directory
1>正在生成代码...
1>已完成生成项目“TexturedHillsAndWaves.vcxproj”的操作 - 失败。
========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========
- In the C/C++ Property Pages > General, add the book’s Common directory to the “Additional Include Directories” list.
- In the Linker Property Pages > General, add the book’s Common directory to the “Additional Library Directories” list.
我们最开始的步骤都还没做,在项目中加入头文件及库文件目录:
头文件目录:../../Common/;
库文件目录:../../Common/;
第六次编译:
1>------ 已启动生成: 项目: TexturedHillsAndWaves, 配置: Debug Win32 ------
1>d3dApp.cpp
1>d3dUtil.cpp
1>dxerr.cpp
1>GameTimer.cpp
1>GeometryGenerator.cpp
1>LightHelper.cpp
1>MathHelper.cpp
1>Waves.cpp
1>Effects.cpp
1>TexturedHillsAndWavesDemo.cpp
1>d:\d3d11\d3d11codeset1\chapter 8 texturing\texturedhillsandwaves\texturedhillsandwavesdemo.cpp(160): error C3861: “D3DX11CreateShaderResourceViewFromFile”: 找不到标识符
1>d:\d3d11\d3d11codeset1\chapter 8 texturing\texturedhillsandwaves\texturedhillsandwavesdemo.cpp(163): error C3861: “D3DX11CreateShaderResourceViewFromFile”: 找不到标识符
1>Vertex.cpp
1>正在生成代码...
1>已完成生成项目“TexturedHillsAndWaves.vcxproj”的操作 - 失败。
========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========
原来博客中不是提及:
使用:
ID3D11Resource* texResource = nullptr;
HR(DirectX::CreateDDSTextureFromFile(md3dDevice, L"Textures/grass.dds", &texResource, &mGrassMapSRV));
ReleaseCOM(texResource); // view saves reference
HR(DirectX::CreateDDSTextureFromFile(md3dDevice, L"Textures/water2.dds", &texResource, &mWavesMapSRV));
ReleaseCOM(texResource); // view saves reference
HR(DirectX::CreateDDSTextureFromFile(md3dDevice, L"Textures/WireFence.dds", &texResource, &mBoxMapSRV));
ReleaseCOM(texResource); // view saves reference
替换
HR(D3DX11CreateShaderResourceViewFromFile(md3dDevice,
L"Textures/grass.dds", 0, 0, &mGrassMapSRV, 0 ));
HR(D3DX11CreateShaderResourceViewFromFile(md3dDevice,
L"Textures/water2.dds", 0, 0, &mWavesMapSRV, 0 ));
但这里我们不需要:
HR(DirectX::CreateDDSTextureFromFile(md3dDevice, L"Textures/WireFence.dds", &texResource, &mBoxMapSRV));
ReleaseCOM(texResource); // view saves reference
所以替换后如图:
第七次编译
1>------ 已启动生成: 项目: TexturedHillsAndWaves, 配置: Debug Win32 ------
1>TexturedHillsAndWavesDemo.cpp
1>d:\d3d11\d3d11codeset1\chapter 8 texturing\texturedhillsandwaves\texturedhillsandwavesdemo.cpp(167): error C2039: “CreateDDSTextureFromFile”: 不是“DirectX”的成员
1>d:\windows kits\10\include\10.0.17763.0\um\directxpackedvector.h(14): note: 参见“DirectX”的声明
1>d:\d3d11\d3d11codeset1\chapter 8 texturing\texturedhillsandwaves\texturedhillsandwavesdemo.cpp(167): error C3861: “CreateDDSTextureFromFile”: 找不到标识符
1>d:\d3d11\d3d11codeset1\chapter 8 texturing\texturedhillsandwaves\texturedhillsandwavesdemo.cpp(170): error C2039: “CreateDDSTextureFromFile”: 不是“DirectX”的成员
1>d:\windows kits\10\include\10.0.17763.0\um\directxpackedvector.h(14): note: 参见“DirectX”的声明
1>d:\d3d11\d3d11codeset1\chapter 8 texturing\texturedhillsandwaves\texturedhillsandwavesdemo.cpp(170): error C3861: “CreateDDSTextureFromFile”: 找不到标识符
1>已完成生成项目“TexturedHillsAndWaves.vcxproj”的操作 - 失败。
========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========
原文中还有一点提到:
Next, we need a replacement for loading textures. Again, the D3DX code used for loading textures has been open sourced: https://github.com/Microsoft/DirectXTex Pull DDSTextureLoader, drop DDSTextureLoader.h/.cpp into the book’s Common directory, and add these files to your project. We will use this code to load textures from disk.
根据提供的链接下载项目,并解压:
将DDSTextureLoader文件夹中的DDSTextureLoader.h/.cpp拷贝到Common目录:
添加进工程:
Add a #include “DDSTextureLoader.h” in d3dUtil.h.
第八次编译
1>------ 已启动生成: 项目: TexturedHillsAndWaves, 配置: Debug Win32 ------
1>d3dApp.cpp
1>d3dUtil.cpp
1>DDSTextureLoader.cpp
1>GeometryGenerator.cpp
1>Effects.cpp
1>TexturedHillsAndWavesDemo.cpp
1>Vertex.cpp
1>正在生成代码...
1>Effects11d.lib(EffectAPI.obj) : error LNK2038: 检测到“_MSC_VER”的不匹配项: 值“1600”不匹配值“1900”(d3dApp.obj 中)
1>Effects11d.lib(EffectNonRuntime.obj) : error LNK2038: 检测到“_MSC_VER”的不匹配项: 值“1600”不匹配值“1900”(d3dApp.obj 中)
1>Effects11d.lib(EffectLoad.obj) : error LNK2038: 检测到“_MSC_VER”的不匹配项: 值“1600”不匹配值“1900”(d3dApp.obj 中)
1>Effects11d.lib(EffectReflection.obj) : error LNK2038: 检测到“_MSC_VER”的不匹配项: 值“1600”不匹配值“1900”(d3dApp.obj 中)
1>Effects11d.lib(d3dx11dbg.obj) : error LNK2038: 检测到“_MSC_VER”的不匹配项: 值“1600”不匹配值“1900”(d3dApp.obj 中)
1>Effects11d.lib(d3dxGlobal.obj) : error LNK2038: 检测到“_MSC_VER”的不匹配项: 值“1600”不匹配值“1900”(d3dApp.obj 中)
1>Effects11d.lib(EffectRuntime.obj) : error LNK2038: 检测到“_MSC_VER”的不匹配项: 值“1600”不匹配值“1900”(d3dApp.obj 中)
1>Effects11d.lib(EffectNonRuntime.obj) : error LNK2019: 无法解析的外部符号 __imp___vsnprintf,该符号在函数 "long __stdcall StringVPrintfWorkerA(char *,unsigned int,unsigned int *,char const *,char *)" (?StringVPrintfWorkerA@@YGJPADIPAIPBD0@Z) 中被引用
1>Effects11d.lib(d3dx11dbg.obj) : error LNK2001: 无法解析的外部符号 __imp___vsnprintf
1>D:\D3D11\d3d11CodeSet1\Chapter 8 Texturing\TexturedHillsAndWaves\Debug\TexturedHillsAndWaves.exe : fatal error LNK1120: 1 个无法解析的外部命令
1>已完成生成项目“TexturedHillsAndWaves.vcxproj”的操作 - 失败。
========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========
原文中提到:
The DirectX 11 book uses the Effects framework. An open source version of the Effects framework that is compatible with the DirectX versions that ship with Windows 8 and above can be found here: https://github.com/Microsoft/FX11 Download the source, open the Effects11_2015 solution file and rebuild the libraries in debug and release mode using Visual Studio 2015. Name the debug one Effects11d.lib and the release one Effects11.lib. Copy the files: d3dx11effect.h, Effects11d.lib and Effects11.lib into the book’s Common directory (overwriting the old ones).
根据提供链接下载:FX11解压并打开Effects11_2017_Win10.sln
编译得到Effects11d.lib(Debug)和Effects11.lib(release),然后拷贝至Common目录,并将d3dx11effect.h(在inc目录)也拷贝覆盖到Common目录。
在编译FX11项目也会出现一些问题,由于时间及篇幅问题,我下一篇再来说它怎么编译。
第九次编译
终于成功了,运行一下:
总结
其实正常编译不用这么曲折麻烦,我这里主要是剖析一下错误,有人可能只会遇到部分错误。我们只要按照文章最开始的链接,按步骤,一次性就到位了。