Getting started with Adobe Alchemy – Mac version

Do you know what is Adobe Alchemy?

Alchemy allows programmers to compile C and C++ scripts into SWC files to make them run on Adobe Flash Player 10 or Adobe AIR 1.5. In other words, you can compile the hundreds of millions of lines of existing open source C and C++ project to use them in Flash.

Some examples of existing C libraries compiled with Alchemy are Doom Triple Pack and World Construction Kit. And it’s free!!

The other side of the coin is still in beta (Adobe calls it “prerelease software”), not supported by Adobe, and not that user friendly.

That’s why I am writing this guide to have Alchemy running on your Mac. I’m starting with a Mac because if you find this guide difficult, be prepared… Windows installation is even worse. Anyway, let’s start:

Download everything you need

Before you start playing with Alchemy, there are some free softwares to download.

Xcode. It’s the developer tool for for Mac OSX and you will need to register to download it. Simply install it following the instruction it will give you.

Alchemy Toolkit for Mac OSX, that’s Alchemy itself. Unzip the entire folder in the root directory of your hard drive. Usually it’s called Macintosh HD.

Adobe Flex SDK, used to produce the final SWC. I wouldn’t use Nightly Builds. Unzip this package in the root directory of your hard drive, just like you made with Alchemy.

Also try to call the folders in a way easy to remember, such as flex and alchemy. This is how should it be your download window:

And this is what you should see in your finder:

Using Terminal

I told you it wasn’t user friendly… so we have to open Terminal and enter some text commands.

“Open” alchemy folder…

cd /alchemy/

and execute config file

./config

You should see something like this:

Generating alchemy-setup...
Turning execution bit on for Alchemy binaries...

Add "source /alchemy/alchemy-setup" to your login script.
"alc-home" takes you to the Alchemy install folder.
"alc-on" puts Alchemy gcc toolchain replacements at the front of your path.
"alc-off" restores original path.
"alc-util" shows you various Alchemy-related environment vars
You need Flash 10 or AIR 1.5 and the Flex 3.2 SDK installed for testing.

Don’t worry if you get a warning like this:

WARNING: "adl" not available
To correct this warning, install the Flex SDK 3.2+ and add /path/to/FlexSDK/bin to your path.

as it will be corrected later.

Now edit adl file in your flex/bin folder. Find this line:

#export ADL=/path/to/your/adl (or adl.exe)

and assuming your Flex folder is called flex, change with:

export ADL=/flex/bin/adl

Return to Terminal and enter the following commands, assuming you are using flex and alchemy folder names:

export FLEX_HOME=/flex/bin
export ALCHEMY_HOME=/alchemy
source /alchemy/alchemy-setup 
PATH=$ALCHEMY_HOME/achacks:/flex/bin:$PATH
export PATH

Finally turn on alchemy:

alc-on

Enter in a folder with an example source code:

cd /alchemy/samples/stringecho/

and compile the C source code into an SWC:

gcc stringecho.c -O3 -Wall -swc -o stringecho_triqui.swc

You should see something like this:

WARNING: While resolving call to function 'main' arguments were dropped!

1756.achacks.swf, 260699 bytes written
frame rate: 60
frame count: 1
69 : 4
72 : 260622
76 : 40
1 : 0
0 : 0
frame rate: 24
frame count: 1
69 : 4
77 : 506
64 : 31
63 : 16
65 : 4
9 : 3
41 : 26
82 : 471
1 : 0
0 : 0
adding: catalog.xml (deflated 75%)
adding: library.swf (deflated 70%)

And you should see a file called stringecho_triqui.swc in your stringecho folder, like in this picture:

Congratulations! You just compiled your first C code into a SWC with Alchemy.

Next time, I’ll show you what to do with it.

Get the most popular Phaser 3 book

Through 202 pages, 32 source code examples and an Android Studio project you will learn how to build cross platform HTML5 games and create a complete game along the way.

Get the book

215 GAME PROTOTYPES EXPLAINED WITH SOURCE CODE
// 1+2=3
// 100 rounds
// 10000000
// 2 Cars
// 2048
// A Blocky Christmas
// A Jumping Block
// A Life of Logic
// Angry Birds
// Angry Birds Space
// Artillery
// Astro-PANIC!
// Avoider
// Back to Square One
// Ball Game
// Ball vs Ball
// Ball: Revamped
// Balloon Invasion
// BallPusher
// Ballz
// Bar Balance
// Bejeweled
// Biggification
// Block it
// Blockage
// Bloons
// Boids
// Bombuzal
// Boom Dots
// Bouncing Ball
// Bouncing Ball 2
// Bouncy Light
// BoxHead
// Breakout
// Bricks
// Bubble Chaos
// Bubbles 2
// Card Game
// Castle Ramble
// Chronotron
// Circle Chain
// Circle Path
// Circle Race
// Circular endless runner
// Cirplosion
// CLOCKS - The Game
// Color Hit
// Color Jump
// ColorFill
// Columns
// Concentration
// Crossy Road
// Crush the Castle
// Cube Jump
// CubesOut
// Dash N Blast
// Dashy Panda
// Deflection
// Diamond Digger Saga
// Don't touch the spikes
// Dots
// Down The Mountain
// Drag and Match
// Draw Game
// Drop Wizard
// DROP'd
// Dudeski
// Dungeon Raid
// Educational Game
// Elasticity
// Endless Runner
// Erase Box
// Eskiv
// Farm Heroes Saga
// Filler
// Flappy Bird
// Fling
// Flipping Legend
// Floaty Light
// Fuse Ballz
// GearTaker
// Gem Sweeper
// Globe
// Goat Rider
// Gold Miner
// Grindstone
// GuessNext
// Helicopter
// Hero Emblems
// Hero Slide
// Hexagonal Tiles
// HookPod
// Hop Hop Hop Underwater
// Horizontal Endless Runner
// Hundreds
// Hungry Hero
// Hurry it's Christmas
// InkTd
// Iromeku
// Jet Set Willy
// Jigsaw Game
// Knife Hit
// Knightfall
// Legends of Runeterra
// Lep's World
// Line Rider
// Lumines
// Magick
// MagOrMin
// Mass Attack
// Math Game
// Maze
// Meeblings
// Memdot
// Metro Siberia Underground
// Mike Dangers
// Mikey Hooks
// Nano War
// Nodes
// o:anquan
// One Button Game
// One Tap RPG
// Ononmin
// Pacco
// Perfect Square!
// Perfectionism
// Phyballs
// Pixel Purge
// PixelField
// Planet Revenge
// Plants Vs Zombies
// Platform
// Platform game
// Plus+Plus
// Pocket Snap
// Poker
// Pool
// Pop the Lock
// Pop to Save
// Poux
// Pudi
// Pumpkin Story
// Puppet Bird
// Pyramids of Ra
// qomp
// Quick Switch
// Racing
// Radical
// Rebuild Chile
// Renju
// Rise Above
// Risky Road
// Roguelike
// Roly Poly
// Run Around
// Rush Hour
// SameGame
// SamePhysics
// Save the Totem
// Security
// Serious Scramblers
// Shrink it
// Sling
// Slingy
// Snowflakes
// Sokoban
// Space Checkers
// Space is Key
// Spellfall
// Spinny Gun
// Splitter
// Spring Ninja
// Sproing
// Stabilize!
// Stack
// Stairs
// Stick Hero
// String Avoider
// Stringy
// Sudoku
// Super Mario Bros
// Surfingers
// Survival Horror
// Talesworth Adventure
// Tetris
// The Impossible Line
// The Moops - Combos of Joy
// The Next Arrow
// Threes
// Tic Tac Toe
// Timberman
// Tiny Wings
// Tipsy Tower
// Toony
// Totem Destroyer
// Tower Defense
// Trick Shot
// Tunnelball
// Turn
// Turnellio
// TwinSpin
// vvvvvv
// Warp Shift
// Way of an Idea
// Whack a Creep
// Wheel of Fortune
// Where's my Water
// Wish Upon a Star
// Word Game
// Wordle
// Worms
// Yanga
// Yeah Bunny
// Zhed
// zNumbers