Niflib/Compile

From NifTools
Jump to: navigation, search

Preparation

  • Obtain the source code either from a source archive release or by cloning the git repository.
  • Get Visual C++ 2005 Express. [1]
  • If you want to compile Niflyze, also download and install the Windows Platform SDK. [2] You only need to install the core x86 component to compile niflib (requires only about 100MB instead of 1GB for a full install).
    • Select "Custom" installation type.
    • Select "Will not be available" (red cross) for all components.
    • Select "Will be installed on local hard drive" only for the component "MS Windows Core SDK -> Build Environment -> Build Environment (x86 32-bit)"
  • If you want the latest development code, rather than released code, download and install TortoiseSVN [3]

Building Using the Visual Studio 2005 Solution File

  • Open the niflib.sln solution file that you obtained from SVN or the source code archive.
  • From the Build menu, select Configuration Manager...
  • Under Active solution configuration choose Release and press the Close button.
  • From the Build menu, select Build Solution
  • Once the solution is built, you will find niflib.lib in the bin directory above the one you downloaded the niflib source to.

Building Using CMake

To build niflib with any other compiler, such as gcc, a cmake build script is provided. First, download CMake and install it. To build niflib:

  • Create an empty build folder.
  • Run the cmake GUI, select the niflib git checkout as source folder, and the empty build folder as binary folder.
  • Press the "configure" button, then press "generate". This will generate build files for your favorite build system (make, msvc, codeblocks, ...)
  • Then run your build system from within the build folder.

For instance, if you want to use make on linux, and your niflib checkout resides in ~/niflib:

cd
mkdir build
cd build
cmake ../niflib/
make

To cross compile a Windows binary on Fedora, use:

cd
mkdir build
cd build
mingw32-cmake ../niflib/
make

The default is to build a shared debug library. If you want to create a static library, change SHARED into STATIC in CMakeLists.txt and rerun make. If you want to create the library without debug info, set CMAKE_BUILD_TYPE to Release in the cmake gui and rerun make.

Personal tools