鏈接器給出了我在我的應用程序中根本沒有使用過的函數的錯誤 (Linker gives errors about a function that i have not used in my application at all)


問題描述

鏈接器給出了我在我的應用程序中根本沒有使用過的函數的錯誤 (Linker gives errors about a function that i have not used in my application at all)

鏈接器不斷顯示關於我的應用程序中未使用的函數的一堆錯誤。我唯一做的就是將標頭從 DirectX SDK 更改為 Windows SDK,我還下載了 DirectXTK 的包,這樣我就可以使用 WICTextureLoader.hDDSTextureLoader.h

這裡是一些鏈接器錯誤。

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)

錯誤 LNK2001:無法解析的外部符號“ union __m128 __vectorcall DirectX::XMVectorSet(float,float,float,float)

我不確定這裡發生了什麼。在我的應用程序中,我根本沒有調用 XMVectorMultiply()XMVectorSinCos()。我已經在我的項目中鏈接了適當的庫和頭文件,但這仍然不能解決問題。什麼可能導致這些鏈接器錯誤?

(如果您需要更多相關信息,請直接詢問)

以下只是我的代碼的一部分(我沒有包含所有代碼,因為我有大約 2000 行代碼):

/code> 在我的應用程序中。我已經在我的項目中鏈接了適當的庫和頭文件,但這仍然不能解決問題。什麼可能導致這些鏈接器錯誤?

(如果您需要更多相關信息,請直接詢問)

以下只是我的代碼的一部分(我沒有包含所有代碼,因為我有大約 2000 行代碼):

/code> 在我的應用程序中。我已經在我的項目中鏈接了適當的庫和頭文件,但這仍然不能解決問題。什麼可能導致這些鏈接器錯誤?

(如果您需要更多相關信息,請直接詢問)

以下只是我的代碼的一部分(我沒有包含所有代碼,因為我有大約 2000 行代碼):

#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;


}

這是我使用 DirectXMath.h 中的函數的幾次,但鏈接器顯示來自該特定標頭的錯誤..


參考解法

方法 1:

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.

(by Soon_to_be_code_masterChuck Walbourn)

參考文件

  1. Linker gives errors about a function that i have not used in my application at all (CC BY‑SA 2.5/3.0/4.0)

#direct3d11 #direct3d #C++ #linker






相關問題

Адлюстраванне дынамічнага буфера ў Direct3D11 у праграме Windows Store (Mapping a dynamic buffer in Direct3D11 in a Windows Store App)

未處理的異常@ClearRenderTargetView() (Unhandled exception @ ClearRenderTargetView())

將 3d 模型導入 Direct3D 11 示例 (Importing 3d model to Direct3D 11 Example)

編譯器不允許我使用“DDSTextureLoader.h”和“WICTextureLoader.h” (Compiler won't let me use "DDSTextureLoader.h" and "WICTextureLoader.h")

在我從舊版 DirectX SDK 更改為 Windows SDK (Visual Studio 2015) 後,鏈接器一直在抱怨 (The linker keeps complaining after I changed from legacy DirectX SDK to Windows SDK (Visual Studio 2015)))

鏈接器給出了我在我的應用程序中根本沒有使用過的函數的錯誤 (Linker gives errors about a function that i have not used in my application at all)

Direct3D 11 中輸出圖像的雙線性過濾 (Bilinear filtering of output image in Direct3D 11)

Direct3D 編程新手:11 與 12 (New to Direct3D programming: 11 vs 12)

如何在 Direct3D 11 上使用字體文件渲染文本? (How can I render text using font files on Direct3D 11?)

獲取 D3D 調試信息? (Get D3D debug information?)

為什麼 XMMatrixLookAtLH 會導致調試錯誤? (Why does XMMatrixLookAtLH result in a debug error?)

InterlockedAdd HLSL 潛在優化 (InterlockedAdd HLSL potential optimization)







留言討論