Skip to content
Candoran2 edited this page Oct 15, 2021 · 3 revisions

Building NifSkope with command-line Qt and Microsoft Visual Studio

These steps are based on the appveyor.yml file from the main NifSkope repository. It has only been tested on a 64-bit system, with Microsoft Visual Studio 2017 and Qt 5.13.

Prerequisite installations

  1. A local clone of NifSkope. How to get this is listed in README.md.
  2. Microsoft Visual Studio for compiling the C++ code - easily found online. Make sure to install the "Desktop Development with C++" module.
  3. Qt 5.13 or up (available at https://download.qt.io/archive/qt/). Qt 5.15 or higher are only available with the online installer, for which you need an account. For Qt 5.13, set 0.0.0.0:123 as the proxy to skip the login screen. Make sure to install the components for your version of Microsoft Visual Studio.

Environment Setup

You can do this part manually in the console, but I've just added the requisite lines to a bat file, so that only the local variables are affected.

  • Add the directory of Qt that contains qmake.exe for the visual studio year and version that you have installed to your path. In my case, this was Microsoft Visual Studio 2017 on a 64-bit system, so I pointed it to C:\Qt\Qt5.13\5.13.0\msvc2017_64\bin (which contained qmake.exe).
  • Add the directory containing msbuild.exe from your Microsoft Visual Studio installation to your path. This Stackoverflow link lays out where it is for each Visual Studio version.
  • Run vcvarsall.bat to set up the environment variables for your build tools/target version. Where you can find vcvarsall.bat is detailed on this page. To know the exact function and availability of each parameter, use powershell or the command line to run /help on it. It should be enough to specify host and target architecture, and the winsdk version.

Running the build process

The actual build process consists of two simple commands: qmake and msbuild.

qmake creates the vcxproj file, which is used by msbuild. For all the options for the qmake command, see the official documentation.

msbuild creates the actual exe. For the meaning of different parameters, see the official documentation.

The bat file I used is listed below:

@echo off
SETLOCAL

set WIN_VER=10.0.17763.0
set CONFIGURATION=debug

set QTDIR=C:\Qt\Qt5.13\5.13.0\msvc2017_64
set "MSBUILD_DIR=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin"

set "PATH=%QTDIR%\bin;%PATH%"
set "PATH=%MSBUILD_DIR%;%PATH%"

REM make sure the correct environment variables are set for qmake
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 %WIN_VER%
REM run qmake
qmake CONFIG+=%CONFIGURATION%  WINDOWS_TARGET_PLATFORM_VERSION=%WIN_VER% -Wall -spec win32-msvc -tp vc NifSkope.pro
REM run msbuild
msbuild NifSkope.vcxproj /t:Build /p:Configuration=%configuration% /m:2