Compiling on Visual studio 2013



  • Hello,

    I have created a graphical applications and works fine on linux and mingw version of qt on windows. I am trying to compile using visual studio (using qt-win-opensource-4.8.5-vs2008.exe), I get the following linking error (many more similar to this). I have understood this has still some dependency on mingw looking at the dllimport ( reading at this http://stackoverflow.com/questions/3704374/linking-error-lnk2019-in-msvc-unresolved-symbols-with-imp-prefix-but-shoul )

    Any support in fixing would be of great help.

    error LNK2001: unresolved external symbol "__declspec(dllimport) public: class QCursor & __thiscall QCursor::operator=(class QCursor &&)" (_imp??4QCursor@@QAEAAV0@$$QAV0@@Z) D:\project\projectgraphics.obj

    Thank you.
    Srikanth


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    The Qt package must match the Visual Studio Version, e.g. you can't use a Qt version built for VS2008 with VS2013.


  • Moderators

    Hi, welcome to devnet.

    You can't link Qt built with VS2008 with your app built using VS2013.

    Qt needs to be compiled with the same compiler you're using (no, VS versions are not compatible with each other).
    You can "build it yourself":http://qt-project.org/doc/qt-4.8/install-win.html (it takes some time) or download a "prebuilt package":http://www.tver-soft.org/qt64



  • Not sure about the VS2008 version. But I can confirm that the pre-compiled Qt 4.8.6 DLL's for VS2010 work just fine with VS2012 and VS2013. Of course you will need to ship both, the VS2010 and the VS2012/VS2013 runtime libraries - which is why I do prefer building Qt with VS2012/VS2013 myself.

    FWIW, my own Qt 4.8.6 libraries built with VS2013 can be found here:
    http://goo.gl/pYcmKl


  • Moderators

    [quote author="MuldeR" date="1403650710"]Not sure about the VS2008 version. But I can confirm that the pre-compiled Qt 4.8.6 DLL's for VS2010 work just fine with VS2012 and VS2013. [/quote]

    Have you tried to use eg. QString::fromStdString()? The std::string (and other containers too) size changed by few bytes between these versions so I wouldn't be surprised if you got some strange (and subtle!) bugs because of this. I would highly discourage from doing that, at least in production builds.



  • [quote author="Chris Kawa" date="1403652126"][quote author="MuldeR" date="1403650710"]Not sure about the VS2008 version. But I can confirm that the pre-compiled Qt 4.8.6 DLL's for VS2010 work just fine with VS2012 and VS2013. [/quote]

    Have you tried to use eg. QString::fromStdString()? The std::string (and other containers too) size changed by few bytes between these versions so I wouldn't be surprised if you got some strange (and subtle!) bugs because of this. I would highly discourage from doing that, at least in production builds.[/quote]

    Well, not that function in particular, because I usually prefer Qt containers over STL. But I'm building with the pre-compiled (MSVC 2010) Qt DLL's all the time during development and haven't encountered any problems yet. For the release builds I use my own static Qt libraries (MSVC 2013), but building the application statically all the time simply is too slow for development ;-)

    Here's an example an how it usually works flawlessly:
    http://www.mediafire.com/download/4z928hhigj71nl6/qt-msvc2010-msvc2013-test.rar

    So I think srikanth9's problem is more a missing .lib file in his linker settings.


  • Moderators

    As long as you're using only Qt types you might (might!) be ok. That is until someone in MS decides to change a default alignment on some struct or you include another 3rd party library that is not so restrained. The problematic classes are those that interact with stl or platform specific classes/libraries (Windows SDK structs change too, not that often but they do).

    Your example proves only that you're lucky or use a subset of Qt that just happens to be binary compatible, nothing more ;)

    You might be right about the missing library linkage in this case though.



  • Thank you.
    I have followed Robot Herder's suggestion and downloaded the correct version. Its now works fine. I am compiling the debug/release version of qt 4.8.6 with vs2013

    --Srikanth


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.