In Visual Studio I included: using namespace Windows::Devices::Enumeration; and it works. When adding/including namespaces in Qt I get errors. Any documentation how to use UWP API with Qt?
For example:
.h
#include <windows.devices.enumeration.h>
.cpp
DeviceAccessInformation deviceInfo;
I get error: C2065: 'DeviceAccessInformation': undeclared identifier
Update:
I have found some information related the issue. So I have added the Win SDK path (INCLUDEPATH += "C:/Program Files (x86)/Windows Kits/10/Include/10.0.16299.0") to the .pro file. Also added the #include "winrt/windows.devices.enumeration.h" to the header file but it still can't find the DeviceAccessInformation deviceInfo;, throws error: C2065: DeviceAccessInformation: undeclared identifier.
Also I have checked the samples, and add the namespace.
using namespace winrt;
and it displays the error: C2871: 'winrt': a namespace with this name does not exist
Also I have noticed the warning: -1: warning: winrt_manifest_install.path is not defined: install target not created
I have included the WindowsApp library but the issue still exists.
contains(QMAKE_TARGET.arch, x86_64) {
LIBS += -L"C:/Program Files (x86)/Windows Kits/10/Lib/10.0.16299.0/um/x64" -lWindowsApp
} else {
LIBS += -L"C:/Program Files (x86)/Windows Kits/10/Lib/10.0.16299.0/um/x86" -lWindowsApp
}
I think the problem is with the wrong includes or I missing something.
Update 2:
Can anyone confirm that Qt 5.9.3 UWP x32/x64 kits work with UWP API? Thanks in advance.
I have decided to develop native UWP app using Visual Studio even though I fixed the issue by installing Qt extension for VS and switching Win SDK kit to 16299.
Related
OS -Windows 10 x64
Library mqtt
Microsoft Visual Studio Community 2017 Version 15.9.15
Programming Language - C++17
Installed paho-mqtt paho-mqttpp3 paho-mqttpp3[ssl] using vcpkg
I am creating a c++ program using mqtt.
But whenever I am using below given header
#include <mqtt/async_client.h>
It is giving following error
d:\vcpkg\installed\x64-windows\include\mqtt\async_client.h(27): fatal error C1083: Cannot open include file: 'MQTTAsync.h': No such file or directory
But MQTTAsync.h file is available on the given location
D:\vcpkg\installed\x64-windows\include\paho-mqtt
I had followed below link by creating new console project
https://github.com/Microsoft/vcpkg/issues/1848
Still issue is not getting resolved
Verify the correct name in your vcpkg-directory.
In my case that would be C:\Users\USERNAME\vcpkg\installed\x64-windows\include\paho-mqtt
Here you will see that the header file you are looking for is actually called MQTTAsync.h
To add it in your project you will have to change your inlcude to #include <paho-mqtt/MQTTAsync.h>
I have a requirement to use XGBoost within a Visual C++ project DLL.
I have been able to download and build the XGBoost source using VC++ and CMake.
When I include the XGBoost code in a test console application, it works fine.
However, when I try to replicate what I've done with the console application in a DLL project, it won't compile.
I am struggling to even use a basic XGBoost type within the project.
I suspect the problem is my ignorance with DLL projects and would appreciate your help.
Here's what's happening in my DLL project:
When I use the following include as the very first line in a cpp class file, it compiles:
#include <xgboost\c_api.h>
With it compiling, if I try to use a simple type defined in this include file, the build fails with the following message:
...\dll_test\xgb_driver.cpp(20): error C2065: 'BoosterHandle': undeclared identifier
This is the line that causes the error:
BoosterHandle my_handle;
"BoosterHandle" is in fact defined in <xgboost\c_api.h>
When I put the include below any other include, I get the following error messages:
1>c:\tools\src\xgboost\include\xgboost\c_api.h(29): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\tools\src\xgboost\include\xgboost\c_api.h(29): error C2146: syntax error: missing ';' before identifier 'bst_ulong'
Below is a little more information on what I did to get XGBoost working with a console app and how I created the DLL project.
=-=-=-=-=-=
Here's what I did to use XGBoost with a console. Everything about it seems to work. I've tested the model predictions, and they are
consistent with what I'm seeing in R.
Using the documentation found here:
https://xgboost.readthedocs.io/en/latest/build.html
I downloaded the XGBoost source and built it using CMake and Visual Studio 2015.
Under Project > Linker > Input > Additional Dependencies,
I added the xgboost.lib file
Under Project > Linker > General > Additional Library Directories
I added a reference to ...\xgboost\build\Release
Under Project > VC++ Directories > Include Directories
I added the path to ...\xgboost\rabit\include and ...\xgboost\include
I put the xgboost.dll in the directory where the .exe is generated.
From here, it was smooth sailing.
=-=-=-=-=-=
Here's what I've done to create a Visual C++ DLL Project:
After choosing File > New > Project, I select an ATL DLL Project (this is part of the project requirement).
For the XGBoost include to the project, I repeated steps 1-5 above, but placed the xgboost.dll file where the
project DLL would be generated.
Here is the source for the header file for the simple class I have created:
#pragma once
class XGB_Driver
{
public:
XGB_Driver();
~XGB_Driver();
float callXGB(float sample_input);
};
Here is the source for the simple cpp file:
#include <xgboost/c_api.h>
#include "stdafx.h"
#include "XGB_Driver.h"
XGB_Driver::XGB_Driver()
{
}
XGB_Driver::~XGB_Driver()
{
}
float XGB_Driver::callXGB(float simple_input) {
BoosterHandle my_handle;
return(0);
}
Why this doesn't work for the ATL DLL project, but does for the console app really has me banging my head against the keyboard.
Your help would be very much appreciated.
Best,
Dave
With the help of CristiFati, I believe this question has been answered.
For whatever reason, it seems that using XGBoost with C++ in a DLL project requires additional includes above and beyond what is required for using it in a console application.
I am currently building the DLL project with the addition of:
#include <cstdint>
I've succcessfully build native WebRTC and got webrtc.lib file in result. Then i was trying to setup Visual Studio 2017 simple project to use webrtc and I pointed include and library directory and also in dependencies added webrtc.lib. For some reason just simple code like this:
#define WEBRTC_WIN
#include<iostream>
#include<api/mediastreaminterface.h>
int main(int argc, char** argv)
{
return 0;
}
generates around 100 errors mainly about min and max functions and rtc::rtc namespace which is weird looks like somehow all rtc::x calls it interprets as rtc::rtc:x for example
Error C2039 'scoped_refptr': is not a member of 'rtc::rtc' webrtctest c:\libwebrtc\webrtc\src\api\mediastreaminterface.h 287
I've tried to download already compiled versions with different include files but got same errors. Also there is an error saying
Error C2059 syntax error: 'namespace' webrtctest c:\libwebrtc\webrtc\src\rtc_base\messagequeue.h 33
which is pointing to this line:
namespace rtc {
I've downloaded latest branch-69, and my windows sdk version is 10.0.17134.0
I've managed to make it work. I had to add #define NOMINMAX on top of everything because there were macros inside of windows.h with same name.
I have downloaded from GitHub directory cppwinrt it contains the header files to use UWP API with Qt. The Qt version is 5.9.3.
I have included it in .pro file:
INCLUDEPATH += "C:/Users/cobra/Downloads/Downloads Data/cppwinrt/10.0.16299.0"
.h file:
#include <winrt/windows.devices.enumeration.h>
#pragma comment(lib, "windowsapp")
using namespace winrt;
using namespace winrt::Windows::Devices::Enumeration;
.cpp file:
init_apartment(); //this initializes com
DeviceInformationCollection infos = DeviceInformation::FindAllAsync().get();
for (const auto &info : infos) {
qDebug() << QString::fromWCharArray(info.Name().c_str());
}
I want to get some device information. The problem is, it compiles only for ARMV7 kit. On x32/x64 kits it displays a lot of errors:
I have checked it and all errors are from cppwinrt directory where the header files located. How to fix it to build for x32/x64 kits?
Update:
Without UWP API includes, the application compiles and runs.
Thanks in advance.
I have fixed the issue by installing Qt extension to Visual Studioand selecting Win SDK to 10.0.16299.0, now it compiles for all architectures.
I am a bit stuck at the moment with a little sample project that I would like to run to test some cryptology that I want to use in a main project.
Basically I am using the latest Qt Creator and I have created a simple window dialog. Furthermore, I would like to test the PBKDF2 implementation through CkCrypt2
So what I have done is downloading the X64 version of the library and added it to my project folder. I then told my Qt project to use an external library, the final .pro file looks like this:
#-------------------------------------------------
#
# Project created by QtCreator 2013-06-09T18:09:44
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = crypt2test
TEMPLATE = app
SOURCES += main.cpp\
m
ainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/libs/ -lChilkatDbgDll_x64
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/libs/ -lChilkatDbgDll_x64d
else:unix: LIBS += -L$$PWD/libs/ -lChilkatDbgDll_x64
INCLUDEPATH += $$PWD/include
DEPENDPATH += $$PWD/include
I can successfully load the library but I cannot start the application.
My mainwindow.cpp looks like this:
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "CkCrypt2.h"
#include <QDebug>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
CkCrypt2 crypt;
bool success;
success = crypt.UnlockComponent("Just some random text ");
if ( !success )
{
qDebug() << "Not successfully unlocking the library";
}
}
MainWindow::~MainWindow()
{
delete ui;
}
The error message I get in the compiler is:
c:\qt\qt5.0.2\tools\qtcreator\bin\crypt2test\include\CkString.h:127: error: C2061: syntax error : identifier 'SYSTEMTIME'
c:\qt\qt5.0.2\tools\qtcreator\bin\crypt2test\include\CkString.h:129: error: C2061: syntax error : identifier 'SYSTEMTIME'
C:\Qt\Qt5.0.2\Tools\QtCreator\bin\crypt2test\include\CkCrypt2.h:429: error: C2061: syntax error : identifier 'SYSTEMTIME'
Looking into the files I see:
void appendDateRfc822(SYSTEMTIME &sysTime);
void appendDateRfc822Gmt(SYSTEMTIME &sysTime);
// GETSIGNATURESIGNINGTIME_BEGIN
bool GetSignatureSigningTime(int index, SYSTEMTIME &outSysTime);
// GETSIGNATURESIGNINGTIME_END
Okay, so it is complaining about the SYSTEMTIME construct. So I look up the error C2061
Basically it says:
The compiler found an identifier where it wasn't expected. Make sure
that identifier is declared before you use it.
Which makes sense, so I look up the SYSTEMTIME and try to do :
#include <windows.h>
But that leads to many more errors in the windows.h file itself.
I use the MS Visual C++ compiler in Qt. Even though I use qmake. I am very new to this and I do not understand it all yet. Furthermore, I have no idea how to fix this, because including the windows.h does not help.
What seems to be the problem here ? Is this an issue regarding my compiler or the constulation that I use a third party app which library is compiled with MS Visual C++ and I am now trying to use this on my Windows machine in Qt with a Windows Visual C++ compiler ?
For any help I am gratefully thankful!
EDIT1:
Actually, after a clean all and qmake and build project I have now different errors and none were found in the Windows.h as previously stated. Since there were so many I have made a screenshot: http://i.imgur.com/B8EoENB.png
EDIT2:
I have adjusted the library that I include. Before this I was using the multi-threaded library of CkCrypt in the Debug mode. I have now included the single realease library. Which is located in the same directory.
When including windows.h I got the errors that things were already defined. So I removed the line again. With this result: http://i.imgur.com/z415txR.png
This shows at the bottom that MSVCRT conflichts with other library. It mentions to use NODEFAULTLIB:library but I am not to sure how to do that. Will google and keep this up to date as I process.
Many years ago, Chilkat was originally developed for the Windows platform only, and used SYSTEMTIME for this reason. In the last 5 years (approx) Chilkat is cross-platform, and SYSTEMTIME no longer makes sense. To cope with the issue, there is a "SystemTime.h" header in the same directory as the CkCrypt2.h header file. You could include this to solve the problem. (However, if WIN32 is defined, you'll probably need to edit SystemTime.h to remove the #ifdef.)
In any case, the methods using SYSTEMTIME are going to be deprecated. For any method or property that uses SYSTEMTIME, there should be a newer alternative method/property that instead uses CkDateTime.
Finally, Chilkat will test with Qt so that for the next version, (hopefully) Qt out-of-the-box will compile without any pitfalls.