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. Mocing with Visual Studio command line, exit with code 1
Forum Updated to NodeBB v4.3 + New Features

Mocing with Visual Studio command line, exit with code 1

Scheduled Pinned Locked Moved General and Desktop
moc.exe
7 Posts 3 Posters 3.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.
  • V Offline
    V Offline
    Ver.X
    wrote on 24 Jul 2015, 00:11 last edited by Ver.X
    #1

    I am trying to use the visual studio command line to mocing files, but I get error below:
    The command "<PATH_TO_QT>\qtbase\bin\moc.exe <PATH_TO_FILE>\file.h -nw -o .\GeneratedFiles\Release\moc_file.cpp -DUNICODE -DWIN32 -DWIN64 -DQT_DLL -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_GUI_LIB -DQT_WIDGETS_LIB -I.\GeneratedFiles -I. -I<PATH_TO_QT>\qtbase\include -I.\GeneratedFiles. -I<PATH_TO_QT>\qtbase\include\QtCore -I<PATH_TO_QT>\qtbase\include\QtGui -I<PATH_TO_QT>\qtbase\include\QtWidgets" exited with code 1.

    It seems that this error caused by my misuse the moc command. Is there any hint for me to figure out what should I fix?
    My qt version is 5.4.1(static build). Also QT ADDIN works for me, I just want to figure out how to build it through the command line.

    Thank you guys XDD

    1 Reply Last reply
    0
    • M Offline
      M Offline
      msue
      wrote on 24 Jul 2015, 11:41 last edited by
      #2

      You should use the devenv command to build a project or the complete solution. Then Visual Studio will do all the necessary steps including moc.

      V 1 Reply Last reply 24 Jul 2015, 16:15
      0
      • M msue
        24 Jul 2015, 11:41

        You should use the devenv command to build a project or the complete solution. Then Visual Studio will do all the necessary steps including moc.

        V Offline
        V Offline
        Ver.X
        wrote on 24 Jul 2015, 16:15 last edited by
        #3

        @msue Is there anyway avoid calling qmake?

        1 Reply Last reply
        0
        • V Offline
          V Offline
          Ver.X
          wrote on 24 Jul 2015, 16:29 last edited by
          #4

          Also I believe what qmake does is setting up the visual studio command line, then the visual studio will run the command line when it build the project. If I manually run the command line then does that means I do not need to call qmake?

          1 Reply Last reply
          0
          • V Offline
            V Offline
            Ver.X
            wrote on 24 Jul 2015, 19:12 last edited by
            #5

            It resolved. It turns out that I put a wrong output paht... stupid.
            Thanks anyways XD

            1 Reply Last reply
            0
            • P Offline
              P Offline
              Paul H.
              wrote on 24 Jul 2015, 19:53 last edited by
              #6

              Are you just looking to be able to build a Qt project from a Visual Studio command line?
              Or are you trying to duplicate everything Visual Studio does when it builds the project (target directories, etc.)?

              For the first option, the first thing to do is make sure qmake is in your path. Then what I do is create a build directory, change to that directory, run:
              qmake <path_to_file.pro>\<file.pro>
              Then run:
              nmake for debug build or
              nmake release for release build.

              For the second option, change to the directory with the project file and run:
              msbuild <MSVC_project_or solution_file>
              You don't need the project file name if you only have one project (.vsxproj) in the folder. You can add options to the command line, such as:
              msbuild <MSVC_project_file> /t:clean - clean the project.
              msbuild <MSVC_project_file> /t:rebuild - rebuild the project.
              msbuild <MSVC_project_file> /p:Configuration=Release - build release version.
              You can also put the options together:
              msbuild <MSVC_project_file> /t:rebuild /p:Configuration=Release - rebuild release version.
              See this page for more information.

              Paul

              V 1 Reply Last reply 24 Jul 2015, 22:54
              0
              • P Paul H.
                24 Jul 2015, 19:53

                Are you just looking to be able to build a Qt project from a Visual Studio command line?
                Or are you trying to duplicate everything Visual Studio does when it builds the project (target directories, etc.)?

                For the first option, the first thing to do is make sure qmake is in your path. Then what I do is create a build directory, change to that directory, run:
                qmake <path_to_file.pro>\<file.pro>
                Then run:
                nmake for debug build or
                nmake release for release build.

                For the second option, change to the directory with the project file and run:
                msbuild <MSVC_project_or solution_file>
                You don't need the project file name if you only have one project (.vsxproj) in the folder. You can add options to the command line, such as:
                msbuild <MSVC_project_file> /t:clean - clean the project.
                msbuild <MSVC_project_file> /t:rebuild - rebuild the project.
                msbuild <MSVC_project_file> /p:Configuration=Release - build release version.
                You can also put the options together:
                msbuild <MSVC_project_file> /t:rebuild /p:Configuration=Release - rebuild release version.
                See this page for more information.

                Paul

                V Offline
                V Offline
                Ver.X
                wrote on 24 Jul 2015, 22:54 last edited by
                #7

                @Paul-H.
                Thanks.

                1 Reply Last reply
                0

                1/7

                24 Jul 2015, 00:11

                • Login

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