Results 1 to 3 of 3

Thread: LNK1120: 1 unresolved externals for toUtf8 and assertion for QString::toStdString()

  1. #1
    Join Date
    Dec 2015
    Location
    Rome
    Posts
    16
    Thanks
    1
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Windows

    Default Re: LNK1120: 1 unresolved externals for toUtf8 and assertion for QString::toStdString

    Hi all,
    I am testing with a new QT5.5 project x86 under VS2015.
    Here is my little program:


    Qt Code:
    1. #include <QtCore/QCoreApplication>
    2. #include <QDebug>
    3. #include <QByteArray>
    4.  
    5.  
    6. 1 int main(int argc, char *argv[]){
    7. 2 QCoreApplication a(argc, argv);
    8. 3 QString message="1234567890";
    9. 4
    10. 5 std::string str=message.toStdString().c_str();
    11. 6 QByteArray a1=message.toUtf8();
    12. 7
    13. 8 qDebug()<<str.c_str();
    14. 9
    15. 10 return a.exec();
    16. 11 }
    To copy to clipboard, switch view to plain text mode 


    The troubles:
    1) After building I get error LNK2019: unresolved external symbol for QString::toUtf8() in 6);
    2) If I delete the line 6) and run the program I get:
    1) An assertion into minkernel\crts\ucrt\src\appcrt\heap\debug_heap.cpp in Debug mode;
    2) no 'apparent' problem in release mode.



    No problems under the QT Creator.

    What I can search for?


    Cheers,
    Giorgio


    Added after 21 minutes:


    I seen that setting 'Visual Studio 2013 (v120)' in project property page --> Configuration Properties --> Platform toolset
    the assertion does not happen and also the LNK2019 is solved.

    Can some one explain me in details the motive, please?

    Cheers.
    Giorgio


    Cheers,
    Giorgio
    Last edited by oop; 18th February 2016 at 15:13.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: LNK1120: 1 unresolved externals for toUtf8 and assertion for QString::toStdString

    Some earlier versions of Qt were built with the MSVC flag "treat wchar_t as a built-in type" set to FALSE. Current versions now have it set to TRUE. Look at the Properties->Configuration Properties->C/C++->Language page in MSVC. This would cause errors with conversion between QString and std:wstring / std::string.

    In addition, MSVC 2015 is not yet officially supported by Qt, whereas MSVC 2013 is. Using VS 2013 as the platform toolset changes some of the defaults and that allows a Qt app to compile and link without complaints.

    I assume that the upcoming Qt 5.6 release will have support for MSVC 2015. If not, continue to use the 2013 toolset setting.

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

    oop (18th February 2016)

  4. #3
    Join Date
    Dec 2015
    Location
    Rome
    Posts
    16
    Thanks
    1
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Windows

    Default Re: LNK1120: 1 unresolved externals for toUtf8 and assertion for QString::toStdString

    Thank you very much, I will keep in mind your kindly given info.

    Giorgio

Similar Threads

  1. Replies: 2
    Last Post: 7th September 2014, 16:02
  2. error unresolved externals
    By smemamian in forum Newbie
    Replies: 9
    Last Post: 3rd September 2014, 07:54
  3. Configuring Qt fow Wince (QtNetwork4.dll unresolved externals)
    By southerton in forum Installation and Deployment
    Replies: 0
    Last Post: 1st October 2010, 11:16
  4. Unresolved externals
    By MarkoSan in forum General Programming
    Replies: 3
    Last Post: 17th March 2007, 13:53
  5. What am I missing? Unresolved externals
    By derick in forum Qt Programming
    Replies: 49
    Last Post: 21st July 2006, 12:41

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.