C++ DirectX 9 未解析的外部符号

C++ DirectX 9 unresolved external symbol

是的,我包含了所有的库,但每次我 运行 我的 x64 程序都会给我一个未解析的符号,但在 x32 中完美运行??

Severity Code Description Project File Line Suppression State Error LNK2019 unresolved external symbol Direct3DCreate9Ex referenced in function "int cdecl DirectXInit(struct HWND *)" (?DirectXInit@@YAHPEAUHWND__@@@Z) DirectX Overlay D:\VSprojects20\Mygui\Garrysmod take 2\Overlay aimbot\DirectX.obj 1

来源

    int DirectXInit(HWND hWnd)
    {
        if (FAILED(Direct3DCreate9Ex(D3D_SDK_VERSION, &p_Object)))
            exit(1);

        ZeroMemory(&p_Params, sizeof(p_Params));
        p_Params.Windowed = TRUE;
        p_Params.SwapEffect = D3DSWAPEFFECT_DISCARD;
        p_Params.hDeviceWindow = hWnd;
        p_Params.MultiSampleQuality = D3DMULTISAMPLE_NONE;
        p_Params.BackBufferFormat = D3DFMT_A8R8G8B8;
        p_Params.BackBufferWidth = Width;
        p_Params.BackBufferHeight = Height;
        p_Params.EnableAutoDepthStencil = TRUE;
        p_Params.AutoDepthStencilFormat = D3DFMT_D16;

        if (FAILED(p_Object->CreateDeviceEx(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &p_Params, 0, &p_Device)))
            exit(1);

        return 0;
    }





    char playerO[350] = { 0 };
    char enemyO[300] = { 0 };
    char aimbotO[300] = { 0 };
    char rect[300] = { 0 };
    int counter = 15;

    int Render()
    {


            p_Device->Clear(0, 0, D3DCLEAR_TARGET, 0, 1.0f, 0);
            p_Device->BeginScene();


            //Drawing Stuff

            DrawBorderBox(10, 10, 200, 200, 15, 255, 255, 0, 0);


            p_Device->EndScene();
            p_Device->PresentEx(0, 0, 0, 0, 0);
            return 0;

    }

页眉

 #ifndef DIRECTX_H
#define DIRECTX_H


#include "Main.h"
#include "Drawings.h"
#include "read.h"

#include <Windows.h>
#include <iostream>


#include <d3d9.h>
#include <d3dx9.h>
#pragma comment(lib, "d3d9.lib")
#pragma comment(lib, "d3dx9.lib")


#include <dwmapi.h>
#pragma comment(lib, "dwmapi.lib")


extern IDirect3D9Ex* p_Object;
extern IDirect3DDevice9Ex* p_Device;
extern D3DPRESENT_PARAMETERS p_Params;
extern ID3DXLine* p_Line;
extern ID3DXFont* pFontSmall;

extern RECT rc;

int DirectXInit(HWND hWnd);
int Render();

#endif

同样,很可能不使用包含,因为它像 x32 中的时钟一样工作。

x32 和 x64 具有不同的项目配置,因为您可能需要将它们指向每个体系结构的不同库位置。仔细检查以确保当您 select x64 时,库和包含目录仍然指向您的 DirectX 包含和 libs 文件夹。

您还需要确保在您的 includes 下

#include <d3d9.h>
#include <d3dx9.h>

你有

#pragma comment(lib, "d3d9.lib")
#pragma comment(lib, "d3dx9.lib")

使用旧版 DirectX SDK,您必须设置不同的 x86 与 x64 库包含路径:

在 VC++ 32 位配置的目录中:

$(IncludePath);$(DXSDK_DIR)Include
$(LibraryPath);$(DXSDK_DIR)Lib\x86

在 VC++ 64 位配置的目录中:

$(IncludePath);$(DXSDK_DIR)Include
$(LibraryPath);$(DXSDK_DIR)Lib\x64

Microsoft Docs

For new projects you should be using Direct3D 11, and you do not need to use the legacy DirectX SDK at all.