简体   繁体   中英

building qt project using visual studio

I have build a Qt project (qwt) using the vs2013 compiler in Qt creator. When I open the .pro file and look at the build steps I see:

  • qmake: qmake.exe qwt.pro -r -spec win32-msvc2013
  • Make: nmake.exe in C:\\qwt-6.1.2

When I build the project, all goes fine and the project is build without errors. So far so good.

However when I try to build this project using the command line I get errors during the nmake step. I have used the same commands as above (and I'm sure that I'm using the same versions of qmake/nmake).

...\QtCore\qglobal.h(38) : fatal error C1083: Cannot open include
file: 'stddef.h': No such file or directory

My question is, what does Qt do more so that the project does build in Qt creator and not from the command prompt? And how can I copy this behaviour in the command prompt? I'm doing this so I can make a batch file that builds the project (on a machine that does not have Qt creator installed).

In order to use the Visual Studio compilation environment from the command-line you need to call the vcvars batch script to set up the paths correctly.

Either call the vcvars64.bat in the C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\bin\\amd64 folder (that is for VS2013, you can replace the "12.0" with whatever visual studio version you have).

Or the vcvars32.bat in the C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\bin folder.

Or use the vcvarsall.bat x86 or vcvarsall.bat x64 calls for the script in C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC

Alternatively Visual Studio creates shortcuts in the start-menu called along the lines of VS2013 x64 Native Tools Command Prompt which call those scripts.

It's likely to be that Qt Creator has added additional variables into the build environment, which are not presented when you try to compile manually through cmd .

If you look within Qt Creator under the Projects section there's Build information. Expand the Build Environment information and check to see if there's anything in there different to your machines global environment settings.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM