[英]MinGW can't find XInput.h header
I am trying to compile this main.cpp file into a DLL with MinGW through a .bat file. 我正在尝试通过.bat文件将这个main.cpp文件编译为具有MinGW的DLL。 I am on Windows, not Linux btw. 我在Windows上,而不是Linux。
compile.bat mingw\\bin\\g++ "srcdll\\main.cpp" -O3 -DNDEBUG -s -shared -o "D:\\CPP\\output\\main.dll" compile.bat mingw \\ bin \\ g ++“ srcdll \\ main.cpp” -O3 -DNDEBUG -s -shared -o“ D:\\ CPP \\ output \\ main.dll”
but the compiler keeps saying it cannot find XInput.h. 但是编译器一直在说找不到XInput.h。 I have DirectX SDK installed as well and the include and lib directories are in my PATH environmental variable. 我也安装了DirectX SDK,include和lib目录在我的PATH环境变量中。
main.cpp 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;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.