Question

I tried to compile Scala^Z3 on Win XP using Cygwin and JDK 1.7.0 but it didn't work out as expected.

I did the following: - Use SBT 0.7.4 - Use current Scala^Z3 revision from github - Use Cygwin and its gcc - Use JDK 1.7.0 (javac)

"sbt update" was successfull. "sbt package" end up in several errors stating undefined references like the following:

\psuter-ScalaZ3-35cb691\src\c/z3_Z3Wrapper.c:10: undefined reference to `_Z3_mk_config'

In order to make it work at all I changed ....\PSuterScalaZ3\psuter-ScalaZ3-35cb691\project\build\scalaz3.scala line 74 to:

lazy val gcc : ManagedTask = if(isUnix || is32bit) {

On the homepage it is stated that it should work for Windows, too. Does it at all? Is there a precompiled jar available?

I saw a z3.jar here: http://lara.epfl.ch/~psuter/jniz3/z3.jar This is a Linux Version too, I guess? Because it didn't work for me either...

Scala^Z3 is a really good piece of code (if i can get it to work ;))

Was it helpful?

Solution

Sorry about that, the sbt script indeed currently only works for Linux (and as you can tell by the absolute path, we're not quite used to having external users yet).

Here are the steps I use to compile it under Windows:

  • compile all Java sources with javac (there are no dependencies)
  • generate the header files using javah
  • compile all the Scala sources with scalac (using only the Java .class files as dependencies)
  • compile the .c + .h files with Visual Studio
  • manually create a jar file with everything

We also hope to release a precompiled .jar file with the shared library for Linux and Windows once we adapted Scala^Z3 to the new changes in Z3 3.1.

EDIT The GitHub repository now contains a precompiled .jar file prepared for Scala 2.9.1 and Z3 3.2. It works under Windows and Linux (32bit). The repository also contains more detailed instructions on how to compile the shared library in Windows, using MinGW instead of Visual Studio (hence removing the need for VS runtime libraries).

OTHER TIPS

I had a similar problem some months back and here is what it I had to do in order to compile it with Visual Studio 2010. I am not sure if it is still relevant since Scala^Z3 and Z3 itself changed a lot, but I hope it nevertheless is helpful.

  1. Created a new Visual C++ Win32 project (.NET Framework 4) for creating DLLs.

  2. Added all .h and .c files in the src/c/ directory. VC somehow complained about the "inline" modifier and a work mate suggested to remove them, which I did.

  3. Added z3.h from Z3 2.19, Z3 2.16 wasn't accepted. Also added the corresponding z3.lib (x86, haven't tried x64 yet). VC wouldn't accept z3.dll and complaint about the file being corrupt. No clue why, Z3 itself works fine for me.

  4. The project compiles with 13 warnings and a dll is created which apparently MUST be named scalaz3.dll.

  5. sbt compile, adding scalaz3.dll to lib-bin, jar the whole thing together to scalaz3.jar

  6. 'scala -classpath scalaz3.jar test.scala' with scalaz3.jar and z3.dll in the current folder works

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top