Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

how to compile from cmd using msvc 2017 ?



  • hi!..

    to compile using ming, I just do this:

    qmake MyProject.pro
    mingw32-make -j4
    

    what is the equivalent for mvsc 2017?

    thanks...


  • Moderators

    Direct equivalent for mingw32-make is nmake, but it doesn't support the -j switch out of the box.
    Qt has a drop-in replacement for nmake called jom that adds that feature.

    So with that the direct equivalent would be

    qmake MyProject.pro
    jom -j4
    


  • thanks!0



  • i have got farther with you solution using jom.. it is very nice indeed..

    now I got other kind of problem:

    while compiling, console says:

    global.h(45): fatal error C1083: Could not open file: 'type_traits': No such file or directory
    

    Looks like msvc is not recognizing std headers...


  • Moderators

    You need to set up environment for the compiler before you run it.

    For MSVC this is done by calling the vcvars script. Depending on which VS version (2017, 2019), edition (Community, Pro, Enterprise) and which platform (x64, x86, arm) you are targeting it will be named differently and placed in slightly different location. You can find it by going to your start menu and looking for a Visual Studio command prompt shortcut and checking where it points to.

    For example for VS2019 Community and targeting x64 the default location of that script is
    C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat
    There are also scripts for other configs in that location e.g. vcvars32.bat for x86 or vcvarsamd64_x86.bat for cross compiling.

    If you're calling those things manually and not from some build script you can also just open that VS command prompt shortcut from start menu and call them in that console session.



  • @Chris-Kawa Thanks for your help... may be do i'm missing something else because i have tried every batch file but still is giving me the same error on cmd..

    alt text

    By the way, i'm using 2019, there is a mistake in the topic title..

    Edit:
    Nevermind!.. i found i did not called for qtenv2.bat after this i got it working

    Thanks!


  • Moderators

    Just a note - don't call all the vcvars scripts! They will write over and add conflicting stuff to the environment. Only call the single one you actually need and I doubt you want the ones for cross compilation. If you're on a 64bit machine and compiling a 64bit app call vcvars64.bat and nothing else. Also note that it only sets up environment for that one console session, so if you call it in one window and then call compiler in another it won't work. They don't see each other.


  • Moderators

    Instead of searching for the correct vcvars___.bat, you can simply use the shortcut called "x86 Native Tools Command Prompt for VS 2019" (or the x64 version) that's in your Start Menu.

    The shortcut opens a Command Prompt window and sets up the environment.



  • @Chris-Kawa @JKSH

    ok, thanks.. again!

    Just remains a doubt...
    the environment set is based on the current architecture or target architecture?
    for instance, I have a 64bit operating system, but I want to develop for 32 bits..


  • Moderators

    From the docs :

    Script Usage
    vcvars32.bat Use the 32-bit x86-native tools to build 32-bit x86 code.
    vcvars64.bat Use the 64-bit x64-native tools to build 64-bit x64 code.
    vcvarsx86_amd64.bat Use the 32-bit x86-native cross tools to build 64-bit x64 code.
    vcvarsamd64_x86.bat Use the 64-bit x64-native cross tools to build 32-bit x86 code.

    So if you're on a 64bit machine and want to produce 32bit binary you can use either vcvars32.bat or vcvarsamd64_x86.bat.


Log in to reply