Results 1 to 6 of 6

Thread: wstring Visual studio 2005 - unresolved external symbol

  1. #1
    Join Date
    May 2010
    Posts
    46
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Question wstring Visual studio 2005 - unresolved external symbol

    Hi,
    i have a problem. I would convert a QString in a wstring. I think that this can be a solution:

    Qt Code:
    1. QString test = "TEST";
    2. wstring converted;
    3. converted = test.toStdWString();
    To copy to clipboard, switch view to plain text mode 

    But when compile my code i have this error:

    error LNK2019: unresolved external symbol "__declspec(dllimport) public: class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > __thiscall QString::toStdWString(void)const " (__imp_?toStdWString@QString@@QBE?AV?$basic_string @_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@ XZ) referenced in function "public: void __thiscall dbInterface::save(class QString)"(save@dbInterface@@QAEXVQString@@@Z)


    I think that the problem can be that i have setting the project proprieties "C/C++ Language Treat wchar_t as Built-in Type: YES".
    I have try to change this value at No (/Zc:wchar_t-) and the code compile correctly. Unfortunately for may project this setting must be "YES".

    How i can convert this QString in a wstring?

    Can anyone help me? Thanks, Bye

  2. #2
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: wstring Visual studio 2005 - unresolved external symbol

    Try a cast to wchart* first, and then initialize wstring with that:
    Qt Code:
    1. std::wstring converted = std::wstring((wchar_t*)test.unicode());
    To copy to clipboard, switch view to plain text mode 

  3. The following user says thank you to Zlatomir for this useful post:

    zoz (1st June 2010)

  4. #3
    Join Date
    Mar 2010
    Posts
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: wstring Visual studio 2005 - unresolved external symbol

    This is a linker error, so casting won't help. The problem here is that the linker cannot find the wstring class. You must link your application against msvcrt, which is the Visual C++ runtime. Check this link on MSDN for more.

  5. The following user says thank you to npclaudiu for this useful post:

    Zlatomir (14th May 2010)

  6. #4
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: wstring Visual studio 2005 - unresolved external symbol

    As far as i remember there where some casts that resolved this in VS2005... my bad, if that didn't work.

    But this should fix it: references to comsupp.lib (pragma or command line) should be changed to comsuppw.lib
    Last edited by Zlatomir; 14th May 2010 at 11:09.

  7. The following user says thank you to Zlatomir for this useful post:

    zoz (1st June 2010)

  8. #5
    Join Date
    May 2010
    Posts
    46
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: wstring Visual studio 2005 - unresolved external symbol

    Ok, i have solved whit the cast that you have write in first post. But now i have another problem:
    How i can convert a Wstring in a QString?

    I think that is possible whit:
    Qt Code:
    1. wstring test;
    2. QString converted = test.fromStdWString(test);
    To copy to clipboard, switch view to plain text mode 

    But i have the same linker error..

    Thaks, bye

  9. #6
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: wstring Visual studio 2005 - unresolved external symbol

    Try this:
    Qt Code:
    1. QString converted = QString((const QChar*)test.c_str(), test.length());
    To copy to clipboard, switch view to plain text mode 

  10. The following user says thank you to Zlatomir for this useful post:

    zoz (1st June 2010)

Similar Threads

  1. unresolved external symbol with qwt3d
    By pospiech in forum Qt Programming
    Replies: 6
    Last Post: 2nd February 2016, 21:47
  2. unresolved external symbol __imp__GetKeyState@4
    By TriKri in forum Qt Programming
    Replies: 0
    Last Post: 10th May 2010, 11:35
  3. unresolved external symbol
    By gridolfi in forum Qt Programming
    Replies: 1
    Last Post: 8th September 2009, 17:58
  4. unresolved external symbol
    By tgreaves in forum Qt Programming
    Replies: 2
    Last Post: 16th January 2009, 19:49
  5. Unresolved External Symbol
    By munna in forum General Discussion
    Replies: 1
    Last Post: 10th May 2006, 19:25

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.