Love, UPX, and you!

General discussion about LÖVE, Lua, game development, puns, and unicorns.
User avatar
Simtex
Prole
Posts: 39
Joined: Sun Dec 14, 2008 5:31 am

Love, UPX, and you!

Post by Simtex »

Many of you are probably familiar with UPX (http://upx.sourceforge.net/), or "The Ultimate Packer For Executables".

For those of you who aren't, and are thinking of distributing something you created with Love, I suggest you check it out. Here's a quick rundown of what it can do:

Basically UPX takes executable files (and certain other file types such as .dll) and compresses them into a smaller size. But instead of needing a separate program to decompress those files before executing them, the files decompress themselves seamlessly when the user runs them. This doesn't affect the performance of the program you are running at all. It does add a very small amount of time to initial startup of the program, but on modern computers it's basically a few microseconds, completely unnoticeable for most programs.

Though Love is pretty small file size wise, if you want to make it the most compact you can, UPX is a great way to achieve that. Here is what happens to the most basic installation of Love when UPX compressed:

Before UPX is run
pre-upx.png
pre-upx.png (2 KiB) Viewed 2867 times
After UPX is run
post-upx.png
post-upx.png (1.93 KiB) Viewed 2867 times
Almost 2.7MB in space savings, for pretty much no cost. If you've combined your own program with the Love executable, just run UPX on the exe after you've combined them.

UPX is a commandline program so use it on a Windows command prompt like this:

Code: Select all

upx love.exe
upx *.dll
For better results (takes longer to compress though) try:

Code: Select all

upx --best love.exe
upx --best *.dll
And for best results (takes much longer to compress, like 5-10 minutes for love.exe and its dll's) try:

Code: Select all

upx --best --brute love.exe
upx --best --brute *.dll
Now a quick note on the UPX license. UPX itself is GNU GPL 2.0, when it compresses something, it leaves a piece of itself (called a "stub") attached to your program so it can decompress at runtime. Normally this would force your program to be GPL 2.0 as well (since it would link to UPX). But the authors of UPX created a special exception. As long as you don't modify the "stub" that is attached to your program after compression, your program may be under any license you choose (including commercial ones). Read the license at the UPX website for specific details (http://upx.sourceforge.net/upx-license.html).

Save bandwidth, save hard drive space, spread the Love.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Love, UPX, and you!

Post by Robin »

UPX! Why did I forget about that?

Note that UPX works with pretty much any executable format known to Man (and usually Woman, but this is the LÖVE CLUB), thus we can use this for Linux and Mac too.

Unless I'm very much mistaken. But I don't think so.
Help us help you: attach a .love.
User avatar
Jasoco
Inner party member
Posts: 3725
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Love, UPX, and you!

Post by Jasoco »

How would it work for OS X and Linux? Those don't use EXE's. OS X uses APP and Linux uses.. uh... DEB? Or something. I dunno.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Love, UPX, and you!

Post by bartbes »

I checked, and linux ELF binaries are supported, don't know how OSX support is though.
User avatar
Jasoco
Inner party member
Posts: 3725
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Love, UPX, and you!

Post by Jasoco »

bartbes wrote:I checked, and linux ELF binaries are supported, don't know how OSX support is though.
Is this just for making the project smaller? Or what is its purpose? To create a bundled game application that includes the game and the Löve engine in one? Because on OS X that's dead simple. If it's for compressing then... I don't think it'd needed really since OS X's love.app includes all the libraries inside itself as opposed to Windows that has the EXE separate from the DLL's. I dunno.
User avatar
TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Denver, CO
Contact:

Re: Love, UPX, and you!

Post by TechnoCat »

Jasoco wrote:How would it work for OS X and Linux? Those don't use EXE's. OS X uses APP and Linux uses.. uh... DEB? Or something. I dunno.
OSX executables are probably bin files too. app's are just renamed folders with the executables in them.
User avatar
Jasoco
Inner party member
Posts: 3725
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Love, UPX, and you!

Post by Jasoco »

Screen shot 2010-07-31 at 7.54.16 PM.PNG
Screen shot 2010-07-31 at 7.54.16 PM.PNG (102.7 KiB) Viewed 2853 times
Frameworks are the OS X equivalent to DLL's.
MacOS contains the love binary.
Resources has the two icons used by Löve.
Info.plist holds information like what icon to use, what file types to associate, other stuff.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Love, UPX, and you!

Post by Robin »

To clarify: UPX only compresses things.
Help us help you: attach a .love.
User avatar
Chief
Party member
Posts: 101
Joined: Fri Mar 12, 2010 7:57 am
Location: Norway, 67° north

Re: Love, UPX, and you!

Post by Chief »

Simtex wrote: After UPX is run
Image
Om nom nom!

Downloading as we speak
User avatar
Jasoco
Inner party member
Posts: 3725
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Love, UPX, and you!

Post by Jasoco »

Would UPX work on the OS X versions of the DLL's? i.e. the Frameworks that are mostly ASCII text code? If someone created a single-click OS X launcher that would decompress all of it, run it from a temp folder then clean up, I'd bite!

On OS X, Löve 0.6.2 in all is 19.4MB. Compressed via normal ZIP it gets down to 6MB. That would be the smallest ZIP will go. Using 7zX and the Ultra compression method it gets down to 3.9MB. But not everyone has 7zX and it's unfair to require it to play when all computers and OS' have ZIP built-in these days.

BTW, Removing the PPC binary from the OS X executable gives me a 9.5MB app that compresses to 2.4MB.

Anything to get it smaller and save bandwidth. 19.4MB minimum just to distribute a game is a lot when it adds up. Even if you require the user to download Löve separately.
Post Reply

Who is online

Users browsing this forum: No registered users and 54 guests