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…
|
1 |
cd /alchemy/ |
and execute config file
|
1 |
./config |
You should see something like this:
|
1 2 3 4 5 6 7 8 9 |
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:
|
1 2 |
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:
|
1 |
#export ADL=/path/to/your/adl (or adl.exe) |
and assuming your Flex folder is called flex, change with:
|
1 |
export ADL=/flex/bin/adl |
Return to Terminal and enter the following commands, assuming you are using flex and alchemy folder names:
|
1 |
export FLEX_HOME=/flex/bin |
|
1 |
export ALCHEMY_HOME=/alchemy |
|
1 |
source /alchemy/alchemy-setup |
|
1 |
PATH=$ALCHEMY_HOME/achacks:/flex/bin:$PATH |
|
1 |
export PATH |
Finally turn on alchemy:
|
1 |
alc-on |
Enter in a folder with an example source code:
|
1 |
cd /alchemy/samples/stringecho/ |
and compile the C source code into an SWC:
|
1 |
gcc stringecho.c -O3 -Wall -swc -o stringecho_triqui.swc |
You should see something like this:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
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.
They can be easily customized to meet the unique requirements of your project.





(5 votes, average: 4.80 out of 5)






This post has 5 comments
Marquezi Medeiros
Very good, i’ll try to use this program to make the inverse, SWF into C code to edit that!
Pradeek
I’ve written a couple of getting started posts on Alchemy some time ago. You can find them here : http://pradeek.blogspot.com/search/label/alchemy
sban
look nice, thanks a lot for your share
Jay
Cannot compile, I have FlexSDK 3.5.0
And what do we do with the sec file?
In file included from stringecho.c:5:
/alchemy/avm2-libc/include/stdlib.h:90: warning: conflicting types for built-in function ‘calloc’
/alchemy/avm2-libc/include/stdlib.h:97: warning: conflicting types for built-in function ‘malloc’
In file included from stringecho.c:6:
/alchemy/avm2-libc/include/stdio.h:230: warning: conflicting types for built-in function ‘fwrite’
/alchemy/avm2-libc/include/stdio.h:258: warning: conflicting types for built-in function ‘snprintf’
/alchemy/avm2-libc/include/stdio.h:263: warning: conflicting types for built-in function ‘vsnprintf’
spyder
Thank You!