Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. how to compile from cmd using msvc 2017 ?
Forum Updated to NodeBB v4.3 + New Features

how to compile from cmd using msvc 2017 ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
10 Posts 3 Posters 1.4k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    U7Development
    wrote on last edited by U7Development
    #1

    hi!..

    to compile using ming, I just do this:

    qmake MyProject.pro
    mingw32-make -j4
    

    what is the equivalent for mvsc 2017?

    thanks...

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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
      
      1 Reply Last reply
      3
      • U Offline
        U Offline
        U7Development
        wrote on last edited by
        #3

        thanks!0

        1 Reply Last reply
        0
        • U Offline
          U Offline
          U7Development
          wrote on last edited by
          #4

          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...

          1 Reply Last reply
          0
          • Chris KawaC Offline
            Chris KawaC Offline
            Chris Kawa
            Lifetime Qt Champion
            wrote on last edited by Chris Kawa
            #5

            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.

            U 1 Reply Last reply
            3
            • Chris KawaC Chris Kawa

              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.

              U Offline
              U Offline
              U7Development
              wrote on last edited by U7Development
              #6

              @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!

              1 Reply Last reply
              0
              • Chris KawaC Offline
                Chris KawaC Offline
                Chris Kawa
                Lifetime Qt Champion
                wrote on last edited by
                #7

                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.

                U 1 Reply Last reply
                3
                • JKSHJ Offline
                  JKSHJ Offline
                  JKSH
                  Moderators
                  wrote on last edited by JKSH
                  #8

                  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.

                  Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                  1 Reply Last reply
                  3
                  • Chris KawaC Chris Kawa

                    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.

                    U Offline
                    U Offline
                    U7Development
                    wrote on last edited by U7Development
                    #9

                    @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..

                    1 Reply Last reply
                    0
                    • Chris KawaC Offline
                      Chris KawaC Offline
                      Chris Kawa
                      Lifetime Qt Champion
                      wrote on last edited by Chris Kawa
                      #10

                      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.

                      1 Reply Last reply
                      2

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved