NifSkope/Compile
From NifTools
To compile NifSkope, you need to do the following:
- get the NifSkope source code and Qt,
- set up the build environment,
- if necessary, compile Qt, and finally
- compile NifSkope.
Following are the details.
Contents |
Windows
Get The NifSkope Source Code
- First, download and install TortoiseSVN.
- Then, open your My Documents folder, create a directory niftools in that folder (right click -> new -> folder).
- Right click on the newly created niftools folder, and select "SVN Checkout" in the context menu.
- In the URL field, put https://niftools.svn.sourceforge.net/svnroot/niftools/trunk.
- Click Ok. The source code will start downloading.
The NifSkope source code should now reside in
C:\Documents and Settings\username\My Documents\niftools\nifskope
for Windows XP, and in
C:\Users\username\Documents\niftools\nifskope
for Windows Vista, where username is your Windows user name. For more information on subversion, see Using SVN.
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
Go to Qt for Open Source C++ and download the qt-win-opensource-x.x.x-mingw.exe file; at the time of writing, x.x.x is 4.5.3. Run the installer and use the default install path C:\Qt\4.5.3\. During the installation, you are asked whether you want to download and install MinGW: do so, again, using the default install path C:\MinGW\. If you have previously installed MinGW, Qt will complain about needing version 3.2 of the w32api package; you can safely ignore this message if you have a newer version (current as of December 2008 is 3.12).
The above instructions are for downloading the Qt framework only, which is sufficient for compiling nifskope. Alternatively, you may want to use the Qt SDK for Open Source C++, which includes a complete development environment, besides the standard Qt framework.
Setting Up The Build Environment
Next, it is useful to create a batch file that sets up all environment variables for you. For example, on Windows XP:
@echo off echo "Setting Qt and MinGW Environment" call C:\Qt\4.5.3\bin\qtvars.bat cd "\Documents and Settings\username\My Documents"
On Windows Vista the last line should read:
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. In particular, replace username with your Windows user name. 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.
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 MinGW 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.
Compiling NifSkope
Once ensured that the environment variables INCLUDE, LIB, and PATH are correctly set, cd to your NifSkope checkout, and run qmake and make:
cd "\Documents and Settings\username\My Documents\niftools\nifskope" makeconfig.bat qmake make
or on Windows Vista:
cd "\Users\username\Documents\niftools\nifskope" makeconfig.bat qmake make
Your NifSkope.exe will now reside in the release directory.
Copying the DLL files
NifSkope.exe depends on some Qt DLL files. If you want to run NifSkope from the release directory, you need to copy those files to that directory. The files are
mingwm10.dll QtCore4.dll QtGui4.dll QtNetwork4.dll QtOpenGL4.dll QtXml4.dll
and can all be found in C:\Qt\4.5.3\bin\.
Optional: Creating The Installer
The official installer is created in the following way. First, make sure you have installed
- Python 2.5 in C:\Python25, and
- NSIS.
Browse to the niftools\nifskope\win-install directory, and run makeexe.bat. You may have to press return a few times in the console window that pops up. At the end, you have an installer for your nifskope!
MSVC Build
EDITORIAL NOTE: the MSVC build has not yet been tested with Qt 4.5.0 or higher
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 come with Qt 4.
Getting Qt and Subversion
First grab qt and subversion from your distribution's repository if you do not already have it. Below are the commands for doing so on Fedora.
Fedora 8
su yum install qt4 qt4-devel qt4-x11 subversion gcc-c++ make exit
Fedora 9 & 10 & 11 & 12
su yum install qt qt-devel qt-x11 subversion gcc-c++ make exit
Get The NifSkope Source Code
Now you have Qt and subversion, grab the NifSkope source code:
cd svn co https://niftools.svn.sf.net/svnroot/niftools/trunk niftools
Compiling NifSkope
Finally, run qmake and make:
cd niftools/nifskope ./makeconfig.sh qmake-qt4 make
Note that 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. 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 svn co https://niftools.svn.sf.net/svnroot/niftools/trunk niftools cd niftools/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!
