Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Apr 19, 2006, 08:51 PM   #1
kainjow
Moderator emeritus
 
kainjow's Avatar
 
Join Date: Jun 2000
Create self-extracting exe

I need to be able to create a self-extracting exe from Mac OS X.

The only solution I have seen so far that works in Mac OS X is from Stuffit's SDK, but I also need the .exe to launch a file that it uncompresses after it's done uncompressing. Stuffit does not do this.

The closest I have found is this, but I think the code is based on MFC, and I don't have the time to port that, even if I was able to

There has to be some open source *nix solution that does this, but I haven't found anything. Any help would be much appreciated. Ideally, it would be cross-platform so that the exact .exe is created from OS X and Windows.

Edit: ok I just found this. Although it's a Windows program, it appears to be mostly ANSI C, and not based on Win32 too much (besides the GUI). Hm

Last edited by kainjow; Apr 19, 2006 at 09:04 PM.
kainjow is offline   0 Reply With Quote
Old Apr 19, 2006, 10:34 PM   #2
savar
macrumors 68000
 
savar's Avatar
 
Join Date: Jun 2003
Location: District of Columbia
Send a message via AIM to savar
Quote:
Originally Posted by kainjow
I need to be able to create a self-extracting exe from Mac OS X.

The only solution I have seen so far that works in Mac OS X is from Stuffit's SDK, but I also need the .exe to launch a file that it uncompresses after it's done uncompressing. Stuffit does not do this.
Hmm...Stuffit stinks anyway, I don't download anything that is Stuff'ed any more.

I have a simple solution to your problem, however. Create an installer application in XCode. Add a tar'ed gzip'ed copy of the program you want to decompress into the application bundle. Write a shell script or compiled program which executes ungzip, then tar -xf, and then forks a new process which runs your target program.

If you want to get really clever, make the name of the tar file a parameter in the info.plist, and then create another application which can take a tar file, load into a copy of this application bundle, and then updates the info.plist. That would be a useful little program, actually.
__________________
Mehce
savar is offline   0 Reply With Quote
Old Apr 19, 2006, 10:39 PM   #3
kainjow
Thread Starter
Moderator emeritus
 
kainjow's Avatar
 
Join Date: Jun 2000
Thanks for the reply. But I guess I didn't make myself clear. I need to be able to make an .exe, as in a Windows executable, from Mac OS X, dynamically. And preferrably, the code should be cross-platform so I can generate the Windows exe from Mac OS X and Windows The last link I posted above I think should do the trick. I just need to make it platform-independent.
kainjow is offline   0 Reply With Quote
Old Apr 19, 2006, 11:01 PM   #4
gekko513
macrumors 601
 
gekko513's Avatar
 
Join Date: Oct 2003
I don't think it's possible. Windows and OS X doesn't have the same format for executable binaries. Windows use the PE (portable executable) file format, but it's only portable across the Windows OSes. Linux uses ELF and OS X uses Mach-O files.

The only "executable" file format I know that work across platforms is .jar files, and that requires a correctly configured Java runtime environment installation.

Edit: Oh, wait, you don't need to execute the .exe file on OS X, you just want to create it there? Am I right?

2nd Edit: But why do you want a self extracting .exe? I know I'm very wary of .exe files on Windows, so unless I can be sure it is a program that I want I will not deal with or execute a .exe file.

Last edited by gekko513; Apr 19, 2006 at 11:07 PM.
gekko513 is offline   0 Reply With Quote
Old Apr 19, 2006, 11:09 PM   #5
kainjow
Thread Starter
Moderator emeritus
 
kainjow's Avatar
 
Join Date: Jun 2000
Yes. I only need to create the .exe from the Mac. I don't need to execute it on the Mac.
kainjow is offline   0 Reply With Quote
Old Apr 19, 2006, 11:17 PM   #6
gekko513
macrumors 601
 
gekko513's Avatar
 
Join Date: Oct 2003
MinGW claims to let you cross-compile .exe files for Windows on OS X: Link. But it doesn't look easy.
gekko513 is offline   0 Reply With Quote
Old Apr 19, 2006, 11:23 PM   #7
kainjow
Thread Starter
Moderator emeritus
 
kainjow's Avatar
 
Join Date: Jun 2000
Hehe.. I don't need to compile, just build. http://www.disoriented.com/FreeExtractor/ is what I need. I am working on porting it though, so I think it'll do what I want.
kainjow is offline   0 Reply With Quote
Old Apr 20, 2006, 02:51 AM   #8
kainjow
Thread Starter
Moderator emeritus
 
kainjow's Avatar
 
Join Date: Jun 2000
Well, I got that app ported Took several hours, but a lot shorter then I expected. It's pretty ugly with #ifdef WIN_32 everywhere, and my own Win32 compatible functions like...
Code:
BOOL ReadFile(
  HANDLE hFile,
  LPVOID lpBuffer,
  DWORD nNumberOfBytesToRead,
  LPDWORD lpNumberOfBytesRead,
  LPOVERLAPPED lpOverlapped
)
{
	int c = fread(lpBuffer, 1, nNumberOfBytesToRead, hFile);
	(*lpNumberOfBytesRead) = (DWORD)c;
	return (nNumberOfBytesToRead == c);
}

BOOL WriteFile(
  HANDLE hFile,
  LPCVOID lpBuffer,
  DWORD nNumberOfBytesToWrite,
  LPDWORD lpNumberOfBytesWritten,
  LPOVERLAPPED lpOverlapped
)
{
	size_t c = fwrite(lpBuffer, nNumberOfBytesToWrite, 1, hFile);
	(*lpNumberOfBytesWritten) = (DWORD)c;
	return ((DWORD)c == nNumberOfBytesToWrite);
}
But... it works! I will post my code later on once I get some free time to clean it up.

The app is run from the command line like this:
Code:
./MakeSFX /zip="file.zip" /sfx="setup.exe"
Then it uses an already existing Win32 installer, and adds the zip file to the .exe file. When you run the .exe, it extracts the zip from the exe into a specified folder.

Last edited by kainjow; Apr 20, 2006 at 03:00 AM.
kainjow is offline   0 Reply With Quote
Old Apr 20, 2006, 09:38 AM   #9
gekko513
macrumors 601
 
gekko513's Avatar
 
Join Date: Oct 2003
Nice work, kainjow. Maybe you should get involved with the darwine project?
gekko513 is offline   0 Reply With Quote
Old Jul 19, 2006, 09:08 PM   #10
drcube26
macrumors newbie
 
Join Date: Jul 2006
Mac exe

Hi,


I am trying to create exe on OS X platform as well. Would it be possible for you to post updated code ( it doesn't have to be clean

Thanks in advance,
drcube26 is offline   0 Reply With Quote
Old Jul 20, 2006, 01:40 AM   #11
kainjow
Thread Starter
Moderator emeritus
 
kainjow's Avatar
 
Join Date: Jun 2000
Sure, here it is (couldn't attach it because it was too big):
http://www.kainjow.com/code/FreeExtractor.zip

FYI to compile for a universal binary, use
Code:
gcc MakeSFX.c -o MakeSFX -arch i386 -arch ppc -isysroot /Developer/SDKs/MacOSX10.4u.sdk
icon.h and stub.h were compiled on my PC with Visual Studio, I think version 2003. However, I think it's using a custom icon, because the icon option in MakeSFX doens't really work that well (you have to have the icon be an exact size in bytes). So you may have to re-compile that on a PC if you want the original or another icon.
kainjow is offline   0 Reply With Quote
Old Jul 20, 2006, 04:49 PM   #12
drcube26
macrumors newbie
 
Join Date: Jul 2006
it works!

Thank you very much!!!!!
drcube26 is offline   0 Reply With Quote
Old Apr 26, 2010, 07:53 PM   #13
vicsf
macrumors newbie
 
Join Date: Apr 2010
Create self-extracting exe

Hi kainjow,
I'm a newbie on this forum and your post "Create self-extracting exe" is the main reason I'm here! I inherited some code which uses MakeSFX executable to create it on a mac via command line and run it on a PC. Everything works fine except for one issue - there is a "back" button the very first window which causes application to crash if user clicks twice on it... Is it possible to hide/grey out this "back" button? Any advice will be greatly appreciated!
vicsf is offline   0 Reply With Quote
Old Apr 26, 2010, 11:34 PM   #14
kainjow
Thread Starter
Moderator emeritus
 
kainjow's Avatar
 
Join Date: Jun 2000
I no longer work on or maintain that code, but I would suggest trying to run the installer (if you have the source code) in a debugger on Windows and find out why it's crashing.
kainjow is offline   0 Reply With Quote
Old Apr 27, 2010, 01:51 PM   #15
vicsf
macrumors newbie
 
Join Date: Apr 2010
I can't access "http://www.disoriented.com/FreeExtractor/"...
vicsf is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
OS Mavericks .EXE Help crabinow16 Windows, Linux & Others on the Mac 3 Dec 8, 2013 09:06 AM
Viruses and exe's marty1990 OS X 4 Nov 30, 2013 03:52 PM
Extracting Whatsapp Conversations tonyr190 iPhone 5 Jul 30, 2013 07:08 AM
help with .EXE file martymar112 Mac Applications and Mac App Store 11 Jun 6, 2013 07:21 PM
Extracting Information WCROC iPhone 2 Mar 21, 2013 09:03 AM

Forum Jump

All times are GMT -5. The time now is 03:35 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC