PDA

View Full Version : WCHAR to QString giving error in vs2005



ucomesdag
26th November 2006, 15:43
When using QString::fromWCharArray(const wchar_t* , int size = - 1);

vs2005 gives the following error:

error LNK2019: unresolved external symbol "__declspec(dllimport)
public: static class QString __cdecl QString::fromWCharArray(wchar_t const *,int)"
(__imp_?fromWCharArray@QString@@SA?AV1@PB_WH@Z) referenced in function "public:
void __thiscall midiIO::queryMidiInDevices(void)" (?queryMidiInDevices@midiIO@@QAEXXZ)


To fix this, go to Project --> Properties --> Configuration Properties -->
C/C++ --> Language, and set 'Treat wchar_t as Built-in Type' to No.

Hope it helps someone, it fixed my day...

wysota
9th December 2006, 12:05
Thanks for the info. Maybe you could add it to our wiki as well?

SteveT
1st May 2008, 23:25
I am a new Qt user. I am having this same issue on a project that I am currently on. I am linking into my Qt VS2005 project libraries that have the compiled with "Treat wchar_t as Built-in Type" set to "Yes". Third party libraries also appear to have been built this way. My Qt project file therefore sees unresolved externals when I call from the Qt project file into a libary. If, in my Qt project file I set the option to "No(/Zc:wchar_t-)" then my external libraries link just fine but Qt then has issues with the methods called by QString (such as ::fromStdWString() which then cannot link properly).

How do I use Qt with libaries built with "Yes" for "Treat wchar_t as Built-in Type"?

Steve