Old 3rd September 2018, 18:16   #1
Yathosho
Forum King
 
Yathosho's Avatar
 
Join Date: Jan 2002
Location: AT-DE
Posts: 3,362
Building nsisbi on non-Windows

Has anyone on this forum managed to build nsisbi on macOS or Linux? I'm using the same SCons parameters that work for standard NSIS, but always run into this error:

code:

/usr/local/opt/scons/bin/scons makensis STRIP=0 ZLIB_W32=~/Desktop/zlib128-dll SKIPUTILS=NSIS Menu
Last 15 lines from ~/Library/Logs/Homebrew/nsisbi/01.scons:
^~~~~~~~
ftello
/usr/include/stdio.h:332:8: note: 'ftello' declared here
off_t ftello(FILE * __stream);
^
Source/util.cpp:653:10: error: use of undeclared identifier 'fseeko64'; did you mean 'fseeko'?
return fseeko64(fp, pos, filepos);
^~~~~~~~
fseeko
/usr/include/stdio.h:331:6: note: 'fseeko' declared here
int fseeko(FILE * __stream, off_t __offset, int __whence);
^
2 errors generated.
scons: *** [build/urelease/makensis/util.o] Error 1
scons: building terminated because of errors.



I've also tried specifying different TARGET_ARCH values and 64-bit versions of zlib, but to no avail.
Yathosho is offline   Reply With Quote
Old 3rd September 2018, 19:20   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,907
I'm guessing this is related to 64-bit file sizes. Using 'fseeko' might work, depends on sizeof(off_t). There is usually a define you have to set at the top of the .cpp file before any #includes to trigger 64-bit support. You have to read about it in the documentation for your std c library and #ifdef in whatever code you need for your platform.

There should be plenty information about this, just google "fseek 64 yourplatform" etc.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 4th September 2018, 21:44   #3
Yathosho
Forum King
 
Yathosho's Avatar
 
Join Date: Jan 2002
Location: AT-DE
Posts: 3,362
Thanks for the hint, Anders. This looks promising:https://stackoverflow.com/a/4003512/1329116

Will give it a try on the weekend!
Yathosho is offline   Reply With Quote
Old 8th September 2018, 17:39   #4
Yathosho
Forum King
 
Yathosho's Avatar
 
Join Date: Jan 2002
Location: AT-DE
Posts: 3,362
Building works fine when I add the following to Source/util.h:

code:
#ifdef __APPLE__
# define fseeko64 fseeko
# define ftello64 ftello
#endif



The reason why I'm so interested in getting this to work is Homebrew, a popular package manager for macOS (also available for Linux). Now I have two options integrate this change:

1. patch util.h before building
2. hope that upstream adds this to util.h

Both work fine, but of course the second option feels cleaner. Any objects to add these four lines of code, JasonFriday13?
Yathosho is offline   Reply With Quote
Old 8th September 2018, 19:13   #5
JasonFriday13
Major Dude
 
JasonFriday13's Avatar
 
Join Date: May 2005
Location: New Zealand
Posts: 867
The main reason I have to use fseeko64() is to support installer sizes between 2GB and 4GB. off_t says it is defined as a signed type, so passing it anything over 2GB will cause an error.

You can try creating a 3GB installer and seeing if it errors out.

"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 8th September 2018, 23:52   #6
Yathosho
Forum King
 
Yathosho's Avatar
 
Join Date: Jan 2002
Location: AT-DE
Posts: 3,362
Quote:
Originally Posted by JasonFriday13 View Post
The main reason I have to use fseeko64() is to support installer sizes between 2GB and 4GB
According to that Stack Overflow answer, Darwin file I/O is 64-bit by default since 2007. So for my (little) understanding aliasing *64 should suffice. Anyway, I wonder what you make of second answer, is this the better solution for this case?

Quote:
You can try creating a 3GB installer and seeing if it errors out.
Creating a 10GB installer worked fine!

Last edited by Yathosho; 9th September 2018 at 01:22.
Yathosho is offline   Reply With Quote
Old 9th September 2018, 10:01   #7
JasonFriday13
Major Dude
 
JasonFriday13's Avatar
 
Join Date: May 2005
Location: New Zealand
Posts: 867
Yeah, external files work fine because makensis doesn't need to know the size to write the external file out, it just stores the size in the first header.

All in one installers between 2GB and 4GB might be a problem, because of the signed int overflow, which is why I asked you to try a 3GB installer and see if it runs ok.

fseeko64 might be gcc specific, I'm only using gcc on ubuntu for my testing.

"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 9th September 2018, 12:59   #8
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,907
http://www.gnu.org/software/libc/man...st-Macros.html tells you there are at least 3 configurations: _LARGEFILE_SOURCE, _LARGEFILE64_SOURCE and _FILE_OFFSET_BITS. Some make off_t/fseeko 64-bit and some add 64-bit specific functions and off64_t but at the end of the day you should be able to work with > 4GiB files on anything less than 20 years old probably.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 10th September 2018, 12:11   #9
JasonFriday13
Major Dude
 
JasonFriday13's Avatar
 
Join Date: May 2005
Location: New Zealand
Posts: 867
Cool. In Platform.h, just define this before the includes, and see if that helps:
Quote:
#ifndef _LARGEFILE64_SOURCE
#define _LARGEFILE64_SOURCE
#endif
I would rather have a separate interface for the 64 bit versions, and not have one replace the other.

"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 September 2018, 21:07   #10
Yathosho
Forum King
 
Yathosho's Avatar
 
Join Date: Jan 2002
Location: AT-DE
Posts: 3,362
Quote:
Originally Posted by JasonFriday13 View Post
All in one installers between 2GB and 4GB might be a problem, because of the signed int overflow, which is why I asked you to try a 3GB installer and see if it runs ok.
3GB all-in-one installer works fine!

Quote:
In Platform.h, just define this before the includes, and see if that helps
That throws the same error as in my initial post
Yathosho is offline   Reply With Quote
Old 11th September 2018, 20:14   #11
JasonFriday13
Major Dude
 
JasonFriday13's Avatar
 
Join Date: May 2005
Location: New Zealand
Posts: 867
Ok, so it is probably redirecting fseeko to fseeko64 behind the scenes, so I'll have to test this out (in source/util.h, after the includes):
Quote:
#ifndef fseeko64
#define fseeko64 fseeko
#endif

#ifndef ftello64
#define ftello64 ftello
#endif
I would rather not use platform specific defines, unless the function names are different (like fseeki64 on windows).

"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 12th September 2018, 23:16   #12
Yathosho
Forum King
 
Yathosho's Avatar
 
Join Date: Jan 2002
Location: AT-DE
Posts: 3,362
Quote:
Originally Posted by JasonFriday13 View Post
I would rather not use platform specific defines, unless the function names are different (like fseeki64 on windows).
This works fine. Thank you.
Yathosho is offline   Reply With Quote
Old 9th October 2018, 20:43   #13
Yathosho
Forum King
 
Yathosho's Avatar
 
Join Date: Jan 2002
Location: AT-DE
Posts: 3,362
Will you add these changes in the next version of nsisbi? My Homebrew formula patches the file right now, but of course it would be nicer without it.
Yathosho is offline   Reply With Quote
Old 10th October 2018, 01:56   #14
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,907
I'm not opposed to taking this upstream as well at some point but we don't need it currently. It we ever need it, it should probably be a helper function in util.h. I don't want to take it right now because I don't want to maintain code that is unused (by us), toolchain specific, and not part of the C standard.

The only 64-bit file stuff we currently use is the file size of redirected stdout on Windows (IIRC).

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 10th October 2018, 09:18   #15
JasonFriday13
Major Dude
 
JasonFriday13's Avatar
 
Join Date: May 2005
Location: New Zealand
Posts: 867
The patch will be in the next version, but I am going to wrap it into a #ifndef _WIN32 block.

It's interesting though, some setups redirect the call, and some keep them separate. If I recall correctly, the 64 bit calls are only for all-in-one installers between 2GB and 4GB.

I am considering adding another setting that allows splitting the data block into two parts, one for the exehead and one for the main install files. I'm thinking of using reservefile to add exehead specific files, the main reason is so that the installer .exe can become a downloadable stub, so that it downloads quick. Then it can be run with some downloader plugin that downloads the main datablock file. I will probably add a check for existing datablock files too, so that it only has to be downloaded once. Don't know when that will happen, I am quite busy at the moment.

[edit] Also, I'm ok with which ever way nsis goes. It's quite nice having a fork because it keeps the main nsis package tight and lean, I don't actually like bloated software much. [/edit]

"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 14th October 2018, 11:20   #16
JasonFriday13
Major Dude
 
JasonFriday13's Avatar
 
Join Date: May 2005
Location: New Zealand
Posts: 867
Oh and I also wondered why my downloads of nsisbi have spiked up, the homebrew script fetches my source code .

"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 16th October 2018, 09:16   #17
Yathosho
Forum King
 
Yathosho's Avatar
 
Join Date: Jan 2002
Location: AT-DE
Posts: 3,362
Quote:
Originally Posted by JasonFriday13 View Post
Oh and I also wondered why my downloads of nsisbi have spiked up, the homebrew script fetches my source code .
Yathosho is offline   Reply With Quote
Reply
Go Back   Winamp & SHOUTcast Forums > Developer Center > NSIS Discussion

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