Hello,
I am trying to build nsis with mingw-w64 project [1].
This project is better maintained and much more complete in many ways.
Some difficulties...
1. New triplets should be added:
i[3-6]86-w64-mingw32
x86_64-w64-mingw32
2. min() is not defined.
3. Includes should be at lower case.
4. Library gets:
/usr/lib/gcc/i686-w64-mingw32/4.4.2/../../../../i686-w64-mingw32/sys-include/commctrl.h:14:2: error: #error _WIN32_IE setting conflicts
5. bug#1753070 at the end I cannot link and run 32bit on my machine... So I cannot test the above.
Attached is a patch I created for 1-4.
Thanks for the patch. I'm a bit afraid of the _WIN32_IE change. The resulting installer should work on Windows 95 and above. That kind of change might make that impossible. I am fully aware of all that stands behind and against this, but an obscure compiler compatibility is not a reason to drop it. Besides, it looks more of a bug in the headers as _WIN32_IE is supposed to modify their behavior. The header should not define it on its own.
The problem is not that the header defines its own value, but the header does not compatible with older interface.
I prefer autotools build system, and not fully understand nsis... But you can probably define this to different values if compiling using MSC or MinGW, right?
Or in source:
#ifdef _MSC_VER
#define _WIN32_IE <whatever>
#else
#define _WIN32_IE <whatever>
#endif
What do you prefer?
My MinGW header files work fine. It's something with the 64-bit version. What exactly is the trigger for this error if not a pre-existing definition of _WIN32_IE?
Yes it is mingw-w64 and not mingw32 issue. mingw-w64 can be compiled as 32bit or 64bit, and its win32 api is much more up-to-date and usable. So it worth the effort of supporting it.
From: commctrl.h
#ifndef _WINRESRC_
#ifndef _WIN32_IE
#define _WIN32_IE 0x0501
#else
#if (_WIN32_IE < 0x0501)
#error _WIN32_IE setting conflicts
#endif
#endif
#endif
Maybe undefining _WINRESRC_ is a better solution? Can you attach the whole file? I can't understand yet why this error exists.
_WINRESRC_ is used for .rc include only, nobody should set this for compile.
As I wrote before, the w64api is no backwards compatible with very old MS API, so they fail if you try to use this API.
nsis does not use anything from the old API as it compiles successfully.
> 5. bug#1753070 at the end I cannot link and run 32bit on my machine...
> So I cannot test the above.
It would be great if could try out the patch for bug #1753070 and report back your results.
nsis-2.46-mingw.patch
Attached is a rebase of the patch.
It is still needed even with the win64 patch.
Please notice that there are two mingw branches today. The w32 (old) branch and the w64 (new) branch. The w64 is capable of compiling both 32bit and 64bit, and can replace the w32 branch that is in deep sleep.
Both mingw versions will work with recent _WIN32_IE.
BTW: You currently compiling the windows binaries as 32bit, nothing to gain if compiling as 64bit?
The patch for bug #1753070 should enable that makensis (NSIS script compiler) and portable utilities can be built natively for 64-bit systems (Win64, Debian amd64, Gentoo amd64, ...)
So far I have not taken into consideration to build the plug-ins and stubs for native Win64.
OK. It does not compile under win64... :) example GWL_WNDPROC usage that should be converted to GWLP_WNDPROC.
BTW: If you use Gentoo, try to build w64 cross toolchain for testing...
$ ACCEPT_KEYWORDS="~amd64" emerge crossdev
$ crossdev -t i686-w64-mingw32
I cross compiled (x86_64-w64-mingw32) makensis and its surrounding utilities for Win64.
The resulting installer can be downloaded from:
http://f0rt.users.sourceforge.net/nsis-2.46+_64bit-setup.exe
I have not tested the installer because I don't have access to a Win64 system.
Please be aware that the installer does not check that the installation is performed on a Win64 system.
The stubs and plug-ins were compiled with mingw32 because the generated cross compiler does only support the compilation for a 64-bit environment.
echo 'int printf(const char *format, ...); int main(int c, char *v[]) { return printf ("Hello World!\n"); }' | x86_64-w64-mingw32-gcc -x c -m32 -Wall -
/tmp/ccdsa25T.s: Assembler messages:
/tmp/ccdsa25T.s:10: Error: suffix or operands invalid for `push'
So the source code for stubs and plug-ins may yet not be compilable by w64-mingw32.
http://f0rt.users.sourceforge.net/nsis_w64-mingw.patch
This patch is based on alonbl's version.
I adapted the handling for the _WIN32_IE define:
By default the original settings for _WIN32_IE are used but the setting could be overruled by specifying the _WIN32_IE define as command line option of the compiler. (See nsis_w64-mingw_scons.patch)
mingw32 expects BOOL as a return value for the DialogProc callback function. This clashes with the official specification
http://msdn.microsoft.com/en-us/library/ms645469%28VS.85%29.aspx [DialogProc Function]
and w64-mingw32 complains about it as well. Therefore I changed it from BOOL to INT_PTR. However the issue needs to be resolved for mingw32.
GCL_HICON -> GCLP_HICON
(LONG) pointer -> (LONG_PTR) pointer
wsock32 -> ws2_32
NSIS Menu: ordered libs to allow compilation with w64-mingw32 and added gcc_libnsis as search path for header and library files.
http://f0rt.users.sourceforge.net/nsis_w64-mingw_scons.patch
Hacked gnu Scons file to work with w64-mingw32.
Steps performed to build makensis and its surrounding utilities natively for Win64 (Host system Gentoo amd64):
# Build cross tool chain
sudo USE=-hardened crossdev --target x86_64-w64-mingw32
# Create build directory
mkdir /tmp/nsis_build
cd /tmp/nsis_build
# Build zlib
mkdir zlib
cd zlib
wget http://downloads.sourceforge.net/project/libpng/zlib/1.2.4/zlib-1.2.4.tar.bz2
tar xvf zlib-1.2.4.tar.bz2
cd zlib-1.2.4
sed -i.orig 's/^\(CC|AR|RC\)\s*=\s*\(.\+\)/\1 = x86_64-w64-mingw32-\2/g' win32/Makefile.gcc
make -f win32/Makefile.gcc
mkdir lib
cp *.a lib
mkdir include
cp zconf.h zlib.h include
cd ..
# Build WX widgets for Win64 (specific for NSIS Menu)
mkdir wxwin
cd wxwin
wget http://downloads.sourceforge.net/project/wxwindows/wxMSW/2.8.10/wxMSW-2.8.10.zip
unzip wxMSW-2.8.10.zip
wget http://f0rt.users.sourceforge.net/wxMSW_w64-mingw.patch.gz
gzip -dc wxMSW_w64-mingw.patch.gz | patch -p0
cd wxMSW-2.8.10/build/msw
make -f makefile.gcc SHELL=${SHELL} CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ AR=x86_64-w64-mingw32-ar RANLIB=x86_64-w64-mingw32-ranlib WINDRES=x86_64-w64-mingw32-windres CFG=nsis BUILD=release RUNTIME_LIBS=dynamic SHARED=0 UNICODE=0 WXUNIV=0 USE_OPENGL=0 USE_ODBC=0 USE_HTML=1 USE_XRC=0
cd ../../../..
# NSIS
svn co https://nsis.svn.sourceforge.net/svnroot/nsis/NSIS/trunk nsis
cd nsis
wget http://f0rt.users.sourceforge.net/makensis_64bit.patch
patch -p0 < makensis_64bit.patch
wget http://f0rt.users.sourceforge.net/nsis_w64-mingw.patch
patch -p0 < nsis_w64-mingw.patch
wget http://f0rt.users.sourceforge.net/nsis_w64-mingw_scons.patch
patch -p0
scons VERSION=2.46+ PREFIX=/usr PREFIX_CONF=/etc PREFIX_PLUGINAPI_INC=/usr/i686-mingw32/usr/include PREFIX_PLUGINAPI_LIB=/usr/i686-mingw32/usr/lib CHMDOCS=0 STRIP=yes STRIP_CP=yes STRIP_W32=yes ZLIB_W32=/tmp/nsis_build/zlib/zlib-1.2.4 WXWIN=/tmp/nsis_build/wxwin/wxMSW-2.8.10
scons VERSION=2.46+ PREFIX=/usr PREFIX_CONF=/etc PREFIX_PLUGINAPI_INC=/usr/i686-mingw32/usr/include PREFIX_PLUGINAPI_LIB=/usr/i686-mingw32/usr/lib CHMDOCS=0 STRIP=yes STRIP_CP=yes STRIP_W32=yes ZLIB_W32=/tmp/nsis_build/zlib/zlib-1.2.4 WXWIN=/tmp/nsis_build/wxwin/wxMSW-2.8.10 test-scripts
cd .test
makensis Examples/makensis.nsi
# NSIS.chm has to be taken from a Windows installation, I commented out the inclusion of the plug-in api files
nsis-2.46.ebuild.diff
I just use the nsis ebuild with the patches :) (attached)
But the latest does not work, I don't know how to set the sccons _WIN32_IE from externally.
I updated the patch for w64-mingw32:
http://f0rt.users.sourceforge.net/nsis_w64-mingw.patch
I added the CROSS_W32 option to explicitly specify the cross toolchain for building Windows executables.
(This is useful if you have more than one suitable cross toolchain installed on your system)
In addition the _WIN32_IE define provided as compiler option takes also predominance for building the stubs.
_WIN32_IE is preset for w64-mingw32 to the value 0x0501.
For your convenience I uploaded the NSIS ebuild file which I used for verification.
http://f0rt.users.sourceforge.net/nsis-2.46.ebuild
Great work!
Last question... should nsis be compiled now using win64? x86_64-w64-mingw32? As far as I can see there are fixups required for win64...
The patches from #1753070 and this tracker item should allow the building of makensis and its related utilities for native Win64.
However the build scripts have not yet been adapted to facilitate that.
[At least the cross compiling of makensis and its related utilities is not supported if build and host system are different. The compilation might work if you install w64-mingw32 on a Win64 system. In that case scons should recognize w64-mingw32 as a native gnu compiler and process the build scripts.]
Furthermore the resulting Win64 executables require testing. Unfortunately I don't have access to a Win64 system.
The installer package including the Win64 executables was built via the cross compiler x86_64-w64-mingw32 on a Gentoo amd64 system with a hacked build script. If you have a Win64 system then you are more than welcome to test it and report back.
Hi,
It will be really nice if you can merge this for next version. Very difficult to keep rebase this.
The minimum required is to be able to cross-compile using mingw-64 which unlike mingw is actively maintained.
Thanks!
We don't even know if there will be another 2.x release. Why not provide patches against v3.x trunk instead?
Why does this patch change wsock32 to ws2_32 (MakeNsisW)? Windows 95 RTM only has WinSock v1 and this breaks it. I doubt anybody is compiling on Win95 these days but it would be nice if the patch included some details about the things it breaks (for no reason?).
Last edit: Anders 2016-06-12
it was submitted 5 years ago... should already been addressed, please take whatever you need to make 3.x version compatible with cross compile and 64bit.
winsock-2 is available ever since windows for workgroup 32bit pack as far as I know, but again, it will be great if you work in order to be able to cross compile the project and keep whatever backward compatibility required.