链接器在从旧版DirectX SDK更改为Windows SDK(Visual Studio 2015)后继续抱怨)

链接器在从旧版DirectX SDK更改为Windows SDK(Visual Studio 2015)后继续抱怨)

问题描述:

我刚刚删除了所有的头文件包括在DirectX SDK,我向Windows SDK移动,但一旦我这样做,链接器不断抱怨未解决的外部符号。链接器显示大约24个错误,其中大部分错误都是我在我的游戏中甚至没有使用的函数。

I just removed all of the headers that were included in the DirectX SDK and i moved towards the Windows SDK, but once I did, the linker constantly complains about an "unresolved external symbol". The linker shows about 24 errors and most of these errors are about functions that I'm not even using in my game.

链接器错误:
error LNK2001:未解析的外部符号union __m128 __vectorcall DirectX :: XMVectorMultiply(union __m128,union __m128)

error LNK2001:未解析的外部符号union __m128 __vectorcall DirectX :: XMVectorSubtract(union __m128,union __m128)

error LNK2001:未解析的外部符号union __m128 __vectorcall DirectX :: XMVector3Normalize(union __m128)

错误LNK2001: unresolved external symbolunion __m128 __vectorcall DirectX :: XMVectorSet(float,float,float,float)

我没有使用 XMVector3Normalize() XMVectorSubtract() XMVectorMultiply()但是我确实使用了 XMVectorSet()

I have not used XMVector3Normalize(), XMVectorSubtract() and XMVectorMultiply() in my application, but I did use the XMVectorSet().

这些函数大多数都是 DirectXMath.h ,所以这里可能出错。

Most of these functions are part of the DirectXMath.h, so what could be wrong here.

无论如何,我不知道这是否会有帮助,我在我的应用程序中使用的所有标头。

Anyway, I don't know if this will help, but down below are all the headers that i used in my application.

#include <windows.h>
#include <D3D11.h>                      
#include <dinput.h> 
#include <SimpleMath.h>
#include <D3Dcompiler.h>
#include <sstream>
#include <SpriteFont.h>      //This file also includes DirectXMath.h
#include <DDSTextureLoader.h>
#include <WICTextureLoader.h>

#pragma comment (lib, "D3D11.lib")
#pragma comment (lib, "dinput8.lib")
#pragma comment (lib, "dxguid.lib")
#pragma comment (lib, "d3dcompiler.lib")


未解析的符号意味着您直接调用这些函数,或者它们由您调用的函数调用。您调用的函数必须由编译并链接到应用程序的源代码定义,或者必须由链接到应用程序的库定义。

"Unresolved symbol" means that either you directly call these functions, or they are called by functions that you are calling. Functions that you call must either be defined by source code that you compile and link into your application, or they must be defined by libraries that you link into your application.

DirectX数学库在标题中完全定义;没有图书馆链接。它们的定义位于 DirectXMath.h 所包含的各种DirectX Math .inl 文件中。

The DirectX Math library is completely defined in the header; there is no library to link against. Their definitions are in the various DirectX Math .inl files that are included by DirectXMath.h.

换句话说,你几乎不可能包含声明这些函数的头文件,并且不会得到它们的实现。

In other words, it's virtually impossible for you to include the header file declaring these functions and not get the implementation for them.

因为我不在你的电脑,我不能告诉你你做了什么,造成这种情况。要确定实际原因,您应该将问题简化为重现问题的最小可能程序,例如创建一个只包含 DirectXMath.h 的新项目,并使用函数 XMVectorMultiply 执行向量乘法并打印结果。

Since I am not at your computer, I can't tell you exactly what you did to cause this state of affairs. To determine the actual cause, you should simplify the problem to the smallest possible program that reproduces the problem, such as creating a new project that only includes DirectXMath.h and uses the function XMVectorMultiply to perform a vector multiplication and print the result.

一旦你得到这个简单的程序工作,到您的程序,并查看差异来找到您的错误的来源。

Once you get that simple program working, then compare it to your program and look at the differences to find the source of your error.

这是在运行时调试应用程序时, '调试您的构建,而不是您的应用程序。

This is the same process you go through when debugging an application at runtime, it's just that you're debugging your build instead of your application.