Previous | Contents | Next

Appendix G: Building NSIS

NSIS version 2.07 introduced a new build system, based on SCons. The build system can build the entire NSIS package so there is no longer need to build it project by project. It allows building using several simultaneous jobs, installation without an installer on both Windows and POSIX and easy compilation with debugging symbols.

G.1 Building in General

Source code is available in CVS and as a separate package with every NSIS distribution.

To build NSIS Python and SCons must be installed. Currently, the supported version of SCons is version 0.96.91. Any version of Python above 1.6 is supported.

To build, open a console, change the working directory to the root directory of NSIS and type scons. That's it. For example:

C:\>cd dev\nsis
C:\dev\nsis>scons
scons: Reading SConscript files ...
Using Microsoft tools configuration
Checking for main() in C library gdi32... (cached) yes
Checking for main() in C library user32... (cached) yes
Checking for main() in C library version... (cached) yes
Checking for main() in C library pthread... (cached) no
Checking for main() in C library stdc++... (cached) no
Checking for main() in C library iconv... (cached) no
Checking for main() in C library libiconv... (cached) no
scons: done reading SConscript files.
scons: Building targets ...
...

To install the built files, type:

scons PREFIX="C:\Program Files\NSIS" install

To create an installer (only on Windows), type:

scons dist-installer

To create a distribution zip file, type:

scons dist-zip

To create both, type:

scons dist

To get a complete list of options that the build system has to offer, type:

scons -h

To get a complete list of options SCons has to offer, type:

scons -H

G.2 Building on Windows

If you have Microsoft Visual C++ installed, SCons will automatically detect and use it. If you don't have it, you can download the free Visual C++ Toolkit and Platform SDK. The build system doesn't automatically recognize the toolkit, so you'll have to give it a hint:

scons MSTOOLKIT=yes

If you get errors about the compiler or the Platform SDK not being found, use:

set MSSDK=C:\Path\To\Platform SDK
set VCToolkitInstallDir=C:\Path\To\VCToolkit
scons MSTOOLKIT=yes

You can also build using the open-source MinGW, but this results in noticeably larger installers. Borland C++ or Open Watcom C/C++ might also work, but haven't been tested.

To compile the documentation as a CHM file, you must have hhc.exe from HTML Help Workshop in the PATH.

Important notes for Microsoft Visual C++ 6.0 users: You should install the latest Platform SDK. Because of flaws in the libraries distributed with Microsoft Visual C++ 6.0, not installing the Platform SDK will result in crashes when using the CopyFiles command. See this forum topic for more information. Installing the Processor Pack is highly recommended to decrease the size of the installer overhead.

G.3 Building on POSIX

As of NSIS 2.01, the compiler, makensis, also compiles on POSIX platforms. POSIX platforms include Linux, *BSD, Mac OS X and others. Since the generated installer will eventually run on Windows, you need a cross-compiler in order to compile them.

If you don't have a cross compiler, you can use:

scons SKIPSTUBS=all SKIPPLUGINS=all SKIPUTILS=all SKIPMISC=all NSIS_CONFIG_CONST_DATA_PATH=no

This should only build makensis. Once you have makensis, you can drop it in a downloaded precompiled package such as the nightly build or a zipped release version (nsis-x.xx.zip). Note that the in order for this to work, the precompiled package must be compiled using the exact same sources as makensis. In particular, Source\exehead\config.h and Source\exehead\fileform.h must be identical.

Currently, the System plug-in can't be built using a cross-compiler, but only with MSVC. When building with a cross compiler, always use at least the following flags:

scons SKIPPLUGINS=System

G.4 Nightly Builds

If you don't want to build NSIS on your own but want to get the latest CVS version, you can use the nightly build. The nightly build is automatically generated every night from source code in CVS.

Previous | Contents | Next