1
votes

I am trying to solve the following issue: I've got a library which uses C++Amp. The library compiles without any warnings and the unit-tests indicate that everything is working. I have a QT-based project which is a GUI for this library and here the problems begin. Everytime I am compiling the GUI, in the linking stage a get the following errors:

widgets.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) private: unsigned short const * __cdecl Concurrency::accelerator::_Get_device_path(void)const " (_imp?_Get_device_path@accelerator@Concurrency@@AEBAPEBGXZ) referenced in function "void __cdecl `dynamic initializer for 'public: static class std::_Future_error_category std::_Future_error_object::_Future_object''(void)" (??__E?_Future_object@?$_Future_error_object@H@std@@2V_Future_error_category@2@A@@YAXXZ)

The library is linked to lib file, not dll.

Same story goes for other object files in the project. Did anyone have a similar problem at the linking stage when using C++Amp. I am sure that it is a very simple problem to solve but at the moment I have no idea how I could do it. Thanks in advance.

Update: the same happens when I am trying to include in the QT project in MSVC++.

1
I'm assuming that you get a whole load of these? It looks like you are not linking the AMP binaries into your QT project.Ade Miller
Yes, I'm getting a lot of them. Actually I have a static lib project (ccilib) and it is a static library (lib file) and the problem occures when I am trying to run my QT project (GUI) which is linked with cci project. How should I link the AMP binaries?Paweł Jastrzębski
You have a compiler setting wrong. You cannot get the code linked until you reset the C/C++, Language, Treat wchar_t as built-in type back to the default. You will need to use this setting consistently in all your compiled code, including Qt.Hans Passant
How should I change it for QT? Recompile?Paweł Jastrzębski
I set it just as you said and it still doesn't work.Paweł Jastrzębski

1 Answers

2
votes
  __imp_?_Get_device_path@accelerator@Concurrency@@AEBAPEBGXZ

Running the undname.exe utility on that string to unmangle the name, I get:

  declspec(dllimport) private: 
  unsigned short const * __ptr64 
  __cdecl Concurrency::accelerator::_Get_device_path(void)const __ptr64

So it is 64-bit code. Looking in vc/lib/amd64/vcamp.lib for a closest match, I find:

 ?_Get_device_path@accelerator@Concurrency@@AEBAPEB_WXZ

Which demangles with undname.exe to:

 private: 
 wchar_t const * __ptr64 
 __cdecl Concurrency::accelerator::_Get_device_path(void)const __ptr64

Note the discrepancy. Your function got compiled to return unsigned short*, the library function returns wchar_t*. You have a compiler setting wrong. Project + Properties, C/C++, Language, Treat WChar_t As Built in Type must be set to the default, "Yes".