Skip to content
⌘ NSIS Forum Archive

Compiling NSIS with MinGW in Windows?

8 posts

roytam1#

Compiling NSIS with MinGW in Windows?

I tried to compile NSIS with MinGW gcc but I got following error:

G:\NSIS>scons TOOLSET=gcc UNICODE=yes
scons: Reading SConscript files ...
Delete("nsis-27-Nov-2013.cvs")
Delete(".instdist")
Delete(".test")
Using GNU tools configuration
Checking for linker flag $MAP_FLAG... AttributeError: 'SConsEnvironment' object has no attribute 'Program':
File "G:\NSIS\SConstruct", line 488:
envs = SConscript('SCons/Config/gnu')
File "c:\Python27\Lib\site-packages\scons-2.3.0\SCons\Script\SConscript.py", line 609:
return method(*args, **kw)
File "c:\Python27\Lib\site-packages\scons-2.3.0\SCons\Script\SConscript.py", line 546:
return _SConscript(self.fs, *files, **subst_kw)
File "c:\Python27\Lib\site-packages\scons-2.3.0\SCons\Script\SConscript.py", line 260:
exec _file_ in call_stack[-1].globals
File "G:\NSIS\SCons\Config\gnu", line 111:
conf.CheckLinkFlag('$MAP_FLAG') # generate map file
File "c:\Python27\Lib\site-packages\scons-2.3.0\SCons\SConf.py", line 640:
ret = self.test(context, *args, **kw)
File "G:\NSIS\SCons\utils.py", line 101:
result = ctx.TryLink(test, extension)
File "c:\Python27\Lib\site-packages\scons-2.3.0\SCons\SConf.py", line 808:
return self.sconf.TryLink(*args, **kw)
File "c:\Python27\Lib\site-packages\scons-2.3.0\SCons\SConf.py", line 611:
return self.TryBuild(self.env.Program, text, extension )
how can I fix it?
Anders#
I know compiling with MinGW works so the problem is probably with scons, try scons 2.0 or 1.3?

I don't remember which version I'm using, 1.2 maybe. New scons versions tends to break things so I refuse to upgrade.
roytam1#
I tried 1.2.0 but with same result:
G:\NSIS>scons-1.2.0.bat TOOLSET=gcc UNICODE=yes
scons: Reading SConscript files ...
Delete("nsis-27-Nov-2013.cvs")
Delete(".instdist")
Delete(".test")
Using GNU tools configuration
Checking for linker flag $MAP_FLAG... AttributeError: SConsEnvironment instance has no attribute 'Program':
File "G:\NSIS\SConstruct", line 488:
envs = SConscript('SCons/Config/gnu')
File "c:\Python27\Lib\site-packages\scons-1.2.0\SCons\Script\SConscript.py", line 612:
return apply(method, args, kw)
File "c:\Python27\Lib\site-packages\scons-1.2.0\SCons\Script\SConscript.py", line 549:
return apply(_SConscript, [self.fs,] + files, subst_kw)
File "c:\Python27\Lib\site-packages\scons-1.2.0\SCons\Script\SConscript.py", line 259:
exec _file_ in call_stack[-1].globals
File "G:\NSIS\SCons\Config\gnu", line 111:
conf.CheckLinkFlag('$MAP_FLAG') # generate map file
File "c:\Python27\Lib\site-packages\scons-1.2.0\SCons\SConf.py", line 636:
ret = apply(self.test, (context,) + args, kw)
File "G:\NSIS\SCons\utils.py", line 101:
result = ctx.TryLink(test, extension)
File "c:\Python27\Lib\site-packages\scons-1.2.0\SCons\SConf.py", line 805:
return apply(self.sconf.TryLink, args, kw)
File "c:\Python27\Lib\site-packages\scons-1.2.0\SCons\SConf.py", line 606:
return self.TryBuild(self.env.Program, text, extension )
Anders#
And if you remove TOOLSET=gcc?

I'll take a look at which scons version I'm using and the command line tomorrow...
Anders#
I'm using scons 1.2 but not TOOLSET=gcc, it should be able to find the compiler by looking in %path%
roytam1#
alright I think I found a way to force scons to use gcc instead of my old vc2003 compiler.
scons TOOLSET=gcc,gnulink,mingw UNICODE=yes "PATH=%PATH%" dist 2>&1|tee scon.log
but I wonder if gcc-4.6.3 is not new enough for compiling NSIS?
I got error when compiling script.c:
scons: Reading SConscript files ...
Delete("nsis-29-Nov-2013.cvs")
Delete(".instdist")
Delete(".test")
Using GNU tools configuration
Checking for linker flag $MAP_FLAG... (cached) yes
Checking for linker flag -s... (cached) yes
Checking for linker flag $MAP_FLAG... (cached) yes
Checking for linker flag -s... (cached) yes
Checking for memcpy requirement... (cached) yes
Checking for memset requirement... (cached) yes
Checking for linker flag -pthread... (cached) no
Checking for __BIG_ENDIAN__... (cached) no
Checking for C library gdi32... (cached) yes
Checking for C library user32... (cached) yes
Checking for C library pthread... (cached) yes
Checking for C library iconv... (cached) yes
Checking for C library shlwapi... (cached) yes
Checking for C library version... (cached) yes
Checking for C library zdll... (cached) yes
Checking for C library zdll... (cached) yes
Checking for C library zdll... (cached) yes
Checking for C library dl... (cached) no
Checking for C library gdi32... (cached) yes
Checking for C library iconv... (cached) yes
Checking for C library pthread... (cached) yes
Checking for C library user32... (cached) yes
Checking for C library version... (cached) yes
Checking for C library zdll... (cached) yes
Checking for C++ library cppunit... (cached) no
scons: done reading SConscript files.
scons: Building targets ...
Install file: "build\urelease\VPatch\Source\GenPat\GenPat.exe" as "nsis-29-Nov-2013.cvs\Bin\GenPat.exe"
Install file: "build\urelease\Library\LibraryLocal\LibraryLocal.exe" as "nsis-29-Nov-2013.cvs\Bin\LibraryLocal.exe"
Install file: "build\urelease\MakeLangId\MakeLangId.exe" as "nsis-29-Nov-2013.cvs\Bin\MakeLangId.exe"
g++ -o build\urelease\makensis\script.o -c -Wno-non-virtual-dtor -Wall -O2 -DNSISCALL="__attribute__((__stdcall__))" -D_UNICODE -DUNICODE -DMAKENSIS -D_WIN32_IE=0x0500 -Ibuild\urelease\config -ID:\zlib-1.2.8 Source\script.cpp
Source\script.cpp: In member function 'int CEXEBuild::doCommand(int, LineParser&)':
Source\script.cpp:4361:39: error: no matching function for call to '__countof_helper(CEXEBuild::doCommand(int, LineParser&)::<anonymous struct> [19])'
Source\script.cpp:4361:39: note: candidate is:
c:\strawberry\c\bin\../lib/gcc/i686-w64-mingw32/4.6.3/../../../../i686-w64-mingw32/include/stdlib.h:294:65: note: template<class _CountofType, unsigned int _SizeOfArray> char (* __countof_helper(_CountofType (&)[_SizeOfArray]))[_SizeOfArray]
Source\script.cpp:4362:30: error: no matching function for call to '__countof_helper(CEXEBuild::doCommand(int, LineParser&)::<anonymous struct> [19])'
Source\script.cpp:4362:30: note: candidate is:
c:\strawberry\c\bin\../lib/gcc/i686-w64-mingw32/4.6.3/../../../../i686-w64-mingw32/include/stdlib.h:294:65: note: template<class _CountofType, unsigned int _SizeOfArray> char (* __countof_helper(_CountofType (&)[_SizeOfArray]))[_SizeOfArray]
Source\script.cpp:5044:39: error: no matching function for call to '__countof_helper(CEXEBuild::doCommand(int, LineParser&)::<anonymous struct> [15])'
Source\script.cpp:5044:39: note: candidate is:
c:\strawberry\c\bin\../lib/gcc/i686-w64-mingw32/4.6.3/../../../../i686-w64-mingw32/include/stdlib.h:294:65: note: template<class _CountofType, unsigned int _SizeOfArray> char (* __countof_helper(_CountofType (&)[_SizeOfArray]))[_SizeOfArray]
Source\script.cpp:5046:30: error: no matching function for call to '__countof_helper(CEXEBuild::doCommand(int, LineParser&)::<anonymous struct> [15])'
Source\script.cpp:5046:30: note: candidate is:
c:\strawberry\c\bin\../lib/gcc/i686-w64-mingw32/4.6.3/../../../../i686-w64-mingw32/include/stdlib.h:294:65: note: template<class _CountofType, unsigned int _SizeOfArray> char (* __countof_helper(_CountofType (&)[_SizeOfArray]))[_SizeOfArray]
scons: *** [build\urelease\makensis\script.o] Error 1
scons: building terminated because of errors.
JasonFriday13#
I've been testing and debugging the linux build using gcc, and I haven't seen this error before. I can't really help though as I use VS2008 for windows compiling.
Anders#
We have a macro called COUNTOF and it tries to use the version in the compiler if possible but I guess gcc is unable to handle anonymous structs. You can try to force our custom version of COUNTOF by removing the #ifdef __countof part...