Compiling ZaaIL with Alchemy – Part 2

This is Part 2 of our 3 part series on compiling ZaaIL from DevIL using the Adobe Alchemy toolset (you can find Part 1 here). Since Alchemy is at best alpha software… most of what I’m going to explain are fixes issues I ran into as I was working with Alchemy.

Issue 1: ALCHEMY_HOME not being found properly

The first issue has to do with the environment variable $ALCHEMY_HOME. You can check what your $ALCHEMY_HOME environment variable is set to by going to Terminal and typing:


If you followed the steps correctly from Part 1 of this series, you should see something print out, mine says “/projects/zaalabs/alchemy-darwin-v0.5a”.

Unfortunately, one of the perl scripts ( in the ALCHEMY_HOME/achacks directory isn’t able to reference the $ALCHEMY_HOME environment variable correctly. Open up, and go to line 56. The way I fixed this, which is admittedly not the best way, is to hard-code my path into the file.

Issue 2: asc.jar is not found

Another issue in the file, found on line 57, is the path to asc.jar. ALCHEMY_HOME/asm-asc/lib does not exist, however there is an asc.jar in ALCHEMY_HOME/bin. Adjust the path accordingly and you’ll be rid of yet another compiler error. Changes

Issue 3: Syntax error: expecting identifier before leftbrace

The next issue is within the GCC perl script (ALCHEMY_HOME/achacks/gcc). Open it up with your favorite text editor (I use vim… I know, old school), and find line 274. This regular expression is actually a little too restrictive and will throw errors regarding other generated Alchemy files. The line that needs to be changed looks like this:

if($o =~ /([^\.]*)/)

and needs to be changed to look like this:

if($o =~ /([^\/\.]+)(\..*)*$/)

This solution was found in the forums for Adobe Alchemy, posted by James Quirk. The error manifested itself as:

[Compiler] Error #1084: Syntax error: expecting identifier before leftbrace., Ln 1, Col 18:
package cmodule. {

GCC Perl Regex Change

Issue 4: error: ‘operator new’ takes type ‘size_t’ (‘long unsigned int’) as first parameter

If you are on a Mac, there is a good chance that you will see this error during compilation:

error: ‘operator new’ takes type ‘size_t’ (‘long unsigned int’) as first parameter

To fix this… we need to make a change when g++ gets called, it needs to have the -DOSX flag with it. This involves modifying the makefiles after the ./configure script generates them.

To do this, you need to open up the makefile and find the line where either CPPFLAGS or CXXFLAGS is being set. If CXXFLAGS is present, you should add the command here. If it isn’t present, you should add it to CPPFLAGS. Different makefiles use different variable names, but either way you’re looking for the variable that holds the flags to be passed to g++. In most of my makefiles the line looked like this:


and I changed it to:


Issue 5: My $PATH environment variable is empty

It should also be noted that sometimes I would find things in my terminal would start acting funny after running alc-off or alc-on. I found that when I did an echo $PATH, my path would be empty. The remedy was to close the terminal and reopen it, to restore things to a sane state.

Getting started!

Now we’re ready to start really compiling something! Lets start with zlib. This will unpack into the directory zlib-1.2.4, however libpng will expect it to be in the zlib. So instead of changing where libpng looks, lets just move zlib-1.2.4 to zlib. Now change directory into zlib, and run alc-on. Then we can run the configure script

mv zlib-1.2.4 zlib
cd zlib

Output should be similar to the screen shot below.

ZLib Configuration Output

Now we’re ready to make/compile the code.

[Note] Using sudo here is important, otherwise you may get permission denied errors during some of the compilation steps.

sudo make

ZLib Make Output

This output looks fine, so zlib is ready to go. Next we install zlib. “sudo make install”. After the install completes, you can go ahead and run alc-off to return your system path to normal.

sudo make install
alc off

ZLib Make Install

[Note about compiling libpng] I ran into problems when compiling libpng with a configure script, so I downloaded the version that doesn’t use configure scripts and used it instead. Doing it this way allows you to skip the configure script, and just run a makefile directly. To do this you have to use the -f option for make and specify the path to the file. For libpng without the configuration script it has a folder named scripts that has a bunch of premade makefiles. The one we want is makefile.gcc which has been configured for a generic unix system.

Issue 6: Unable to open file: $ALCHEMY_HOME/avm2-libc/lib/

As you are compiling these other libraries you may notice an error go past that reads:

[Compiler] Error #1063: Unable to open file: /projects/zaalabs/alchemy-darwin-v0.5a/avm2-libc/lib/

This error occurs in some cases when your code tries to build/use a shared library. As far as I can tell… this file is not in the released version of Alchemy, and therefore shared libraries are broken. I haven’t found a fix for this error, and so for now I just work around it by using static libraries.

These steps should work for most of the dependencies. Remember that some of DevIL’s dependencies have dependencies of their own. Therefore the order in which you compile your libraries is important. ZLib must be compiled before LibPNG will compile, and all of DevILs dependencies must be compiled before we can compile DevIL.

Compiling DevIL

Once we’ve tackled the feat of configuring and compiling all of DevIL’s dependencies, we’re ready to compile DevIL. This time the compilation steps will be a bit different… since DevIL depends on all of these other libraries. Normally you would still follow the same procedure and things would turn out great, if you were compiling without Alchemy that is. However, Alchemy currently has some problems with shared libraries as mentioned above, so we’ll have to use static libraries.

This means when running gcc you need to append some special parameters, but we don’t want to manually compile the library, instead we want to use the makefile that is generated by the configure script. So we again need to modify the makefile.

After configuring DevIL using:


Open up the Makefile and find the line where IL_LIBSs is defined and modify it so that it reads:

IL_LIBS = -ltiff -lpng12 -llcms -ljpeg -L../jpeg-8a -L../tiff3.9.2 -L../libpng-1.2.43 -L../lcms-1.19

The -L arguments is added to tell gcc where to look for the dependencies when compiling the code.

DevIL Static Makefile Changes

Modify the makefile in the DevIL root folder, as well as the makefile in the lib directory of DevIL. After those modifications, you’re ready to compile DevIL with “sudo make” [make sure you run alc-on before you make this file as well].

At this point you should have a fully compiled DevIL with all of its necessary libraries linked in. Woot!

In the next post we’ll build our GlueGen file and compile into a usable swc. As always if you run into any problems or just want to leave a comment feel free to pipe up below.

Tags: , , ,

6 Responses to “Compiling ZaaIL with Alchemy – Part 2”