This is ScalaZ3 for Scala 2.10 and Z3 4.3. Switch to the branch '2.9.x' for Scala 2.9 support.
You should have Java and SBT 0.13.x installed.
-
Download Z3 source code from http://z3.codeplex.com/, compile it, and copy the headers and built library to z3/[z3version]/include and z3/[z3version]/lib respectively. (eg: z3/4.3-unix-64b/include/z3.h and z3/4.3-unix-64b/lib/libz3.so).
-
Run 'sbt package' to create the jar file. It will be in 'target/scala-2.10/scalaz3_2.10-2.1.jar' and will contain the shared library dependencies.
-
For testing, run
sbt test
-
Download Z3 source code from http://z3.codeplex.com/, compile it, and copy the headers and built library to
z3/[z3version]/include
andz3/[z3version]/lib
respectively. (eg:z3/4.3-osx-64b/include/{z3,z3_api,z3_macros}.h
andz3/4.3-osx-64b/lib/libz3.dylib
). -
Run
sbt package
to create the jar file. It will be intarget/scala-2.10/scalaz3\_2.10-2.1.jar
and will contain the shared library dependencies. Make sure to compile withgcc
and notclang
(which may be aliased asgcc
). -
For testing, run
sbt test
Cygwin does not work for generating scalaZ3. Use Visual Studio instead, if the given dll does not work.
If you wish to use the given DLL for x64 architectures:
-
Download Z3 4.3 release for 64bit Windows, and copy
libz3.dll
toz3\[z3version]-win-[arch]\bin
andinclude\*.h
toz3\[z3version]-win-[arch]\include\
. (eg: z3\4.3-win-64b\bin\libz3.dll) -
If you wish, you can create
scalaz3.dll
by yourself by following these steps, else just use the current version and move to step 3).
-
Create a new Visual Studio Project:
Win32 Project
,DLL
, namedscalaz3
-
In the project menu, properties, platform, create a new one X64 from win32 settings, and set it up as default
-
Copy-paste all
*.h
and*.c
files fromScalaZ3\src\c
to the folder where you created your visual studio project, e.g.:C:\Users\...\Documents\Visual Studio 2013\Projects\scalaz3\scalaz3
-
Copy-paste all include files from the
z3\[z3version]-win-[arch]\include
directory, as well as alldll
files from thez3\[z3version]-win-[arch]\bin
folder to the project folder. -
In the Visual Studio interface, right-click the project,
add existing item...
and add all of the above. -
In project properties, configuration properties, C/C++, General, Other include directory, add both
C:\Program Files\Java\jdk1.7.0_25\include
andC:\Program Files\Java\jdk1.7.0_25\include\win32
. You should have this jdk installed already. If not, download it there. -
Open the Visual Studio Command Line Prompt for x64 bits (Start menu, All programs Visual Studio 2013, Visual Studio Tools, Native tool command line x64 for VS2013 or something similar)
-
Navigate to the visual studio project (see step 4.) and run:
dumpbin /exports libz3.dll > libz3.def
-
Change the content of libz3.def so that the start looks like (use Notepad++ for example)
EXPORTS
Z3_app_to_ast
Z3_append_log
-
Create the lib with the Visual Studio Command Line with the command:
lib /def:.\libz3.def /OUT:.\libz3.lib
and then add it to the project. -
Rename
cast.c
,extra.c
,z3_thycallbacks.c
andz3_Z3Wrapper.c
with the*.cpp
extension -
Change
(*ENV)->get....(ENV,
toENV->get...(
everywhere (ENV
is a string which is not necessarily "env") inextra.cpp
,z3_Z3Wrapper.cpp
andZ3_thycallbacks.cpp
. Fix other compilation errors if any.You can use the regexp to find
\(\*(\w)+\)->(\w+)\(\1,
and replace by
\1->\2\(
The following four instructions also help to fix errors depending on your jni.h version and visual studio version: -
Change the quotes
#include <z3.h>
to#include "z3.h"
incast.h
,extra.h
,z3_thycallbacks.h
,z3_thycallbacks.cpp
andz3_Z3Wrapper.cpp
. -
Add
#include "stdafx.h"
at the very beginning ofcast.h
,z3_thycallbacks.cpp
,extra.cpp
andcasts.cpp
-
Remove all
inline
keywords incast.cpp
andcast.h
-
Locate line 27 in
Z3_thycallbacks.cpp
and change(*env)->NewGlobalRef(env, pc);
topc;
. -
Now compiling (Project menu, generate the solution) gives the DLL in the following repository (Note that this is the "solution" folder, not the "project" one)
C:\Users\...\Documents\Visual Studio 2013\Projects\scalaz3\x64\Debug
-
Copy the
scalaZ3.dll
from step 17 toScalaZ3/lib-bin
and replace the existing dll.
*** THE STEP WHICH MADE EVERYTHING WORK: COMPLETELY CUT FROM CYGWIN *** -
Remove
C:\cygwin\bin
from the PATH environment variable so that when invoking sbt it makes sure that no cygwin is involved.
-
Run to create the jar file. It will end up in 'target/scala2.10/scalaz3_2.10-2.1.jar' and will contain the shared library dependencies.
sbt package //fails at some point because it cannot run gcc sbt packageBin // Uses the correct dll
-
Run the tests with
sbt test