Making standalones for Windows on Linux

Hello -
Is it possible to create a stand-alone .exe file for Windows, from Blender 2.34 running on a Linux machine?

I’m pretty sure I read somewhere that it only makes a runtime for the platform it’s on. I’m not positive, though. It doesn’t give any options when you save the runtime so I kind of doubt it.

If you replace blenderplayer with blenderplayer.exe it will create a Windows exe (rename it .exe afterwards.)

This script will do it:


# Blender Publisher script.
# Creates a Linux or Win32 executable from a blend file.
# Create a Linux exe from Windows, or a Windows exe from Linux!
# You need:
#	blenderplayer for each platform (http://www.blender3d.org/Download/)
#	A CKey for Blender < 2.26
#	A Full python installation (for struct module - HELP! can you do this with native python?)
#	A blender game.

# 1. Save the .blend file.  Compress, Sign and Lock the file if Blender < 2.26
# 2. Set the config below.
# 3. Run this script.  You can run it from within Blender or from a python command line.

# Config: set this appropriately
# The Published Blender executable file: (to be created)
OUTPUTFILE="/path/to/Blender/ballercoaster"
# The .blend file you want to publish:
BLENDFILE="/path/to/Blender/Ballercoaster.blend"
# The blenderplayer (Other operating system version)
BLENDERPLAYER="/path/to/Blender/blenderplayer-2.24"

# Copyright (c) 2004 Kester Maddock.  All Rights Reserved.
# LICENSE: GPL

# ----------------------------------------------------------------------------------------
def ipack(int_val):
     return chr((int_val>>24)&0xff) + chr((int_val>>16)&0xff) + chr((int_val>>8)&0xff) + chr(int_val&0xff)

# Copy the run time
expgame = file(OUTPUTFILE, "w")
expexe = file(BLENDERPLAYER, "r")
while (1):
	data = expexe.read(8192)
	if (data == ""):
		break
	expgame.write(data)
expexe.close()
	
dataoffset = expgame.tell()

# copy the blend data
blend = file(BLENDFILE, "r")
while (1):
	data = blend.read(8192)
	if (data == ""):
		break
	expgame.write(data)
blend.close()

# link them together
expgame.write(ipack(dataoffset));
expgame.write("BRUNTIME");
expgame.close()

# Finished

Great stuff!
When you say (in the code) “A Full python installation (for struct module - HELP! can you do this with native python?)”

  • do you mean that the python binary also gets bundled into the stand-alone or that python needs to be on the target machine?

For that matter, what if I use Python code that is not in the built-in Python runtime?

This also works on Windows creating a Linux blender runtime? And how about a runtime for Mac OSx ? :stuck_out_tongue:

Yeah - I always forget the Mac .

So stuff to find-out:

  1. The Python mystery
  2. Mac and other platforms

Sheesh - this just gets more and more complicated.

The issues:

  1. Where can we download the latest blenderplayer for Linux and the one for Windows?

  2. What is the latest version of each player?

  3. Do they accept .blend files made in 2.34?

  4. I found a link to the Windows player (233?) and it has these files in it:

  5. blenderplayer.exe 2. gnu_gettext.dll 3. SDL.dll
    Your script only refers to number 1, what are the others? Are they not needed by number 1?
    Should one create a ‘player’ and then bundle number 2 and 3 into a zip-file along with it?

  6. I found a linux blenderplayer (not sure what version), but when I run it (as-is or after it’s been bundled by your script) it reports:error while loading shared libraries: libpython2.3.so.1.0: cannot open shared object file: No such file or directory

Any help?

A decent cvs build of blender from ztonzy has blenderplayer:

http://www.blender.org/modules.php?op=modload&name=phpBB2&file=viewtopic&t=4666

(This is quite odd as I have just posted a very similar answer about blenderplayer today…)

LOL :slight_smile: That was also a reply to a post by me. I have been on a blenderplayer mission today! Thanks for the link, am d/l now - hope it works.

:smiley: [!] :smiley: [!] :smiley: [!] :smiley:
The blenderplayer at that URL works! ! ! !

I am very chuffed - thanks for the good link.

Do you have any comments on my issues (above) about the Windows player?

Biggles, some answer’s to your questions perhaps…

    • A recent build of blender can be got from the blender.org forum:

http://www.blender.org/modules.php?op=modload&name=phpBB2&file=viewforum&f=18

BUT, I can’t guide you as to which one is the most useful/stable etc. You might want to pick up the official 2.34 Windows build and use that (it does come with blenderplayer (.exe), unlike the official linux build.)

This cross-building possibility is very interesting for me as I am creating educational software for windows, but I use linux; It makes using blender as a demo tool a whole lot more feasible.

  1. The cvs versions are the latest ones, but bear in mind that a lot of new features (and therefore bugs) are present and I can’t say which builds have which features…

  2. AFAIK yes. They are predecessors to a single increment in version (2.34->2.35) and the developers are massively unlikely to break the file format at this stage.

  3. My understanding is that the blenderplayer.exe is the skeleton that you blend file is attached to, and run by. The dll’s are libraries of functions that blenderplayer.exe needs to physically run on the windows box. As for bundling the ddl’s into a zip with the exe, my guess is to suck and see on a friends computer. Add the exe and all the dll you can find in the blender dir, and put them on a fresh computer. Start removing dll’s until you find the ones that break the exe which are therefore neccessary to include.

  4. Sounds like 2.33 version of linux… Upgrading the path variable in the prefs might fix it, but in this case, just upgrade to the newest version…

This cross-building possibility is very interesting for me as I am creating educational software for windows, but I use linux; It makes using blender as a demo tool a whole lot more feasible.
> Yeah, it interests me too. I worked in Windows on Director and Flash for almost 5 years. That way we would publish players for Mac and Windows. Linux was never even a thought in my mind.
Recently (1 year) I have changed to 100% Linux.
If I wanted to run windows version of Blender, I would have to look into a VM of some kind because I only have one computer.

Could you tell me how you create software on Linux for Windows - that’s what I am aiming at too. This is why I have sunk so much time into Blender. I was thinking I would have to code in C and use SDL or something to get cross-platform going, but it’s very complex.
Hell, I was even toying with the idea of writing something like Director for Linux based on SDL, but I am not a ‘real’ programmer and such a task would take me several years.
I am glad I stumbled across Blender - the game engine could really do ‘multimedia presentations’ and all manner of educational and informational things.

Side-thought:
I would like to know what happens when you run a Windows player and there is no proper GL driver - it would be nice for the player to pop-up a window (that is customisable) to explain to the user what is missing and what they must do.

  1. … Start removing dll’s until you find the ones that break the exe which are therefore neccessary to include.
    > I did that on the same day I made my OP. I await reports from my Windows friends…

  2. Sounds like 2.33 version of linux… Upgrading the path variable in the prefs might fix it, but in this case, just upgrade to the newest version…
    > Well I tried to locate that file on my Fedora 1 system and it did not exsist. I found one that was close and made a link to it (hoping to fool the player), but it would have none of it! This was all on that old player built by another forum member recently. The latest one in the CVS you linked me to has no problem.
    Still, wonder what would happen on a system sans Python?

Good stuff, keeps the old brain warm :slight_smile:

Making a game exe from Linux:

  1. Make your game.exe file using Alien-xmp’s python script. For the player use the blenderplayer.exe included with the latest version of 2.34

  2. Find the following files (on a windows version of Blender 2.34):
    gnu_gettext.dll (unknown use, but just include it)
    SDL.dll (suspect this is for sound and joystick)
    Python23.dll

  3. Test it.
    Try to run game.exe
    You might get a message complaining that it’s looking for Python22.dll. Simply rename Python23.dll to Python22.dll and try again.

  4. When that works, archive it and that’s what you distribute.

*I was not in front of Windows for this test, I was on the phone over 1000Km’s away! There could be other problems I have not spotted yet.

Great stuff!
When you say (in the code) “A Full python installation (for struct module - HELP! can you do this with native python?)”

  • do you mean that the python binary also gets bundled into the stand-alone or that python needs to be on the target machine?

No, that is not relevant any more. A previous version used the struct module where this version uses ipack(). Note the script doesn’t use struct…

This also works on Windows creating a Linux blender runtime? And how about a runtime for Mac OSx ?

Yes, you can make a Linux runtime from Windows, or a Linux & Windows runtime from OSX.

The OSX runtime is a little different - put your .blend in the Resources/ folder in blenderplayer.app, and rename it “game.blend” ie, you shouldn’t need any special script to do this.

Missing libpython2.3.so.1.0: The blenderplayer you linked with was built for Python 2.3, which you must have installed on the target machine. Python pretty common on Linux machines, but it may not be version 2.3.

You will have to bundle the .dlls with your runtime (it depends on how blenderplayer.exe was built)

It will accept any blend that the blenderplayer can play. It will work with 2.25 if you sign & lock the blend file first for example.

One more blenderplayer trick: the player can run exported runtimes from other platforms. eg: if you have a game.exe exported for windows, you can run it from Linux/Mac by:
./blenderplayer game.exe

[quote=“alien-xmp”]

One more blenderplayer trick: the player can run exported runtimes from other platforms. eg: if you have a game.exe exported for windows, you can run it from Linux/Mac by:
./blenderplayer game.exe

Thanks for the tips. The last one is a great one !