Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/130.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ DX11 DirectInput8Create导致LNK2019错误_C++_Directx_Directx 11_Unresolved External_Directinput - Fatal编程技术网

C++ DX11 DirectInput8Create导致LNK2019错误

C++ DX11 DirectInput8Create导致LNK2019错误,c++,directx,directx-11,unresolved-external,directinput,C++,Directx,Directx 11,Unresolved External,Directinput,我正在尝试创建一个GPU渲染粒子系统,它使用这个输入类来处理鼠标/键盘输入 问题是路线 HRESULT result = DirectInput8Create(.....); 导致LNK2019:未解决的外部符号错误。我已经包括了必要的文件,所以我不知道为什么会发生这种情况。下面分别是Input.h和Input.cpp文件 INPUT.H文件 #ifndef _INPUT_ #define _INPUT_ #include <stdafx.h> #include <dinp

我正在尝试创建一个GPU渲染粒子系统,它使用这个输入类来处理鼠标/键盘输入

问题是路线

HRESULT result = DirectInput8Create(.....);
导致LNK2019:未解决的外部符号错误。我已经包括了必要的文件,所以我不知道为什么会发生这种情况。下面分别是
Input.h
Input.cpp
文件

INPUT.H
文件

#ifndef _INPUT_
#define _INPUT_

#include <stdafx.h>
#include <dinput.h>

class Input{
private:
    IDirectInputDevice8*    _DIKeyboard;
    IDirectInputDevice8*    _DIMouse;

    LPDIRECTINPUT8          _directInput;

    LONG                    _mouseXabsolute, _mouseYabsolute, _mouseZabsolute;
    LONG                    _mouseXrelative, _mouseYrelative, _mouseZrelative;
    BYTE                    _keyboardState[256];
    BYTE                    _leftMouseButton, _rightMouseButton;

    int                     _screenWidth, _screenHeight;
    HWND                    _hWnd;

    POINT                   _point;
    RECT                    _rect;

public:
    Input();
    ~Input();

    void unload();
    bool initializeInput(HINSTANCE hInstance, HWND hWnd, int screenWidth, int screenHeight);

    void updateInput();

    BYTE* getKeyboardState();

    LONG getMouseXRelative();
    LONG getMouseYRelative();
    LONG getMouseZRelative();

    LONG getMouseXAbsolute();
    LONG getMouseYAbsolute();
    LONG getMouseZAbsolute();

    BYTE getLeftMouseClick();
    BYTE getRightMouseClick();
};

#endif 

如果您能为我解决此问题提供帮助,我将不胜感激。

您应该链接到dinput8.lib静态库:

#pragma comment(lib, "dinput8")

此外,您应该考虑使用原始输入API代替直接输入:

它是链接错误,因此您的.h和.cp文件是无关的。您只是忘记了链接导入库dinput8.lib。请注意,如果您使用的是DirectX 11,则无需使用DirectInput。此外,在现代版本的Windows上,不应该使用DirectInput进行键盘或鼠标输入——它只是在Win32消息之上实现的。请参阅和。我还必须添加dxguid。
#pragma comment(lib, "dinput8")