Clearsilver on OSX

It's been a while since I've posted, but I've got a lot to talk about. First up is Clearsilver on OSX.

For those of you who don't know, Clearsilver is a lightweight templating engine written in C. It has bindings for a wide array of languages, including Java. Java bindings, of course, mean ColdFusion can use it as well. It's very low-level, which is both good and bad, but it's crazy fast and quite easy to work with. However, I had been unable to get it to compile on OSX until recently. Fortunately, the fix is simple once I figured it out.

Download the source tarball and unpack. Open up `rules.mk.in` in the root directory and around line 91 or so, replace "-shared" with "-dynamiclib" in the LDSHARED and CPPLDSHARED lines. Now run `./configure` with the appropriate options. Now open up `java-jni/Makefile` and around line 10, change "libclearsilver-jni.so" to "libclearsilver-jni.jnilib" in the NEO_UTIL_SO line. Do your normal make process and you should be greeted with working Java bindings. Just drop clearsilver.jar and libclearsilver-jni.jnilib in your classpath, subject to the standard JNI caveats about multiple loads per JVM instance.

I'm a total noob with C tooling, so I'm sure there's a better way to approach this (probably with some magical setting in the autoconf scripts). However, I don't know what it is, and making two little text changes wasn't enough of a burden to make me dig deeper. If anyone has a better solution, however, I'd be interested to hear about it.

On a related note, some of the code I contributed has made it into the official distributions.  While I'm sure they're not using the Java bindings (which is all I contributed to), it's still pretty cool to be able to say a package I helped develop powers Google Groups, WUnderground, and Trac, among others.

Comments are closed.