Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to build a QT-project in visual studio from command line

I am trying to automate the build process for one of my QT-project. I used the following command in my batch file for non-QT projects

"C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe" "myproject.sln" /build "Debug|x64" /projectconfig Debug

but it is not working for my QT project. Am I missing something?

like image 435
Abtin Rasoulian Avatar asked Sep 04 '25 16:09

Abtin Rasoulian


1 Answers

Here is an example on how to do that (command by command):

"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86
cd <my_project_directory>
qmake
nmake

The first command sets up the environment for using Visual Studio tools. Second command changes the current directory to one where your Qt project file is (you have to have one). Third command runs Qt's qmake.exe utility to generate make files. And finally nmake will build your project.

However, if you don't use Qt project files and have only VisualStudio solution, you can use MSBuild utility, like:

"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86
MSBuild your_solution.sln /p:Configuration=Debug

You can also set additional environment variables, such as QTDIR if it does not find your Qt installation.

like image 73
vahancho Avatar answered Sep 07 '25 07:09

vahancho