I'm relatively new to C++ programming and Qt so this issue is probably my miss understanding of codependency. I'm trying to use the Xinput.h file within my source code, which is part of the DirectX SDK with Qt creator. I have working source code for my solution that compiles and executes fine within Visual Studio 2008 however when I come to use it within Qt no such like as the header file is missing. I have tried to import the XInput.dll using the inbuilt libary adder
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../../Program Files (x86)/Microsoft DirectX SDK (June 2010)/Lib/x64/ -lXInput
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../../Program Files (x86)/Microsoft DirectX SDK (June 2010)/Lib/x64/ -lXInputd
else:symbian: LIBS += -lXInput
else:unix: LIBS += -L$$PWD/../../../../../Program Files (x86)/Microsoft DirectX SDK (June 2010)/Lib/x64/ -lXInput
INCLUDEPATH += $$PWD/../../../../../Program Files (x86)/Microsoft DirectX SDK (June 2010)/Lib/x64
DEPENDPATH += $$PWD/../../../../../Program Files (x86)/Microsoft DirectX SDK (June 2010)/Lib/x64
However this fails to compile giving me '_in' was not declared in this scope, does any one know how i might fix this?
The _in and _out errors come from the Xinput.h header file included in the Direct X SDK.
DWORD WINAPI XInputGetState
(
__in DWORD dwUserIndex, // Index of the gamer associated with the device
__out XINPUT_STATE* pState // Receives the current state
);
I thought i would include a demo for anyone unsure of what is happening:
The .Pro file from QT:
QT += core
QT -= gui
TARGET = testxbox
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
INCLUDEPATH += "...path to include file.../Include"
win32: LIBS += -L$$PWD/../../../Program Files (x86)/Microsoft SDKs/Windows/v7.0A/Lib/ -lXinput
INCLUDEPATH += $$PWD/../../../Program Files (x86)/Microsoft SDKs/Windows/v7.0A/Lib
DEPENDPATH += $$PWD/../../../Program Files (x86)/Microsoft SDKs/Windows/v7.0A/Lib
Then i just try to include the Xinput.h in my source files, and i get loads of horrendous messages. Windows VS 2008 just let's me do
#include <windows.h>
#include <XInput.h>
#pragma comment(lib, "XInput.lib")
and it works?
I've put xinput.lib in my project folder and added this line to a .pro file:
And of course added #include in the code.
It worked.