The linker keeps showing a bunch of errors about functions that i have not used in my application. The only thing that I did was change the headers from DirectX SDK to the Windows SDK, and I also downloaded the package for DirectXTK so i can use WICTextureLoader.h
and DDSTextureLoader.h
Here are some of the linker errors.
error LNK2001: unresolved external symbol "union __m128 __vectorcall DirectX::XMVectorMultiply(union __m128,union __m128)
error LNK2001: unresolved external symbol "void __vectorcall DirectX::XMVectorSinCos(union __m128 *,union __m128 *,union __m128)
error LNK2001: unresolved external symbol "union __m128 __vectorcall DirectX::XMVectorSet(float,float,float,float)
I'm not sure what's going on here. I didn't call XMVectorMultiply()
or XMVectorSinCos()
at all in my application. I already linked the appropriate libraries and headers in my project, but this still won't fix the problem. What could be causing these linker errors?
(If you need more relevant information, just ask)
Below is just part of my code (I didn't include all of it because i have about 2000 lines of code):
#pragma comment (lib, "dinput8.lib")
#pragma comment (lib, "dxguid.lib")
#pragma comment (lib, "D3D11.lib")
#pragma comment (lib, "d3dcompiler.lib")
#include <windows.h>
#include <D3D11.h>
#include <dinput.h>
#include <D3Dcompiler.h>
#include <sstream>
#include <SimpleMath.h>
#include <DirectXMath.h>
#include <DDSTextureLoader.h>
#include <WICTextureLoader.h>
#include <SpriteBatch.h>
#include <SpriteFont.h>
void Create_Camera_View_Space()
{
camPosition = DirectX::XMVectorSet(0.0f, 2.0f, -12.5f, 0.0f);
camDirection = DirectX::XMVectorSet(0.0f, 0.0f, 1.0f, 0.0f);
camUp = DirectX::XMVectorSet(0.0f, 1.0f, 0.0f, 0.0f);
CameraView = DirectX::XMMatrixLookAtLH(
camPosition,
camDirection,
camUp
);
}
void Create_Camera_Projection_Space()
{
CameraProjection = DirectX::XMMatrixPerspectiveFovLH(
0.4f * 3.14f,
(float)400 / 400,
1.0f,
10000.0f
);
}
void Create_World_Space_for_Ground()
{
DirectX::XMMATRIX Translation;
DirectX::XMMATRIX Rotation;
DirectX::XMMATRIX Scale;
DirectX::XMMATRIX Input_Rotation_X;
DirectX::XMMATRIX Input_Rotation_Z;
GroundWorld = DirectX::XMMatrixIdentity();
Scale = DirectX::XMMatrixScaling(500.0f, 10.0f, 500.0f);
Translation = DirectX::XMMatrixTranslation(0.0f, 10.0f, 0.0f);
GroundWorld = Scale * Translation;
}
This is the few times i am using the functions in the DirectXMath.h
, but the linker shows errors that come from that specific header..
The most likely issue here is that you are building the various libraries in question with different settings, compilers, or paths.
__vectorcall
is a calling convention supported by VS 2013 or later and is used by DirectXMath in the Windows 8.1 SDK and the Windows 10 SDK if it is supported by your compiler. As DirectXMath is all inline, you have to be consistent about making sure all your use of DirectXMath in the same EXE or DLL is using the same version of the headers and the same version of the compiler.
This is one of the reasons why DirectX Tool Kit provides compiler specific vcxproj
files to ensure this is kept in sync.
As your project previously used the legacy DirectX SDK, you probably have some lingering Preprocessor macros and VC++ Directories settings that need cleaned up. You might try doing a diff of your vcxproj
file with DirectXTK_Desktop_2015.vcxproj
.
You can also have problems if you are building your x86 config with
/arch:IA32
or/arch:SSE
rather than/arch:SSE2
which is what is used for the DirectX Tool Kit library builds.A similar mismatch can happen if you try to use
_XM_NO_INTRINISCS_
in your project which does not match how DirectX Tool Kit is built.