diff --git a/lib64-bin/libz3.so b/lib64-bin/libz3.so
new file mode 100755
index 0000000000000000000000000000000000000000..52b0f0abc22e3a383c9c724923357a23c49f24e1
Binary files /dev/null and b/lib64-bin/libz3.so differ
diff --git a/project/Build.scala b/project/Build.scala
index 9621bd41349c27ee8e3e64868f4f2da0a0107f29..796a12b2d3864605147a72d32c91b44246d9763b 100644
--- a/project/Build.scala
+++ b/project/Build.scala
@@ -5,13 +5,22 @@ import Keys._
 object Leon extends Build {
   private val scriptName = "leon"
   def scriptFile = file(".") / scriptName
-  def ldLibraryDir = file(".") / "lib-bin"
+  def is64 = System.getProperty("sun.arch.data.model") == "64"
+  def ldLibraryDir = file(".") / (if (is64) "lib64-bin" else "lib-bin")
 
   val scriptTask = TaskKey[Unit]("script", "Generate the " + scriptName + " Bash script") <<= (streams, dependencyClasspath in Compile, classDirectory in Compile) map { (s, deps, out) =>
     if(!scriptFile.exists) {
-      s.log.info("Generating script...")
+      s.log.info("Generating script ("+(if(is64) "64b" else "32b")+")...")
       try {
-        val depsPaths = deps.map(_.data.absolutePath)
+        val depsPaths = deps.map(_.data.absolutePath).filter(p =>
+          if (p.endsWith("unmanaged/z3.jar")) {
+            !is64
+          } else if (p.endsWith("unmanaged/z3-64.jar")) {
+            is64
+          } else {
+            true
+          }
+        )
         // One ugly hack... Likely to fail for Windows, but it's a Bash script anyway.
         val scalaHomeDir = depsPaths.find(_.endsWith("lib/scala-library.jar")) match {
           case None => throw new Exception("Couldn't guess SCALA_HOME.")
diff --git a/unmanaged/z3-64.jar b/unmanaged/z3-64.jar
new file mode 100644
index 0000000000000000000000000000000000000000..a69f124bbc14d1ee6f3fe92e6906b5743569a057
Binary files /dev/null and b/unmanaged/z3-64.jar differ