3
votes

I have been trying to build Qt 5.6.0 for use with Visual Studio 2015 Community, but the documentation on their website and on the Qt wiki is not very specific when it comes to building it for Visual Studio. I have also tried other tutorials for building it but to no success.

Tutorials I have tried following:
https://wiki.qt.io/Building_Qt_5_from_Git
https://doc.qt.io/qt-5/windows-building.html

These are the steps that I take when attempting to build it:

  1. Cloned the source code from the git repo to D:\Programs\qt5.

  2. Checked out the branch I wanted. In this case it was 5.6.0.

  3. Cloned only the essentials module subset to reduce build time.

  4. Created a batch script to set the environment variables for the cmd session and placed it in D:\Programs\qt5:

    REM Set up \Microsoft Visual Studio 2015, where <arch> is \c amd64, \c x86, etc.
    CALL "D:\Programs\Visual Studio 2015 Community\VC\vcvarsall.bat" amd64
    SET _ROOT=D:\Programs\qt5
    SET PATH=%_ROOT%\qtbase\bin;%_ROOT%\gnuwin32\bin;%PATH%
    REM Uncomment the below line when using a git checkout of the source repository
    SET PATH=%_ROOT%\qtrepotools\bin;%PATH%
    SET QMAKESPEC=win32-msvc2015
    SET _ROOT=
    REM When compiling with ICU, uncomment the lines below and change <icupath> appropriately:
    REM SET INCLUDE=<icupath>\include;%INCLUDE%
    REM SET LIB=<icupath>\lib;%LIB%
    REM SET PATH=<icupath>\lib;%PATH% 
    

    *Tried removing the SET QMAKESPEC line and it did not affect the resulting errors.

  5. Open the Developer Command Prompt for VS2015 and navigate to D:\Programs\qt5.

  6. Run the script in number 4.

  7. Enter the commands to configure the Qt5 build.

    configure -developer-build -opensource -confirm-license -nomake tests -nomake examples -mp -skip qtwebengine -skip qtwebchannel
    

    *Is there a way to use the configure command to only build the essentials module subset?

  8. Enter the command to build Qt.

    nmake
    

    I get this error when I try to build it:


    D:\Programs\qt5>nmake

    Microsoft (R) Program Maintenance Utility Version 14.00.23506.0
    Copyright (C) Microsoft Corporation.  All rights reserved.

            cd qtbase\ && ( if not exist Makefile D:\Programs\qt5\qtbase\bin\qmake D:\Programs\qt5\qtbase\qtbase.pro -o Makefile ) && nmake -f Makefile

    Microsoft (R) Program Maintenance Utility Version 14.00.23506.0
    Copyright (C) Microsoft Corporation.  All rights reserved.

            cd src\ && ( if not exist Makefile D:\Programs\qt5\qtbase\bin\qmake D:\Programs\qt5\qtbase\src\src.pro -o Makefile ) && nmake -f Makefile

    Microsoft (R) Program Maintenance Utility Version 14.00.23506.0
    Copyright (C) Microsoft Corporation.  All rights reserved.

            cd corelib\ && ( if not exist Makefile.qtzlib D:\Programs\qt5\qtbase\bin\qmake D:\Programs\qt5\qtbase\src\corelib\qtzlib.pro -o Makefile.qtzlib ) && nmake -f Makefile.qtzlib

    Microsoft (R) Program Maintenance Utility Version 14.00.23506.0
    Copyright (C) Microsoft Corporation.  All rights reserved.

            nmake -f Makefile.qtzlib.Debug all

    Microsoft (R) Program Maintenance Utility Version 14.00.23506.0
    Copyright (C) Microsoft Corporation.  All rights reserved.

            copy /y ..\..\lib\Qt5Zlibd.dll ..\..\bin
    The system cannot find the file specified.
            nmake -f Makefile.qtzlib.Release all

    Microsoft (R) Program Maintenance Utility Version 14.00.23506.0
    Copyright (C) Microsoft Corporation.  All rights reserved.

            copy /y ..\..\lib\Qt5Zlib.dll ..\..\bin
    The system cannot find the file specified.
            cd tools\bootstrap\ && ( if not exist Makefile D:\Programs\qt5\qtbase\bin\qmake D:\Programs\qt5\qtbase\src\tools\bootstrap\bootstrap.pro -o Makefile ) && nmake -f Makefile

    Microsoft (R) Program Maintenance Utility Version 14.00.23506.0
    Copyright (C) Microsoft Corporation.  All rights reserved.

            nmake -f Makefile.Debug

    Microsoft (R) Program Maintenance Utility Version 14.00.23506.0
    Copyright (C) Microsoft Corporation.  All rights reserved.

            cl -c -nologo -Zc:wchar_t -FS -Zi -MDd -D_HAS_EXCEPTIONS=0 -MP -GR -W3 -w34100 -w34189 -w44996 -WX /Fd..\..\..\lib\Qt5Bootstrapd.pdb -DUNICODE -DWIN32 -DWIN64 -DQT_BOOTSTRAPPED -DQT_LITE_UNICODE -DQT_NO_CAST_TO_ASCII -DQT_NO_CODECS -DQT_NO_DATASTREAM -DQT_NO_LIBRARY -DQT_NO_QOBJECT -DQT_NO_SYSTEMLOCALE -DQT_NO_THREAD -DQT_NO_UNICODETABLES -DQT_NO_USING_NAMESPACE -DQT_NO_DEPRECATED -DQT_NO_TRANSLATION -DQT_CRYPTOGRAPHICHASH_ONLY_SHA1 -DQT_NO_CAST_FROM_ASCII -DQT_BUILD_BOOTSTRAP_LIB -DQT_BUILDING_QT -D_CRT_SECURE_NO_WARNINGS -D_USE_MATH_DEFINES -DQT_ASCII_CAST_WARNINGS -DQT_MOC_COMPAT -DQT_USE_QSTRINGBUILDER -DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_BEFORE=0x040800 -DQT_NO_EXCEPTIONS -I. -I..\..\3rdparty\zlib -I..\..\..\include -I..\..\..\include\QtCore -I..\..\..\include\QtCore\5.6.1 -I..\..\..\include\QtCore\5.6.1\QtCore -I..\..\..\include\QtXml -I..\..\..\include\QtXml\5.6.1 -I..\..\..\include\QtXml\5.6.1\QtXml -Itmp -I..\..\..\mkspecs\win32-msvc2013 -Fo.obj\debug\ @C:\Users\Justin\AppData\Local\Temp\nm3B49.tmp
    qlatincodec.cpp
    qtextcodec.cpp
    qutfcodec.cpp
    d:\programs\qt5\qtbase\include\qtcore\../../src/corelib/global/qflags.h(52): error C2220: warning treated as error - no 'object' file generated (compiling source file ..\..\corelib\codecs\qlatincodec.cpp)
    d:\programs\qt5\qtbase\include\qtcore\../../src/corelib/global/qflags.h(52): warning C4577: 'noexcept' used with no exception handling mode specified; termination on exception is not guaranteed. Specify /EHsc (compiling source file ..\..\corelib\codecs\qlatincodec.cpp)
    d:\programs\qt5\qtbase\include\qtcore\../../src/corelib/global/qflags.h(52): note: to simplify migration, consider the temporary use of /Wv:18 flag with the version of the compiler with which you used to build without warnings (compiling source file ..\..\corelib\codecs\qlatincodec.cpp)
    d:\programs\qt5\qtbase\include\qtcore\../../src/corelib/global/qflags.h(52): error C2220: warning treated as error - no 'object' file generated (compiling source file ..\..\corelib\codecs\qutfcodec.cpp)
    d:\programs\qt5\qtbase\include\qtcore\../../src/corelib/global/qflags.h(52): warning C4577: 'noexcept' used with no exception handling mode specified; termination on exception is not guaranteed. Specify /EHsc (compiling source file ..\..\corelib\codecs\qutfcodec.cpp)
    d:\programs\qt5\qtbase\include\qtcore\../../src/corelib/global/qflags.h(52): note: to simplify migration, consider the temporary use of /Wv:18 flag with the version of the compiler with which you used to build without warnings (compiling source file ..\..\corelib\codecs\qutfcodec.cpp)
    d:\programs\qt5\qtbase\include\qtcore\../../src/corelib/global/qflags.h(52): error C2220: warning treated as error - no 'object' file generated (compiling source file ..\..\corelib\codecs\qtextcodec.cpp)
    d:\programs\qt5\qtbase\include\qtcore\../../src/corelib/global/qflags.h(52): warning C4577: 'noexcept' used with no exception handling mode specified; termination on exception is not guaranteed. Specify /EHsc (compiling source file ..\..\corelib\codecs\qtextcodec.cpp)
    d:\programs\qt5\qtbase\include\qtcore\../../src/corelib/global/qflags.h(52): note: to simplify migration, consider the temporary use of /Wv:18 flag with the version of the compiler with which you used to build without warnings (compiling source file ..\..\corelib\codecs\qtextcodec.cpp)
    NMAKE : fatal error U1077: '"D:\Programs\Visual Studio 2015 Community\VC\BIN\amd64\cl.EXE"' : return code '0x2'
    Stop.
    NMAKE : fatal error U1077: '"D:\Programs\Visual Studio 2015 Community\VC\BIN\amd64\nmake.EXE"' : return code '0x2'
    Stop.
    NMAKE : fatal error U1077: 'cd' : return code '0x2'
    Stop.
    NMAKE : fatal error U1077: 'cd' : return code '0x2'
    Stop.
    NMAKE : fatal error U1077: 'cd' : return code '0x2'
    Stop.

I have tried searching this error to find a fix, but so far I haven't been able to get much information about it at all.

Any help on the subject would be greatly appreciated, thanks.

2
SET QMAKESPEC=win32-msvc2013 looks wrong, try with SET QMAKESPEC=win32-msvc2015. Or just don't set the mkspec explicitly at all. (not entirely sure if that works, but worth a try)Frank Osterfeld
I tried your suggestions of setting the QMAKESPEC to win32-msvc2015, and removing that line altogether, but it resulted in the same errors. Thanks for the quick response :) Edited the original question to reflect the changes.JRud52

2 Answers

1
votes

This is a manual fix, not a solution per se, but if you look at the error message you see this:

cd tools\bootstrap\ && ( if not exist Makefile...

nmake -f Makefile.Debug....

Go to that folder and open the file MakeFile.Debug. There you will find an entry called CXXFLAGS. Append "/EHsc" to the end and save the file.

Then simply run nmake again.

The error is slightly confusing. The first one

error C2220: warning treated as error - no 'object' file generated

is a following error from the problem that Qt is having. Visual Studio 2015 has some new redisigns that causes the actual problem:

warning C4577: 'noexcept' used with no exception handling mode specified

The local solution is also mentioned:

Specify /EHsc

So that is what my fix does. It simply tells the compiler to ignore some exceptions or handle them differently. In this case the problem probably emerges from a C function that throws an exception, but the C++ wrapper does not handle it.

For more info please read /EH documentation.

0
votes

I compiled without problem (including openssl and mysql). I figured some points out:

  • Perl-bin has to be in front of Git.
  • Use Python 2.7 (Current 3.x will crash Angle).
  • Use perl init-repository with -f (otherwise you might have inconsistent versions)
  • Use correct x86 / x64 3rd party libraries. (Compiling in x64 command prompt you have to use x64 libs).
  • Branch 5.7 seems to be buggy (compile problems with qt3d). Branch dev (from August, 29 2016) seems to be our friend.