Results 1 to 8 of 8

Thread: Link error when compiling Qt 5.1.0 project in Visual Studio 2010

  1. #1
    Join Date
    Aug 2010
    Posts
    99
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Question Link error when compiling Qt 5.1.0 project in Visual Studio 2010

    Hi,

    A while ago i upgraded from Qt 4.x to 5.1.0. I then got a new computer (Windows 7, 64 bit) on which i installed a clean 5.1.0. But i have never been able to successfully compile my project with 5.1.0. Now i've come back to the project to try again, and it all seems to be compiling ok, but when it gets to linking it says it cannot find "qtmaind.lib":

    2>------ Rebuild All started: Project: Window Detective, Configuration: Debug Win32 ------
    2>Build started 2/01/2014 1:05:13 PM.
    2>_PrepareForClean:
    2> Deleting file "Debug\obj\Window Detective.lastbuildstate".
    2>InitializeBuildStatus:
    2> Touching "Debug\obj\Window Detective.unsuccessfulbuild".
    2>CustomBuild:
    2> Moc'ing ...
    ...
    2> Rcc'ing qt_resources.qrc...
    2>ClCompile:
    2> Window.cpp
    ...
    2> Generating Code...
    2>LINK : fatal error LNK1104: cannot open file 'qtmaind.lib'
    2>
    2>Build FAILED.
    2>
    2>Time Elapsed 00:07:50.17
    ========== Rebuild All: 1 succeeded, 1 failed, 0 skipped ==========
    I have installed Qt to "C:\dev\Qt". I have the Qt Visual Studio addon, which i think should set the QtDir variable itself, and the project's library directories is set to "$(QtDir)\lib;$(LibraryPath)". I've also added "qtmaind.lib" to the list of additional dependencies.

    Below is the linker command line:
    /OUT:"C:\dev\projects\Window Detective\src\..\Window Detective.exe" /VERBOSE /NOLOGO "Psapi.lib" "qtmaind.lib" "Qt5Cored.lib" "Qt5Guid.lib" "Qt5Widgetsd.lib" "Qt5Xmld.lib" "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" "C:\dev\projects\Window Detective\src\hook\Debug\WD_Hook.lib" /MANIFEST /ManifestFile:"Debug\obj\Window Detective.exe.intermediate.manifest" /ALLOWISOLATION /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"C:\dev\projects\Window Detective\src\Debug\Window Detective.pdb" /SUBSYSTEM:WINDOWS /PGD:"C:\dev\projects\Window Detective\Window Detective.pgd" /TLBID:1 /DYNAMICBASE /NXCOMPAT /MACHINE:X86 /ERRORREPORT:QUEUE
    As you can see, the library is mentioned there, and it definitely exists on disk, so i cannot see why the linker cannot find it.
    Last edited by xtal256; 2nd January 2014 at 02:22. Reason: changed code tags to quote
    [Window Detective] - Windows UI spy utility
    [War Thunder]

  2. #2
    Join Date
    Aug 2010
    Posts
    99
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Link error when compiling Qt 5.1.0 project in Visual Studio 2010

    Just to mention, i get the same problem when compiling in release mode - it cannot find "qtmain.lib".

  3. #3
    Join Date
    Aug 2010
    Posts
    99
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Link error when compiling Qt 5.1.0 project in Visual Studio 2010

    After reading some similar posts, i thought i might need to build Qt. I'm looking at Installing Qt for Windows, but i'm not quite sure what options i want and where to install it to.
    I already have Qt "installed" at C:\dev\Qt, where i see the following directory structure:
    C:\dev\Qt
    ----5.1.0
    --------msvc2010_opengl
    ------------bin
    ------------doc
    ------------examples
    ------------imports
    ------------include
    ------------lib
    ------------mkspecs
    ------------phrasebooks
    ------------plugins
    ------------qml
    ------------translations
    --------src
    ------------qtactiveqt
    ------------qtbase
    ------------qtdeclarative
    ------------qtdoc
    ------------qtgraphicaleffects
    ------------qtimageformats
    ------------...
    ----Licenses
    ----Tools
    ----vcredist
    ----VSAddin


    So if i ran "configure.exe", would i need to specify "C:\dev\Qt\5.1.0\msvc2010_opengl\" as the location, or just "C:\dev\Qt\5.1.0\" or what?
    I thought i installed the pre-build package, so i don't even know if i need to run configure.

    EDIT: Sorry for the crappy formatting on the directory listing, the forum collapses spaces (and turns no-break spaces into asterisks).
    Last edited by xtal256; 5th January 2014 at 11:24.

  4. #4
    Join Date
    Aug 2010
    Posts
    99
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Link error when compiling Qt 5.1.0 project in Visual Studio 2010

    hello? anyone?
    [Window Detective] - Windows UI spy utility
    [War Thunder]

  5. #5
    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: Link error when compiling Qt 5.1.0 project in Visual Studio 2010

    The linker does not find qtmaind.lib because whatever search path the linker is using does not include the Qt lib folder. I cannot see any reference to a library search path in your linker command. Given your claimed library directories I would start by hard coding rather than relying on a magic QtDir environment variable.

    I do not have or use Visual Studio or the Qt Plugin so I cannot tell you how that should normally function.

  6. #6
    Join Date
    Aug 2010
    Posts
    99
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Link error when compiling Qt 5.1.0 project in Visual Studio 2010

    Quote Originally Posted by ChrisW67 View Post
    ... I cannot see any reference to a library search path in your linker command....
    Hmm, good point. I'll try and find out why that is.
    Actually, i wasn't even aware that you could set the library search path. I've always just given the file names in the "Additional Dependencies" list, not their full path.
    When I just gave the full path to all the Qt lib files, and the build succeeded. So at least that works. But i don't recall having to do that in the past.
    Last edited by xtal256; 9th January 2014 at 00:41.

  7. #7
    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: Link error when compiling Qt 5.1.0 project in Visual Studio 2010

    Look in the property pages for your project (right click on the project in the VS Solution Explorer, select Properties). Expand the Linker section, and on the first page (General), you will see an "Additional Library Directories" property. If you click the "..." button on the right, it will display a dialog where you can enter the paths to the directories that contain non-default libraries. You can use environment variables as part of the path specification (like $(QTDIR)\lib) or relative paths (like ..\..\lib).

    If you do this, you do not have to put full path names on each individual library in the Additional Dependencies list.

    As you have no doubt noticed, the directory layout for the Qt installation changed dramatically between 4.8 and 5.x. Also be aware that when you deploy your app, things have changed there, too. The Windows dependencies are now in a DLL, and that DLL must be placed in a specific subdirectory relative to your executable and all the other Qt DLLs.
    Last edited by d_stranz; 9th January 2014 at 21:34.

  8. #8
    Join Date
    Aug 2010
    Posts
    99
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Link error when compiling Qt 5.1.0 project in Visual Studio 2010

    Quote Originally Posted by d_stranz View Post
    Look in the property pages for your project (right click on the project in the VS Solution Explorer, select Properties). Expand the Linker section, and on the first page (General), you will see an "Additional Library Directories" property. If you click the "..." button on the right, it will display a dialog where you can enter the paths to the directories that contain non-default libraries. You can use environment variables as part of the path specification (like $(QTDIR)\lib) or relative paths (like ..\..\lib).

    If you do this, you do not have to put full path names on each individual library in the Additional Dependencies list.
    Thanks mate, that's exactly what i was looking for. I probably never noticed it before because i only had to do it once on my old computer.
    [Window Detective] - Windows UI spy utility
    [War Thunder]

Similar Threads

  1. Replies: 2
    Last Post: 29th September 2013, 07:05
  2. Replies: 0
    Last Post: 19th March 2013, 18:48
  3. Replies: 2
    Last Post: 26th November 2012, 08:09
  4. Replies: 4
    Last Post: 13th November 2012, 21:46
  5. Problem compiling QT 4,8,0 in windows 7 x64 with visual studio 2010
    By phate89 in forum Installation and Deployment
    Replies: 0
    Last Post: 11th January 2012, 17:14

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.