NifSkope/Compile

From NifTools
Jump to: navigation, search


To compile NifSkope, you need to do the following:

  1. get the NifSkope source code and Qt,
  2. set up the build environment,
  3. if necessary, compile Qt, and finally
  4. compile NifSkope.

Following are the details.

Contents

Windows

Get The NifSkope Source Code

Follow the steps described in using git. The NifSkope source code should now reside in

C:\Documents and Settings\username\My Documents\nifskope

for Windows XP, and in

C:\Users\username\Documents\nifskope

for Windows Vista, where username is your Windows user name.

You now have two choices for compiling NifSkope: either with MinGW, or with MSVC. The MinGW build environment is very easy to set up, does not require that much disk space (about 303 megabytes), runs on most Windows platforms (confirmed on Windows 98 and up), but compilation is a bit slower and the binary depends on the MinGW and Qt DLL files. The MSVC build environment takes more time to set up, requires more disk space (about 1526 megabytes) and more to download, and only runs on recent windows platforms (Windows 2000 and up), but once done, compilation is faster and the binary has no MinGW or Qt DLL dependencies.

MinGW Build

Getting Qt and MinGW

EDITORIAL NOTE: Qt 4.8.x is currently recommended.

Go to Qt for Open Source C++ and download the online installer, QtSdk-online-win-x86-vx_x_x.exe; at the time of writing, x_x_x is 1_2_1. Run the installer and use the default install path C:\QtSDK\.

When running the installer, select Custom for installation type. On the Select Components screen, select:

  • Qt SDK > Development Tools > Qt Creator (should be selected for you)
  • Qt SDK > Development Tools > Desktop Qt > Qt 4.8.1 > Desktop Qt 4.8.1 - MinGW
  • Qt SDK > Miscellaneous > MinGW 4.4

Everything else can be deselected.

Compiling NifSkope

First, start git bash, cd to your NifSkope clone, and run the config script:

cd Documents/nifskope
makeconfig.sh

Now, start the Qt Creator, and open the NifSkope.pro (File > Open File or Project).

When building for the first time, you will need to configure it for your toolchain (such as MinGW). On the left side, click Projects, and you'll see the project's Build Settings for the "Release" build. Make sure that Qt version does not say Invalid Qt version, but has a valid entry, such as for instance Qt 4.7.4 for Desktop - MinGW 4.4 (Qt SDK). Make sure that Shadow build is enabled (this prevents cluttering your source directory), and leave the Build directory to the default (typically, C:\Users\username\Documents\NifSkope-build-desktop).

Set the build configuration to "Release" if not already set (left side, click NifSkope, this should say Build: Release). Next, build it (left side, click the green play button below NifSkope). This will take a while (you can click on Compile Output on the bottom to see the progress). Your NifSkope.exe will now reside in the NifSkope-build-desktop directory (or whatever directory you have configured in the build settings).

Copying the DLL files

NifSkope.exe depends on some Qt DLL files. If you want to run NifSkope from the NifSkope-build-desktop\release directory, you need to copy those files to that directory. The files are

libgcc_s_dw2-1.dll
mingwm10.dll
QtCore4.dll
QtGui4.dll
QtNetwork4.dll
QtOpenGL4.dll
QtXml4.dll

and can all be found in C:\QtSDK\Desktop\Qt\x.x.x\mingw\bin\.

Optional: Creating The Installer

The official installer is created in the following way. First, make sure you have installed

In your buildenv, browse to the nifskope\win-install directory, and run makeexe.bat. At the end, you have an installer for your nifskope!

MSVC Build

EDITORIAL WARNING: this section is completely out of date.

Getting the Qt Source Code

Go to Trolltech's Qt4 The download links are on the bottom of page, you need the qt-win-opensource-src-x.x.x zip file; at the time of writing, x.x.x is 4.4.0. Extract the zip to a "nice" folder, this is where you Qt library will reside. You cannot just move a Qt folder after you built the library without breaking things. The folder name should not contain any spaces. A choice could be C:\Qt\ For example, move your Qt source zip to C:\Qt, and extract the zip there. The sources end up in the folder C:\Qt\qt-win-opensource-src-4.4.0

Setting Up The Build Environment

Download and install Microsoft Visual C++ Express 2008. Next, it is useful to create a batch file that sets up all environment variables for you. For example, on 32-bit versions of Windows:

@echo off

echo "Setting Visual Studio Environment"
call "C:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86

echo "Setting Qt Environment"
set QTPREFIX=C:\Qt\qt-win-opensource-src-4.4.0
set INCLUDE=%QTPREFIX%\include;%INCLUDE%
set LIB=%QTPREFIX%\lib;%LIB%
set PATH=%QTPREFIX%\bin;%PATH%

cd "\Documents and Settings\username\My Documents"

and on 64-bit versions of Windows:

@echo off

echo "Setting Visual Studio Environment"
call "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86

echo "Setting Qt Environment"
set QTPREFIX=C:\Qt\qt-win-opensource-src-4.4.0
set INCLUDE=%QTPREFIX%\include;%INCLUDE%
set LIB=%QTPREFIX%\lib;%LIB%
set PATH=%QTPREFIX%\bin;%PATH%

cd "\Users\username\Documents"

Copy and paste this in your editor. It will probably not work on your system; adapt the paths to reflect your install environment. Save as buildenv.bat and put it on your My Documents folder. Right click and "Send to Desktop". This will create a shortcut on your Desktop. Right-click on this shortcut just created, select properties, and change the target into

%comspec% /k  "C:\Documents and Settings\username\My Documents\buildenv.bat"

for Windows XP, and

%comspec% /k  "C:\Users\username\Documents\buildenv.bat"

for Windows Vista, where username is your Windows user name.

Compiling Qt

Run the buildenv.bat link you just created on your Desktop. This will open up your development console. If you type

set

then you get a list of all environment variables. The variables INCLUDE, LIB, and PATH should reflect the proper locations of the MSVC and QT include, lib, and bin directories. If not then you may have a typo in your buildenv.bat file, in which case you need to fix the typo and run the link again.

Once ensured that the environment variables INCLUDE, LIB, and PATH are correctly set, type

cd \Qt\qt-win-opensource-src-4.4.0

You should now be in the Qt library folder. To start the compilation process, type

configure.exe -static -release -platform win32-msvc2008

This means we are configuring Qt to use MSVC and to link statically. Carefully read the instructions on screen, select "Yes" when asked. A tool called "qmake" will be compiled. Finally, a message will prompt you to start the building process by typing

nmake

Qt should now compile. This will take some time.

Compiling NifSkope

There are two ways to build NifSkope with Qt. Pick your favorite.

Via QMake + NMake

Still in the console, cd to your NifSkope checkout, and run qmake and nmake:

cd "\Documents and Settings\username\My Documents\niftools\nifskope"
qmake
nmake

or on Windows Vista:

cd "\Users\username\Documents\niftools\nifskope"
qmake
nmake

Your NifSkope.exe will now reside in the release directory.

Via QMake + MSVC Project

Still in the console, cd to your NifSkope checkout, and run qmake to create a project file:

cd "\Documents and Settings\username\My Documents\niftools\nifskope"	 
qmake -t vcapp

or on Windows Vista:

cd "\Users\username\Documents\niftools\nifskope"	 
qmake -t vcapp

This will create a file called NifSkope.vcproj in your nifskope folder. Open that with MSVC.

Go to the "Build" menu and select "Build Solution". The first time you do this you will be asked to save the solution file. Just save it in the nifskope directory as well. NifSkope should now build! At the end of the process, your NifSkope.exe should be in the release directory.

Linux

Building NifSkope on linux is fairly straightforward as most distributions have binary packages for Qt4 available in their repositories.

Getting Qt and Git

First grab g++, qt and git from your distribution's repository if you do not already have them. Below are the commands for doing so on Fedora and Ubuntu; note that the packages specified may have many dependencies which will be automatically installed.

Fedora 8

su
yum install qt4 qt4-devel qt4-x11 git gcc-c++ make
exit

Fedora 9 to 15

su
yum install qt qt-devel qt-x11 git gcc-c++ make
exit

Fedora 16 comes with Qt 4.8-rc1, which currently breaks NifSkope. There's a qt48-qglfunctions git branch which is a rough attempt to fix the problems, but your mileage may vary.

Ubuntu 10.04

sudo apt-get update
sudo apt-get install build-essential checkinstall git-core g++ qt4-qmake libqt4-dev

Get The NifSkope Source Code

See using git.

Compiling NifSkope

If you want to compile a Debug build, see the notes in NifSkope.pro regarding changing the CONFIG flags.

Finally, run qmake and make:

cd niftools/nifskope
./makeconfig.sh
qmake-qt4
make

A few notes:

  • If you have multiple cores, you can type make -j N where N is the number of cores you have. The compilation will run N times faster.
  • If you got the source from the .tar.bz2 file, then skip the makeconfig.sh command.

Finally, type

./NifSkope

and you can start enjoying NifSkope on your linux box!

Optional: Creating An RPM Package

On Fedora, you can create an RPM for nifskope as follows. First, you need to set up your rpm environment:

su
yum install rpmdevtools
exit
rpmdev-setuptree

Next, build your source tarball:

cd linux-install
./maketarball.sh

This will automatically dump the source code tarball into ~/rpmbuild/SOURCES/nifskope-x.x.x.tar.bz2. Finally, build the rpm:

rpmbuild -ba nifskope.spec

The rpm will now reside somewhere in ~/rpmbuild/RPMS/.

You can also build nifskope in mock, which allows you to build rpms for different target distributions and different architectures on the same host. For example:

rpmbuild -bs nifskope.spec
mock -r fedora-10-x86_64 ~/rpmbuild/SRPMS/nifskope-x.x.x-1.fc10.src.rpm
mock -r fedora-10-i386 ~/rpmbuild/SRPMS/nifskope-x.x.x-1.fc10.src.rpm

The rpms will reside in /var/lib/mock/xxx/result.

Mac OS X

Getting Qt

You can use MacPorts http://www.macports.org/ to install qt (there are other ways, such as fink). Once you have installed MacPorts, simply do:

port search qt
sudo port install qt4-mac

This will install Qt. It may take a while, depending on how many dependent libraries it has to download and compile as well. If you run into a perl error, fix it by following the advice here: http://trac.macports.org/wiki/ProblemHotlist#perl5-image-error

Compiling NifSkope

Then the install is very similar to Linux.

cd
git clone --recursive git://niftools.git.sourceforge.net/gitroot/niftools/nifskope
cd nifskope
./makeconfig.sh

You may have an error the first time you run ./makeconfig.sh. Just run it again.

qmake
make

Now Nifskope.app resides in niftools/nifskope.

Copying the XML files

Before you can run nifskope, one final step is needed: copy nif.xml and kfm.xml from niftools/docsys/ to niftools/nifskope/NifSkope.app/Contents/MacOS/ from the command line (or you can control-click on Nifskope.app/ to open up the Application bundle and navigate to Contents/MacOS in the Finder). Now your nifskope should work!

Cross Compiling on Linux for Windows

It is also possible to compile NifSkope for windows under linux. At the moment, this has only been tested on Fedora 14.

Getting Cross Compiled Qt Libaries and Git

First grab mingw32-qt and git from your distribution's repository if you do not already have them. Below are the commands for doing so on Fedora; note that the packages specified may have many dependencies which will be automatically installed.

Fedora 16 & 17

su
yum install mingw32-qt git make
exit

Get The NifSkope Source Code

See using git.

Compiling NifSkope

If you want to compile a Debug build, see the notes in NifSkope.pro regarding changing the CONFIG flags.

Finally, run mingw32-qmake-qt4 and make:

cd niftools/nifskope
./makeconfig.sh
mingw32-qmake-qt4
make

A few notes:

  • If you have multiple cores, you can type make -j N where N is the number of cores you have. The compilation will run N times faster.
  • If you got the source from the .tar.bz2 file, then skip the makeconfig.sh command.

Creating The Installer

There is a script that does all the work:

cd win-install
./makeexe.sh

The installer will then reside in the nifskope/win-install folder.

Personal tools