MinGW找不到XInput.h头

时间:2012-09-01 20:35:27

标签: c++ c mingw header-files

我正在尝试通过.bat文件将此main.cpp文件编译为带有MinGW的DLL。 我在Windows上,而不是Linux btw。

的compile.bat  mingw \ bin \ g ++“srcdll \ main.cpp”-O3 -DNDEBUG -s -shared -o“D:\ CPP \ output \ main.dll”

但是编译器一直说它找不到XInput.h。我也安装了DirectX SDK,include和lib目录在我的PATH环境变量中。

的main.cpp

#include <windows.h>
#include <XInput.h>

#define EXPORTREAL extern "C" __declspec(dllexport) double __cdecl
#define EXPORTSTRING extern "C" __declspec(dllexport) LPSTR __cdecl

EXPORTREAL setRumble(double index, double left, double right)
{
    XINPUT_VIBRATION vibration;

    vibration.wLeftMotorSpeed = left;
    vibration.wRightMotorSpeed = right;

    XInputSetState(index,&vibration);

    return index;
}

EXPORTREAL leftTrigger(double index)
{
    XINPUT_STATE state;

    XInputGetState(index,&state);
    return state.Gamepad.bLeftTrigger;
}

EXPORTREAL rightTrigger(double index)
{
    XINPUT_STATE state;

    XInputGetState(index,&state);
    return state.Gamepad.bRightTrigger;
}

EXPORTREAL leftThumbX(double index)
{
    XINPUT_STATE state;

    XInputGetState(index,&state);
    return state.Gamepad.sThumbLX;
}

EXPORTREAL leftThumbY(double index)
{
    XINPUT_STATE state;

    XInputGetState(index,&state);
    return state.Gamepad.sThumbLY;
}

EXPORTREAL rightThumbX(double index)
{
    XINPUT_STATE state;

    XInputGetState(index,&state);
    return state.Gamepad.sThumbRX;
}

EXPORTREAL rightThumbY(double index)
{
    XINPUT_STATE state;

    XInputGetState(index,&state);
    return state.Gamepad.sThumbRY;
}

EXPORTREAL getButtonState(double index)
{
    XINPUT_STATE state;

    XInputGetState(index,&state);
    return state.Gamepad.wButtons;
}

EXPORTREAL checkButton(double index, double button)
{
    WORD buttonWord;
    XINPUT_STATE state;

    buttonWord = button;

    XInputGetState(index,&state);
    return (state.Gamepad.wButtons & buttonWord) ? 1 : 0;
}

EXPORTREAL getCtrlState(double index)
{
    XINPUT_STATE state;

    return XInputGetState(index,&state);
}

BOOL APIENTRY DllMain( HMODULE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
                     )
{
    XINPUT_VIBRATION vibration;

    vibration.wLeftMotorSpeed = 0;
    vibration.wRightMotorSpeed = 0;

    XInputSetState(0,&vibration);

    return TRUE;
}

1 个答案:

答案 0 :(得分:1)

  1. 将标题路径添加到命令行
  2. 错误(未定义的引用)来自链接。您应该在链接行
  3. 中添加.a / .o的路径