Mocing with Visual Studio command line, exit with code 1
-
wrote on 24 Jul 2015, 00:11 last edited by Ver.X
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
-
wrote on 24 Jul 2015, 11:41 last edited by
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.
-
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.
-
wrote on 24 Jul 2015, 16:29 last edited by
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?
-
wrote on 24 Jul 2015, 19:12 last edited by
It resolved. It turns out that I put a wrong output paht... stupid.
Thanks anyways XD -
wrote on 24 Jul 2015, 19:53 last edited by
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
-
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
1/7