The linker keeps complaining after I changed from legacy DirectX SDK to Windows SDK (Visual Studio 2015))

心已入冬 提交于 2019-12-02 14:38:19

问题


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.

Linker errors: error LNK2001: unresolved external symbol "union __m128 __vectorcall DirectX::XMVectorMultiply(union __m128,union __m128)

error LNK2001: unresolved external symbol "union __m128 __vectorcall DirectX::XMVectorSubtract(union __m128,union __m128)

error LNK2001: unresolved external symbol "union __m128 __vectorcall DirectX::XMVector3Normalize(union __m128)

error LNK2001: unresolved external symbol "union __m128 __vectorcall DirectX::XMVectorSet(float,float,float,float)

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

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")

回答1:


"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.

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.

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.



来源:https://stackoverflow.com/questions/33712488/the-linker-keeps-complaining-after-i-changed-from-legacy-directx-sdk-to-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!