Results 1 to 6 of 6

Thread: Visual Studio compiling Qt code report LNK2019

  1. #1
    Join Date
    Nov 2015
    Posts
    3
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Talking Visual Studio compiling Qt code report LNK2019

    Hi, everybody.

    I'm new to Qt and I'm currently working on a module of a project(an assignment of a course in my school). The UI is created using Qt (by another fellow in my group), so I have to use classes like QString and QDir and so on. But I'd like to use VS instead of QtCreator to do the coding since I'm not drawing the UI.

    I downloaded the latest Qt 5.5 open-source version for Windows from its website. Its root folder is D:\Qt\5.5\msvc2013_64. Inside I found the "lib" folder with many ".lib" files and "include" folder with relevant headers. So I imported both of them into my VS project. And I added the "Qt5Cored.lib" to my VS project's "Additional Dependencies" option of the linker.

    I wrote a very simple test to see if this configuration works. (Using QString and QDir).

    But the linker constantly report LNK2019 on QString::QString and QDir::setPath and many other Qt's stuff.

    What am I doing wrong or I simply can't do Qt-coding in VS without an add-in?

    Thanks in advance.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Visual Studio compiling Qt code report LNK2019

    You need to match the compiler, bit-ness (is that a word?), and debug/release mode the Qt libraries were built with. The Qt5Cored.dll is a debug library and you have a 64-bit MS VC2013 version of Qt. Are you attempting to compile your program as a debug version with a 64-bit MSVC 2013?

  3. #3
    Join Date
    Nov 2015
    Posts
    3
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Visual Studio compiling Qt code report LNK2019

    Yes I'm using 64-bit Windows and Visual Studio 2013 (I guess it's also 64-bit because I searched this and Microsoft doesn't provide 32 or 64 VS installer seperately.).

    I'm compiling a Debug configuration of my program in Visual Studio 2013.

    I installed Qt 5.5 using the online-installer from Qt's official website. According to the installer's reference manual page, it will match the compiler on my system and select the matched pre-built Qt libraries to download. I checked this by clicking Tools->Options->Build & Run in QtCreator and I got the following list of compilers detected (and used by QtCreator):
    Microsoft Visual C++ Compiler 12.0 (x86) MSVC
    Microsoft Visual C++ Compiler 12.0 (amd64) MSVC
    Microsoft Visual C++ Compiler 12.0 (x86_amd64) MSVC
    Microsoft Visual C++ Compiler 12.0 (x86_arm) MSVC
    Microsoft Visual C++ Compiler 12.0 (amd64_arm) MSVC

    The same piece of code can compile and run perfectly on my machine without any problem if I use QtCreator instead of Visual Studio. So I'm guessing there's some configuration options that I'm missing in my VS project.

  4. #4
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Visual Studio compiling Qt code report LNK2019

    Install Visual Studio Addin. This tool integrades Qt and Visual Studio IDE.

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

    threedts167 (10th November 2015)

  6. #5
    Join Date
    Nov 2015
    Posts
    3
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Visual Studio compiling Qt code report LNK2019

    I have Installed the Visual Studio Addin.

    But I still got the same linker errors, and I turned on the /VERBOSE switch I can see that Qt5Cored.lib is marked as "unused library", which is strange because my test code is as follows.

    Qt Code:
    1. #include <iostream>
    2.  
    3. #include <QtCore/QtCore>
    4.  
    5. using namespace std;
    6.  
    7. int main()
    8. {
    9. QString strPath1 = "D:/TestCDir";
    10. QString strPath2 = "D:/TestCDir/Tmp";
    11. QDir dir;
    12. dir.setPath(strPath1);
    13. if (!dir.exists())
    14. dir.mkpath(strPath1);
    15. dir.setPath(strPath2);
    16. if (dir.count() == 0)
    17. dir.rmpath(strPath2);
    18. else
    19. cout << dir.count() << endl;
    20. dir.setPath(strPath1);
    21. dir.rmpath(strPath1);
    22. return 0;
    23. }
    To copy to clipboard, switch view to plain text mode 

  7. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Visual Studio compiling Qt code report LNK2019

    If you build your project in release mode then Qt5Cored.dll will be unused because the "d" in the library name means "debug". Your program should be linked to Qt5Core.dll

Similar Threads

  1. Compiling QT 5.3.2 with Visual studio 2005
    By Buldozer in forum Installation and Deployment
    Replies: 2
    Last Post: 23rd October 2014, 07:21
  2. compiling Qt with visual studio
    By jello in forum Newbie
    Replies: 0
    Last Post: 13th April 2010, 20:32
  3. Problem compiling under visual studio
    By franco.amato in forum Qt Programming
    Replies: 1
    Last Post: 28th October 2009, 17:53
  4. C++ Compiling Errors when use Visual Studio 6.0
    By seguprasad in forum General Programming
    Replies: 1
    Last Post: 3rd February 2009, 11:47
  5. Compiling Qt with Visual Studio
    By circle in forum Newbie
    Replies: 4
    Last Post: 14th April 2008, 17:04

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