1

我对 C++ 编程和 Qt 比较陌生,所以这个问题可能是我对相互依赖的理解缺失。我正在尝试在我的源代码中使用 Xinput.h 文件,该文件是带有 Qt 创建者的 DirectX SDK 的一部分。我有我的解决方案的工作源代码,可以在 Visual Studio 2008 中编译和执行,但是当我在 Qt 中使用它时,没有头文件丢失。我尝试使用内置的库加法器导入 XInput.dll

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

然而,这无法编译给我 '_in' 没有在这个范围内声明,有谁知道我可以如何解决这个问题?

_in 和 _out 错误来自 Direct X SDK 中包含的 Xinput.h 头文件。

DWORD WINAPI XInputGetState
(
    __in  DWORD         dwUserIndex,  // Index of the gamer associated with the device
    __out XINPUT_STATE* pState        // Receives the current state
);

我想我会为任何不确定发生了什么的人提供一个演示:

QT 的 .Pro 文件:

QT += 核心

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

然后我只是尝试将 Xinput.h 包含在我的源文件中,然后我收到大量可怕的消息。Windows VS 2008 让我来做

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

它有效吗?

4

1 回答 1

0

I've put xinput.lib in my project folder and added this line to a .pro file:

win32: LIBS += -lXInput

And of course added #include in the code.

It worked.

于 2014-05-14T13:08:05.247 回答