0

I've tried this in QtCreator and Visual Studio 2015. I've played with different configurations and as far as I can tell I've got the environment setup correctly.

However, whenever I make an API call (so far I've only been trying WiFi Direct calls) and build in Release mode I get this error.

C2664   'long __winRT::__getActivationFactoryByPCWSTR(void *,Platform::Guid &,void **)': cannot convert argument 1 from 'const wchar_t [60]' to 'void *'

In Debug I get these errors in Visual Studio 2015.

Error   LNK2038 mismatch detected for '_MSC_VER': value '1800' doesn't match value '1900' in main.obj qtmaind.lib(qtmain_win.obj)

Error   LNK2001 unresolved external symbol "public: virtual struct QMetaObject const * __thiscall MainWindow::metaObject(void)const " (?metaObject@MainWindow@@UBEPBUQMetaObject@@XZ)   PROJECT     mainwindow.obj

Error   LNK2001 unresolved external symbol "public: virtual void * __thiscall MainWindow::qt_metacast(char const *)" (?qt_metacast@MainWindow@@UAEPAXPBD@Z) SSLocalServer   mainwindow.obj

Error   LNK2001 unresolved external symbol "public: virtual int __thiscall MainWindow::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@MainWindow@@UAEHW4Call@QMetaObject@@HPAPAX@Z)    mainwindow.obj

Error   LNK2019 unresolved external symbol "__declspec(dllimport) char const * __cdecl std::_Winerror_map(int)" (__imp_?_Winerror_map@std@@YAPBDH@Z) referenced in function "public: virtual class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall std::_System_error_category::message(int)const " (?message@_System_error_category@std@@UBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@H@Z) qtmaind.lib(qtmain_win.obj) 

Simple question first. Is it even possible with the current version of Qt 5.6 to use the WinRT API (Specifically WiFi Direct) in a Desktop application?

If it is, what am I missing?

Edit -- My test project. Qt directories will probably need to be changed.

Simurr
  • 672
  • 1
  • 4
  • 19
  • Are you sure that the copy of Qt you're using has been compiled with the same compiler you're using to compile your application? [This question](http://stackoverflow.com/q/19575747/1329652) is about that very issue. – Kuba hasn't forgotten Monica May 03 '16 at 18:58
  • Please add a minimum example that reproduces the issue. Make sure you include the complete `.pro` file, the complete `main.cpp` (it should be the only other source file you have), and the link to your copy of Qt binaries, or the `configure` line you used to compile your copy of Qt. – Kuba hasn't forgotten Monica May 03 '16 at 19:01
  • @KubaOber test project added. I did not compile my own version of Qt. This is the community version of 5.6 which appears to have it's debug msvc 2015 debug libraries compiled with a different version of msvc. – Simurr May 03 '16 at 19:53
  • You'd be really hard pressed to develop with Qt without compiling it on your own. I suggest you do just that, otherwise it'll be hard to reproduce this problem as this might be a packaging issue and nothing else. I don't use any prebuilt Qt, so at least myself I can't test it. – Kuba hasn't forgotten Monica May 03 '16 at 20:12
  • @KubaOber compiling my own version of Qt 5.6.0 resulted in the exact same errors. This makes the MSC_VER error make no sense at all and also makes me think I'm missing some configuration option or some configuration of Qt 5.6 is causing the problem. – Simurr May 16 '16 at 16:22

1 Answers1

0

Some macro in MS headers expands wrong and tries to pass a wrong thing to __getActivationFactoryByPCWSTR. You need to figure out why it happens. Qt desktop apps are not special, they are just like any other desktop app: if any desktop app can use these APIs, then a Qt desktop app can, too.

Alas, the desktop apps can only use a subset of Windows Runtime APIs. Wifi Direct is not listed there. Perhaps you should be using the desktop WiFi direct APIs instead - they are more portable.

Kuba hasn't forgotten Monica
  • 95,931
  • 16
  • 151
  • 313
  • Thank you for answering, but how is that helpful? If ANY desktop app can use those API's, why does Qt fail? What is different? This does give me an idea to look through the examples and see if something is defined in the project that is missing in mine. – Simurr May 03 '16 at 18:49
  • @Simurr Qt is not a thing in this respect. The only effect Qt can have on your code is via the project configuration (your .pro or cmake file) and the mkspecs used to build Qt proper. I'm not seeing that issue so far. – Kuba hasn't forgotten Monica May 03 '16 at 19:00
  • The [Windows.Devices.WiFiDirect](https://msdn.microsoft.com/library/windows/apps/windows.devices.wifidirect.aspx) namespace is available for desktop applications (it simply wraps the native [Wi-Fi Direct functions](https://msdn.microsoft.com/en-us/library/windows/desktop/dn457945.aspx)). To verify this, you can pick any class and check for the [DualApiPartition](https://msdn.microsoft.com/en-us/library/windows/apps/windows.foundation.metadata.dualapipartitionattribute.aspx) attribute. – IInspectable May 04 '16 at 15:01