Create W32 7-Zip sfx in Linux

2 Comments

7-Zip tool

7-Zip allows you to create a self extracted binary archives with the -sfx switch. But in the Linux version of 7-Zip the SFX created is a Linux binary.

So if you run the following command in a Linux box and try to run test.exe in Windows you’ll get a “Program too big to fit into memory” error.

7z a -sfx test.exe test.txt

That’s because the binary is a GNU/Linux binary.

$ file test.exe
test.exe: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, stripped

The -sfx switch in Linux will try to use 7zCon.sfx module by default and will create a Linux binary console file.

If you want to create a W32 self extracted binary in Linux you have to pick the 7z.sfx module from the windows 7-Zip version and put it in the 7z directory.

In Ubuntu you can copy 7z.sfx in the following directory:

/usr/lib/p7zip/

After done this you can use the -sfx7.sfx switch to create a W32 binary SFX file.

e.g.

7z a -sfx7.sfx test.exe test.txt

and you get that

$ file test.exe
 test.exe: PE32 executable for MS Windows (GUI) Intel 80386 32-bit
Article Global Facebook Twitter Myspace Friendfeed Technorati del.icio.us Digg Google StumbleUpon Eli Pets