Category Archives: Alchemy

Tonight’s LFPUG meets for a presentation on Adobe’s Alchemy project, followed by another hour on the Flash Pixel Bender plug-in.

In December I played around with Alchemy, going through the basic set up and few of the examples. But found it tough to go much further beyond there.

My C and C++ isn’t great, I think there were a few bugs and glitches in the software and I couldn’t get through them. More tutorials would have been good, I guess there could be more around now, I’ve been meaning to get back into it again.

The presentation tonight is from Thomas Vian, a Flash developer rather than a C developer – so I’m looking forward to the session.

So far there are 75 people registered to attend – not a bad number, hopefully he’ll cover more than just he basic tutorials and getting started setup that Adobe offer on their Labs page.

There’s also a ‘double feature’ on Adobe TV with Ryan Stewart talking to Scott Peterson about the project, there’s a demo after the interview. Good catch-up viewing:

And not to dismiss the Pixel Bender presentation, looking forward to that too!

I’ve recently started playing with Adobe Alchemy, a beta project for compiling C/C++ libraries into Actionscript.

I was having problems compiling the sample app – the GCC couldn’t find the Actionscript libraries and I was seeing a duplication in the path:

cc1 error: /usr/lib/alchemy/usr/lib/alchemy/avm2-libc/avm2/AVM2Env.h

I posted it up on the Alchemy forums and it would seem I wasn’t the only one experiencing this problem.

Turns out it’s an unnecessary Perl hack, in the script in the /alchemy/achacks/ directory.

Commenting out the following lines of the pfix function:

$p =~ s/(^|^-[-\w]+=?)(\/usr\/include\/)/$1${home}\/avm2-libc\/include\//;
$p =~ s/(^|^-[-\w]+=?)(\/usr\/)/$1${home}$2/;

and it stops the incorrect ‘fix’ of the file path.

Try again, and the SWC compiles. Who says forums don’t work? There’s a lot of excitement about this project, glad to see them so active.

Adobe recently beta released a new project codenamed Alchemy.

Alchemy is basically a research project that allows you to compile C and C++ code to run on the Actionscript Virtual Machine (AVM2), essentially, enabling you to utilise compiled C and C++ libraries, ‘as Actionscript’, in all your web applications:

Alchemy is primarily intended to be used with C/C++ libraries that have few operating system dependencies. Ideally suited for computation-intensive use cases, such as audio/video transcoding, data manipulation, XML parsing, cryptographic functions or physics simulation.

It used to be called FlaCC, and was previewed at Adobe MAX last year. Although it’s not intended to produce complete applications, it can run up to ten times faster than Actionscript – although still slower than native C/C++ code.

The Alchemy site at Adobe Labs offers a promising ‘Getting Started’ guide with tutorials for Windows, Macintosh and Linux now that each platform – Flash Player 10, Adobe Air, the Flex SDK and the Alchemy toolkit – are all cross-platform and open source.

I decided to give it a go, working with my preferred development environment running on Ubuntu 8. However, in following the seemingly quite simple steps to compile my first library, I ran across a number holes in the guide and problems in the toolkit.

Alongside my efforts, Tim Crook tried the same on Machintosh.

Unable to get any success from Adobe’s instructions, we took following steps to get Alchemy up and (almost) running:

Set up your environment – make sure you have up-to-date versions of Java, Perl and GCC. Then download the latest Flex SDK and add the bin directory to your system path. If you’ve not done this before, you’ve basically two methods. Firstly get the path to the SDK, mine is at:


Then, to add the bin directory for the current session, execute:

export PATH=$PATH:/usr/lib/flex_sdk_3/bin

Obviously change the path accordingly if yours isn’t in the same place. But you’ll have to do this with every new session you create, because the append is only temporary.

Instead, to add the path automatically you’ll need to modify your login script or bash profile – depending on your system. On Ubuntu 8, I add the above line to the end of of my bash startup file, which I find at:


There are different ways to add directories for various user types – whether for single or multiple users, for the root user etc – there’s a troubleshoot here. You can check whether either method was successful by calling:

echo $PATH

You should see the path appended – there’ll most likely be other directories listed too. Test the path and SDK by running:

adt -version

You should see output similar to:

adt version “″

Which is just your Air Developer Tool version number. You’ll need to restart the session if you’ve modified your bash script rather than modifying the path temporarily.

Then download and extract the Alchemy toolkit, again, mine is at:


Run the configuration file by navigating to the folder using the cd command and execute:


As you’ll be prompted, there’s a set-up that needs to be run every time you login. To achieve this automatically, open up the bash profile again and before the path modification add:

source /usr/lib/alchemy/alchemy-setup

If you’ve followed the ‘Getting Started’ guide – it’s all the same up until now, but here’s where we begin to differ. Restart your terminal session. As far as we found, you’ve no need to modify your path any further. To check whether the set-up did run successfully, turn Alchemy on and check which GCC you are using:

which gcc

You should see something along the lines of:


The Adobe instructions say you’re now ready to compile one of the sample libraries. Navigate to:

cd /usr/lib/alchemy/samples/stringecho

Then run:

gcc stringecho.c -03 -Wall -swc -o stringecho.swc

And you should see some ouput. But I didn’t, neither did Tim – ours both die silently. :(

After a lot of head scratching a Googling we found a forum complaint that there are some bad symlinks in the current release of the toolkit – and we found them too. There’s two symlinks in /alchemy/bin:

llvm-g++ -> /usr/lib/alchemy/bin/llvm-gcc4-ubuntu-install/bin/llvm-g++
llvm-gcc -> /usr/lib/alchemy/bin/llvm-gcc4-ubuntu-install/bin/llvm-gcc

These go nowhere, so created new links to the correct compilers as follows:

ln -s /usr/lib/alchemy/bin/llvm-gcc4-ubuntu-install/bin/g++ llvm-g++
ln -s /usr/lib/alchemy/bin/llvm-gcc4-ubuntu-install/bin/gcc llvm-gcc

Then try again.

For Tim, success – for me, not so much.

There’s obviously something in the Linux toolkit that’s not in the Macintosh version. Amongst the output I do get though, is the following line:

cc1 error: /usr/lib/alchemy/usr/lib/alchemy/avm2-libc/avm2/AVM2Env.h

So it’s another path issue somewhere that’s causing the duplication – I’m just yet to locate it, or find a way to resolve it. I’m working on it.

This whole project could be incredible, Adobe are strongly encouraging developers to share ported libraries and support the open source ethos.

If anybody has run into the same problems as I, or even fixed them – get in touch!

Update (03.12.08): I’ve since found the fix.

In the lonely cool before dawn, you hear their engines roaring on.