Old 24th January 2019, 16:57   #1
papo77
Junior Member
 
Join Date: Jan 2019
Posts: 2
Question makensis x64 installer

Hi everybody,
after a whole afternoon searching on the Web I give up: I can't find a way to force makensis to produce a x64 only installer.

I also tried /DARCH=x86/64 and /DARCH=x64 but nothing: installer.exe is always a 32 bit process. :-(

Why do I need a x64 installer?

Because I want to restrict the program installation to x64 Windows machines only.


ANY help or suggestion is very welcome, thanks!

Oh, I also accept answers such as "RTFM" provided there's a link to the right topic :-)
papo77 is offline   Reply With Quote
Old 24th January 2019, 18:07   #2
Nutzzz
Member
 
Join Date: May 2007
Location: Orange County, CA, U.S.A.
Posts: 54
There is a 64-bit fork of NSIS, but it has some issues and AFAIK it hasn't been updated in quite some time.

However, there's really no need for NSIS to be a native 64-bit app unless you're targeting Windows Server Nano. If you !include LogicLib.nsh and x64.nsh, you can do something like this:
code:
${IfNot} ${RunningX64}
Abort
${EndIf}
${DisableX64FSRedirection}
SetRegView 64


${RunningX64} returns true for either a 64-bit NSIS or a 32-bit NSIS running on a 64-bit OS.
${DisableX64FSRedirection} means when you refer to $SYSDIR or $PROGRAMFILES, it's the 64-bit ones (e.g., C:\Windows\System32 instead of C:\Windows\SysWOW64, which confusingly is the 32-bit one).
SetRegView does the same thing for the 64-bit registry location (i.e., don't allow Windows to automatically redirect into the equivalent location under WOW6432Node).
Nutzzz is offline   Reply With Quote
Old 24th January 2019, 18:41   #3
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,014
Quote:
Originally Posted by Nutzzz View Post
There is a 64-bit fork of NSIS, but it has some issues and AFAIK it hasn't been updated in quite some time.
The official NSIS source code can be compiled as 64-bit as well (but the System plug-in is not fully functional). 32-bit MakeNSIS can produce 64-bit installers but you have to compile or get the 64-bit stubs and plug-ins first, and then add "Target AMD64-Unicode" to your .NSI.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 24th January 2019, 19:07   #4
Nutzzz
Member
 
Join Date: May 2007
Location: Orange County, CA, U.S.A.
Posts: 54
Quote:
Originally Posted by Anders View Post
...but the System plug-in is not fully functional
Is there a place where the limitations of the 64-bit System plugin are documented?
Nutzzz is offline   Reply With Quote
Old 24th January 2019, 20:17   #5
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,014
Quote:
Originally Posted by Nutzzz View Post
Is there a place where the limitations of the 64-bit System plugin are documented?
Not really but the only thing I can think of is System::Get (and the k type https://sourceforge.net/p/nsis/bugs/1198/) because the code for callbacks has not been written for that platform yet.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 25th January 2019, 12:03   #6
papo77
Junior Member
 
Join Date: Jan 2019
Posts: 2
Thumbs up

Thanks a lot to both of you guys, you solved my problem.

For the moment I won't try the compilation thing because , if I got it right, x64 is not fully supported by NSIS dev people; fine for me.

So I ended up with that:

Quote:
!include x64.nsh

Function .onInit
${IfNot} ${RunningX64}
MessageBox MB_OK|MB_ICONINFORMATION "This program runs on x64 machines only, exiting"
Abort
${EndIf}
${DisableX64FSRedirection}
FunctionEnd

where I only added the MessageBox that shows up even in a silent installer (I'm forced to notify the user about what happened).


So, again, thanks a lot for your help dudes!
papo77 is offline   Reply With Quote
Old 9th February 2019, 10:52   #7
dgnuff
Junior Member
 
Join Date: Jun 2014
Posts: 3
Quote:
Originally Posted by Anders View Post
The official NSIS source code can be compiled as 64-bit as well (but the System plug-in is not fully functional). 32-bit MakeNSIS can produce 64-bit installers but you have to compile or get the 64-bit stubs and plug-ins first, and then add "Target AMD64-Unicode" to your .NSI.
Just looking in the Stubs folder, I can see the installer stubs, as well as uninst, which is obviously the uninstaller stub.

Which reminds me, what's the best way to handle registry access if I have a 64 bit installer stub and a 32 bit uninstaller stub. Should I be OK if I just specify HKCU64 / HKLM64 for both?

I'm a little curious what the effect of "SetRegView 64" will be on a program that's already 64 bit.

Or just build a 64 bit uninstaller stub and be done with it?
dgnuff is offline   Reply With Quote
Old 9th February 2019, 12:24   #8
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,014
Quote:
Originally Posted by dgnuff View Post
Just looking in the Stubs folder, I can see the installer stubs, as well as uninst, which is obviously the uninstaller stub.

Which reminds me, what's the best way to handle registry access if I have a 64 bit installer stub and a 32 bit uninstaller stub. Should I be OK if I just specify HKCU64 / HKLM64 for both?

I'm a little curious what the effect of "SetRegView 64" will be on a program that's already 64 bit.

Or just build a 64 bit uninstaller stub and be done with it?
uninst is just a icon, the uninstaller is actually generated from the installer stub.

A 64-bit app is SetRegView 64 by default.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 10th February 2019, 03:29   #9
dgnuff
Junior Member
 
Join Date: Jun 2014
Posts: 3
Thumbs up

It turns out it's fairly simple to build a 64 bit stub. Since this is obviously a Windows only thing I didn't bother trying to set up Python and SCons, I just built a standard VS 2019 Preview solution.

The code compiles as is, with one exception, I got a ton of complaints about NSISCALL. It's defined in api.h, but (for example) components.c tries to use it without including api.h. Since stdcall and cdecl have no effect for amd64 builds with MSVC anyway, I just defined NSISCALL to be empty in Platform.h, and moved on.

It took quite a while to find the commands needed to use the 64 bit stub, since as far as I can tell, the CPU command isn't documented in nsis.chm. Not really a surprise, since the standard Windows distribution only has x86 stubs. However a little code archaeology found it in tokens.cpp, and by adding these two lines to the top of my script, just after setting the compression:

CPU amd64
Unicode true

it all works right.

I'd need to make a total of five more stubs for a complete set: three compressors and solid / non-solid for each: I only have lzma non-solid working now. If you're interested, I can get that done, it'll be pretty fast now that I know how, and send the whole lot your way.

I'd have to leave it to one of you to convert from the MSVC solution to SCons, but I'd guess that you guys being experts with SCons should be able to get it done fairly easily. That should give you the ability to create 64 bit installers for those that need them. My main reason is so that the installer won't even start on a 32 bit system, since 64 bit software is all I create nowadays.
dgnuff is offline   Reply With Quote
Old 10th February 2019, 09:41   #10
JasonFriday13
Major Dude
 
JasonFriday13's Avatar
 
Join Date: May 2005
Location: New Zealand
Posts: 872
The 64 bit builds haven't seen much changes since nsis 3.0 was released. In scons, it's as easy as adding TARGET_ARCH="amd64" to the command line (I use VS2008 on windows, mingw-w64 works on linux too). There is also an undocumented Target command, which takes x86-ansi, x86-unicode, and amd64-unicode.

"Only a MouseHelmet will save you from a MouseTrap" -Jason Ross (Me)
NSIS 3 POSIX Ninja
Wiki Profile
JasonFriday13 is offline   Reply With Quote
Old 10th February 2019, 12:45   #11
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,014
System::Get is incomplete in 64-bit builds.

scons sets NSISCALL, building without scons is unsupported so you might see issues. scons also sets the compiler switches etc.

The CPU/Target instructions are undocumented because we have not settled on the final syntax.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Tags
64-bit

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump