Compiling trans for Linux

Monkey Archive Forums/Monkey Tutorials/Compiling trans for Linux

DruggedBunny(Posted 2011) [#1]
Updated for version 58...

First of all, this doesn't provide a Linux target -- as it stands, it just allows you to build, via command line, on a Linux PC, for the HTML5 target.

I've provided a build of trans_linux here, though I don't know enough to say whether it'll work on your distro/setup. (Updated to V58.)

You can just copy these files to your MonkeyPro58/bin folder (replace 58 with whatever version you have) and skip straight to step 10 below to try them. Failing that, you may have to build them yourself.

Building trans for Linux (tested on Ubuntu 11.04)

Note that you will have to change references to the MonkeyPro58 folder for later releases of Monkey!

Creating the trans C++ file:

1) Open Monk on Windows or Mac;

(I used VirtualBox running on a Linux host to do the Windows stuff, though you could do it with Linux in a virtual machine running on a Windows/Mac host.)

2) Load MonkeyPro58/src/trans/trans.monkey;

Build for STDCPP target;

(You'll need MinGW or the Mac developer tools installed, and the relevant path/s added to MonkeyPro58/bin/config_[platform].txt)

3) Locate "main.cpp" in the *WINDOWS/MAC* MonkeyPro58\src\trans\\stdcpp folder and copy it to the *LINUX* MonkeyPro58/bin folder. Rename it to "trans_linux.cpp".

4) Open a command prompt (terminal) in Linux and type:

cd ~/Desktop/MonkeyPro58/bin/

(This assumes that MonkeyPro58 is on your desktop.)

5) To build the trans_linux executable, type:

g++ trans_linux.cpp -o trans_linux

(If you get an error saying g++ isn't a command, or similar, install g++ via package manager then do it again.)

6) To check the executable is working, type:


(Note: type the ./ as well!)

You should see trans's usage information.

UPDATE, 20 May 2012 - MakeMeta is no longer required; skip steps 7, 8 and 9!

Skip to step 10 with newer versions, eg, v58. MakeMeta is no longer required.

7) Navigate to the src folder:

cd ~/Desktop/MonkeyPro58/src/trans/

8) To build makemeta.bmx we need the Linux version of BlitzMax:

~/Apps/BlitzMax/bin/bmk makeapp makemeta.bmx

(You will have to change "~/Apps/BlitzMax" above to wherever you've installed BlitzMax on your system.)

9) Copy the resulting makemeta build to Monkey's bin folder, then change to that folder:

	cp makemeta ~/Desktop/MonkeyPro58/bin/makemeta_linux
	cd ~/Desktop/MonkeyPro58/bin/

10) We need to set up the HTML5 target, so open up MonkeyPro58/bin/config.linux.txt in a text editor and set this line:


(This assumes Chromium is your browser. Change "chromium_browser" to "firefox" if that's what you use; not tested.)

At this point, we're all done setting up trans for Linux!

Building apps

Now, to build (for example) the Matrix Rocks demo (in MonkeyPro58/bananas/hitoro), navigate to its folder:

cd ~/Desktop/MonkeyPro58/bananas/hitoro/matrixrocks

... and build it:

~/Desktop/MonkeyPro58/bin/trans_linux -target=html5 matrixrocks.monkey

Assuming there were no errors, you should now have a folder, containing a HTML5 folder, containing:

data  favicon.ico  main.js  MonkeyGame.html

(The 'data' entry is another folder.)

Upload these files, along with the data folder, to a web server and visit the MonkeyGame.html page to try it!

Here's one I built earlier, in Linux:

DruggedBunny(Posted 2011) [#2]
I suspect the binaries linked above may have lost their executable permissions by being zipped. If they fail to run, try entering these lines into a command prompt after navigating to the /bin folder:

chmod +x trans_linux
chmod +x makemeta_linux

Dabz(Posted 2011) [#3]
Nice one James!!!


DruggedBunny(Posted 2012) [#4]
Updated for v58!