我想从我使用 Qt 5.9.2 MinGW 32bit 创建的应用程序中使用通过 WinRT API 可用的库(如这些)。我有 Windows 10 操作系统。
现在,我已经设置了一个套件,如下所示。
然后,在.pro
文件中,我添加了:
CONFIG += c++1z
SOURCES += main.cpp
### Windows 10 SDK
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/'../../../../Program Files (x86)/Windows Kits/10/Lib/10.0.16299.0/um/x86/' -lWindowsApp
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/'../../../../Program Files (x86)/Windows Kits/10/Lib/10.0.16299.0/um/x86/' -lWindowsApp
INCLUDEPATH += $$PWD/'../../../../Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/shared'
DEPENDPATH += $$PWD/'../../../../Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/shared'
INCLUDEPATH += $$PWD/'../../../../Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/um'
DEPENDPATH += $$PWD/'../../../../Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/um'
INCLUDEPATH += $$PWD/'../../../../Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/ucrt'
DEPENDPATH += $$PWD/'../../../../Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/ucrt'
INCLUDEPATH += $$PWD/'../../../../Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.12.25827/include'
DEPENDPATH += $$PWD/'../../../../Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.12.25827/include'
INCLUDEPATH += $$PWD/../ne-patient-app-libraries/cppwinrt/10.0.16299.0/
DEPENDPATH += $$PWD/../ne-patient-app-libraries/cppwinrt/10.0.16299.0/
我cppwinrt
从GitHub 代表和 Windows 10 SDK 从Windows Dev Center获得。
我只是添加了一些行main.cpp
来测试正确的编译:
#include <QCoreApplication>
#include <winrt/Windows.Devices.WiFi.h>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
WiFiAdapter wiFiAdapter;
return a.exec();
}
运行qmake
and后build
,我收到以下错误:
C:\Program Files (x86)\Windows Kits\10\Include\10.0.16299.0\ucrt\corecrt_stdio_config.h:31: 错误:#error 不支持的架构 #error 不支持的架构 ^
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.12.25827\include\new:23: 错误:#error Unsupported architecture #error Unsupported architecture ^
C:\Program Files (x86)\Windows Kits\10\Include\10.0.16299.0\um\winnt.h:1008: error: #error 必须定义目标架构。#error 必须定义目标架构。^
...以及来自文件的其他内容:corecrt_stdio_config.h
, winnt.h
, oaidl.h
, DirectXMath.h
,vcruntime.h
和yvals.h
.
这是编译器运行的详细构建命令:
g++ -c -fno-keep-inline-dllexport -g -std=gnu++1z -Wextra -Wall -W -fexceptions -mthreads -DUNICODE -D_UNICODE -DQT_DEPRECATED_WARNINGS -DQT_QML_DEBUG -DQT_CORE_LIB -I../uwp-test -I. -I"../../../../Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/shared" -I"../../../../Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/um" -I"../../../../Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/ucrt" -I"../../../../Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.12.25827/include" -I../ne-patient-app-libraries/cppwinrt/10.0.16299.0 -I../../../../Qt/5.9.2/mingw53_32/include -I../../../../Qt/5.9.2/mingw53_32/include/QtCore -Idebug -I../../../../Qt/5.9.2/mingw53_32/mkspecs/win32-g++ -o debug/main.o ../uwp-test/main.cpp
我错过了什么?什么可以解决问题?谢谢!