Skip to content
⌘ NSIS Forum Archive

Building NSIS with vc9

39 posts

jimpark#
Scons 1.2.0 does not fix the compilation issues with MSVS 2008 (VC9), unfortunately. However, there is a simple patch you can apply to msvc.py in your Python\Lib\site-packages\scons-1.2.0\Scons\Tool. The URL for the bug report and the patch is here: http://scons.tigris.org/issues/show_bug.cgi?id=2224

One thing we probably should do with Vc9 is add:

#include <shellapi.h>
to Platform.h

The reason for this is that in the newer SDKs, the FOF macros are now defined in shellapi.h instead of elsewhere. This causes MACRO redefinition warnings to appear since Platform.h defines them and then shellapi.h defines them again.
jimpark#
I should also mention that the above patch only works in the command line where you run vsvars32.bat to set up the environment variables correctly.
kichik#
shellapi.h added, thanks. But that SCons patch is, again, against SCons spirit and that's why it requires vsvars32.bat. Those paths are surely saved somewhere in the registry or in some XML file.
jimpark#
Well, hopefully they will figure it out on their next release. They're approach still doesn't help you if you have multiple versions of MS Developer Studio installed on your machine. It always assumes that you will want to compile with the latest and that is not true -- for instance that fact that Scons doesn't support Vc9 makes you wish you can tell Scons to just use Vc8. So I think really the best way to get that intent across to Scons is either add a parameter to Scons to tell it which version of which compiler to use, or it reads the needed information through environment variables, assuming that the user knows what he's doing. This whole going into the registry to figure out what's installed and trying to glean the setup information just doesn't work when Microsoft just decides that some of that information will be in some new other mechanism. For every release of MSDEV, Scons will be behind.
jimpark#
I'm not sure that it works.

Every compiler I know takes cues from the environment and Microsoft's compiler is no exception. If your cmd.exe environment is setup for Vc9 and then you try to compile it for Vc8, is it guaranteed to work? Or would you have the potential for conflicting header files and libraries?

It just seems to me that Scons' most fragile feature is the gleaning of the environment variables from the registry. Scons is so useful but I think it shoots itself in the foot when it tries to do something that it really ought not. Let the developer set up the usual environment for the compiler. Trust that he knows what he's doing. Have Scons worry about the project settings being correct for that compiler minus what's usually gotten from the environment. Then I would imagine that Scons won't break as often when a compiler vendor comes out with a new version. Each compiler vendor has to support a command line environment that works -- so make use of that environment.

Of course, this is just my two cents.
kichik#
But it does work 🙂

It redefines the environment according to the selected version (defaulting to the highest) and ignores anything you define on your on in your cmd.exe. That's what Visual Studio does as well, so there's no reason it shouldn't work.

As for letting the developer setup his environment, I'd rather not. We are not talking about Linux. Most developers I know and certainly most developers I've gotten questions from, don't know much about the environment. I love it that SCons sets it up for them. New versions are bound to come along but ignoring the old versions won't solve anything. An option is something else and still not a perfect solution as the flags might be all wrong.

I will probably be creating a VC9 tool definition for scons soon for another project. If that happens, I'll submit it as a patch to scons after I add it to NSIS.
Mixesoft#
Building NSIS 2.46: Python v2.65 + Scons 1.3.0 + VS2010 Express + Windows SDK v7.1

1. Download Python Windows installer 2.x from:
http://www.python.org/download/ and install it,
for example into:
C:\Dev\Python26


2. Download latest Scons for Windows from:
http://scons.org/download.php and install it.


3. Download NSIS source from:
http://nsis.sourceforge.net/Download
and unpack all NSIS files, for example, into
C:\Dev\NSIS

4. Open file named ms located at C:\Dev\NSIS\SCons\Config dir.

Comment the following lines and save file:
90:	#stub_env.Append(LINKFLAGS = ['/opt:nowin98'])
108: #makensis_env.Append(LINKFLAGS = ['/opt:nowin98'])
119: #plugin_env.Append(LINKFLAGS = ['/opt:nowin98'])
130: #util_env.Append(LINKFLAGS = ['/opt:nowin98'])
5. Open file named SConstruct located at C:\Dev\NSIS dir.
Add after line:
152:	opts.Add(BoolVariable('MSTOOLKIT', 'Use Microsoft Visual C++ Toolkit', 'no'))
the following line:
opts.Add(EnumVariable('MSVS_VERSION', 'MS Visual C++ version', os.environ.get('MSVS_VERSION'), allowed_values=('6.0', '7.0', '7.1', '8.0', '8.0Exp', '9.0','9.0Exp', '10.0', '10.0Exp')))

6. Run Visual Studio 2010 command prompt:
Start > All Programs > Microsoft Visual Studio 2010 Express > Visual Studio Command Prompt 2010

Set current directory to NSIS:
cd C:\Dev\NSIS
Run the following command:
scons SKIPUTILS="NSIS Menu" SKIPPLUGINS=all MSVS_VERSION=10.0Exp
bltomov#
Thank you for the detailed build instructions.
I was now able to build NSIS on XP + VS2010 Express + Windows SDK v7.
Please note, that the python version must be 2.6 or greater.