From 9341ce9f60352afc543175c8de919b62d0011549 Mon Sep 17 00:00:00 2001 From: baierd Date: Fri, 22 Jan 2021 19:36:40 +0100 Subject: [PATCH 01/13] Extend Yices2 library loading to load Windows by switching to a Method --- .../solvers/yices2/Yices2SolverContext.java | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/src/org/sosy_lab/java_smt/solvers/yices2/Yices2SolverContext.java b/src/org/sosy_lab/java_smt/solvers/yices2/Yices2SolverContext.java index 42a69b1b00..051fa154de 100644 --- a/src/org/sosy_lab/java_smt/solvers/yices2/Yices2SolverContext.java +++ b/src/org/sosy_lab/java_smt/solvers/yices2/Yices2SolverContext.java @@ -14,6 +14,9 @@ import static org.sosy_lab.java_smt.solvers.yices2.Yices2NativeApi.yices_get_version; import static org.sosy_lab.java_smt.solvers.yices2.Yices2NativeApi.yices_init; +import com.google.common.annotations.VisibleForTesting; +import com.google.common.collect.ImmutableList; +import java.util.List; import java.util.Set; import org.sosy_lab.common.NativeLibraries; import org.sosy_lab.common.ShutdownNotifier; @@ -49,7 +52,7 @@ public Yices2SolverContext( public static Yices2SolverContext create( NonLinearArithmetic pNonLinearArithmetic, ShutdownNotifier pShutdownManager) { - NativeLibraries.loadLibrary("yices2j"); + loadLibrary(); synchronized (Yices2SolverContext.class) { if (numLoadedInstances == 0) { @@ -75,6 +78,37 @@ public static Yices2SolverContext create( return new Yices2SolverContext(manager, creator, booleanTheory, pShutdownManager); } + @VisibleForTesting + static void loadLibrary() { + loadLibrary(ImmutableList.of("yices2j"), ImmutableList.of("yices", "yices2j")); + } + + /** + * This method loads the given library, depending on the operating system. + * + *

+ * Each list is applied in the given ordering. + */ + private static void loadLibrary(List linuxLibrary, List windowsLibrary) { + // we try Linux first, and then Windows. + // TODO we could simply switch over the OS-name. + // TODO move this method upwards? more solvers could use it. + try { + for (String libraryName : linuxLibrary) { + NativeLibraries.loadLibrary(libraryName); + } + } catch (UnsatisfiedLinkError e1) { + try { + for (String libraryName : windowsLibrary) { + NativeLibraries.loadLibrary(libraryName); + } + } catch (UnsatisfiedLinkError e2) { + e1.addSuppressed(e2); + throw e1; + } + } + } + @Override public String getVersion() { return String.format( From 5dc0a2a924f9c216f0324b470b3cb0de503d6a38 Mon Sep 17 00:00:00 2001 From: baierd Date: Fri, 22 Jan 2021 19:53:39 +0100 Subject: [PATCH 02/13] Update how Yices2ApiTest loads libs --- .../sosy_lab/java_smt/solvers/yices2/Yices2NativeApiTest.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/org/sosy_lab/java_smt/solvers/yices2/Yices2NativeApiTest.java b/src/org/sosy_lab/java_smt/solvers/yices2/Yices2NativeApiTest.java index a0d8a68bad..4f1d929663 100644 --- a/src/org/sosy_lab/java_smt/solvers/yices2/Yices2NativeApiTest.java +++ b/src/org/sosy_lab/java_smt/solvers/yices2/Yices2NativeApiTest.java @@ -106,7 +106,6 @@ import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; -import org.sosy_lab.common.NativeLibraries; import org.sosy_lab.common.rationals.Rational; import org.sosy_lab.java_smt.api.Model; @@ -118,7 +117,7 @@ public class Yices2NativeApiTest { @BeforeClass public static void loadYices() { try { - NativeLibraries.loadLibrary("yices2j"); + Yices2SolverContext.loadLibrary(); } catch (UnsatisfiedLinkError e) { throw new AssumptionViolatedException("Yices2 is not available", e); } From f93295d9c9b57309a3e2c66d02a009c024ca8395 Mon Sep 17 00:00:00 2001 From: baierd Date: Fri, 22 Jan 2021 21:45:24 +0100 Subject: [PATCH 03/13] Change lib name of Yices2 for loading in Windows --- .../sosy_lab/java_smt/solvers/yices2/Yices2SolverContext.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/org/sosy_lab/java_smt/solvers/yices2/Yices2SolverContext.java b/src/org/sosy_lab/java_smt/solvers/yices2/Yices2SolverContext.java index 051fa154de..8eff79b4fd 100644 --- a/src/org/sosy_lab/java_smt/solvers/yices2/Yices2SolverContext.java +++ b/src/org/sosy_lab/java_smt/solvers/yices2/Yices2SolverContext.java @@ -80,7 +80,7 @@ public static Yices2SolverContext create( @VisibleForTesting static void loadLibrary() { - loadLibrary(ImmutableList.of("yices2j"), ImmutableList.of("yices", "yices2j")); + loadLibrary(ImmutableList.of("yices2j"), ImmutableList.of("libyices", "libyices2j")); } /** From 340b60a35bb7db8c008308c1e89d8b67c841ff8a Mon Sep 17 00:00:00 2001 From: baierd Date: Tue, 2 Feb 2021 17:55:21 +0100 Subject: [PATCH 04/13] Change Types to be Windows compatible --- lib/native/source/yices2j/includes/defines.h | 8 ++++---- ...g_sosy_1lab_java_1smt_solvers_yices2_Yices2NativeApi.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/native/source/yices2j/includes/defines.h b/lib/native/source/yices2j/includes/defines.h index 9d0daa56ff..5f188b2b08 100644 --- a/lib/native/source/yices2j/includes/defines.h +++ b/lib/native/source/yices2j/includes/defines.h @@ -181,7 +181,7 @@ typedef void jvoid; // for symmetry to jint, jlong etc. out##num: #define FREE_INT_ARRAY_ARG(num) \ - (*jenv)->ReleaseIntArrayElements(jenv, arg##num, m_arg##num, 0); \ + (*jenv)->ReleaseIntArrayElements(jenv, arg##num, (jint *)m_arg##num, 0); \ out##num: #define FREE_LONG_ARRAY_ARG(num) \ @@ -235,7 +235,7 @@ typedef void jvoid; // for symmetry to jint, jlong etc. throwException(jenv, "java/lang/IllegalArgumentException", msg); \ return 0; \ } \ - return (long) retval; \ + return (size_t) retval; \ } #define POINTER_ARG_RETURN(num) \ @@ -309,7 +309,7 @@ typedef void jvoid; // for symmetry to jint, jlong etc. if (!(*jenv)->ExceptionCheck(jenv)) { \ jretval = (*jenv)->NewIntArray(jenv, 2); \ if(jretval != NULL){ \ - (*jenv)->SetIntArrayRegion(jenv, jretval, 0, 2, yval); \ + (*jenv)->SetIntArrayRegion(jenv, jretval, 0, 2, (jint *)yval); \ } \ } \ return jretval; \ @@ -325,7 +325,7 @@ typedef void jvoid; // for symmetry to jint, jlong etc. if (!(*jenv)->ExceptionCheck(jenv)) { \ jretval = (*jenv)->NewIntArray(jenv, sz); \ if(jretval != NULL){ \ - (*jenv)->SetIntArrayRegion(jenv, jretval, 0, sz, m_arg##num); \ + (*jenv)->SetIntArrayRegion(jenv, jretval, 0, sz, (jint *)m_arg##num); \ } \ } \ out: \ diff --git a/lib/native/source/yices2j/org_sosy_1lab_java_1smt_solvers_yices2_Yices2NativeApi.c b/lib/native/source/yices2j/org_sosy_1lab_java_1smt_solvers_yices2_Yices2NativeApi.c index 9663fb4e28..cbed499cd3 100644 --- a/lib/native/source/yices2j/org_sosy_1lab_java_1smt_solvers_yices2_Yices2NativeApi.c +++ b/lib/native/source/yices2j/org_sosy_1lab_java_1smt_solvers_yices2_Yices2NativeApi.c @@ -1143,7 +1143,7 @@ if ((*jenv)->ExceptionCheck(jenv)) { } jretval = (*jenv)->NewIntArray(jenv, sz); if (jretval != NULL) { - (*jenv)->SetIntArrayRegion(jenv, jretval, 0, sz, m_arg3); + (*jenv)->SetIntArrayRegion(jenv, jretval, 0, sz, (jint *)m_arg3); } out: free(m_arg3); From 5d38ba646c3e993192d0bf6a90e699f317d0ba2d Mon Sep 17 00:00:00 2001 From: baierd Date: Wed, 3 Feb 2021 00:12:19 +0100 Subject: [PATCH 05/13] Script + Tutorial for Yices2 Windows Binary --- .../source/yices2j/compileForWindows.sh | 167 ++++++++++++++++++ 1 file changed, 167 insertions(+) create mode 100755 lib/native/source/yices2j/compileForWindows.sh diff --git a/lib/native/source/yices2j/compileForWindows.sh b/lib/native/source/yices2j/compileForWindows.sh new file mode 100755 index 0000000000..d1655a3cd4 --- /dev/null +++ b/lib/native/source/yices2j/compileForWindows.sh @@ -0,0 +1,167 @@ +#!/usr/bin/env bash + +# This file is part of JavaSMT, +# an API wrapper for a collection of SMT solvers: +# https://github.com/sosy-lab/java-smt +# +# SPDX-FileCopyrightText: 2020 Dirk Beyer +# +# SPDX-License-Identifier: Apache-2.0 + +# ######################################### +# +# INFO: +# This script has to be used with the Yices2 and GMP installed as explained +# below in Windows with Cygwin! +# +# ######################################### +# +# Information as to how to compile Yices2 for Windows: https://github.com/SRI-CSL/yices2/blob/master/doc/COMPILING +# Information as to how to compile GMP for Windows for Yices2: https://github.com/SRI-CSL/yices2/blob/master/doc/GMP +# Note: Cygwin is needed for compiliation, but the binary can be build in a way that it is not needed for execution. +# +# Install Cygwin https://www.cygwin.com/ +# Note: choose to install "mingw64-x86_64-gcc-..." (at least core and g++), +# "mingw64-x86_64-headers", "mingw64-x86_64-runtime", "gcc-core", "gcc-g++", +# "libgcc", "cmake", "bash", "m4" and "make", "automake", "autoconf2.1", +# "autoconf2.5", "autoconf" (the wrapper thingy), "libtool" and "gperf" +# If you miss to install them, just restart the installation file and you can choose them. +# +# It might be possible that you need to install MinGW first +# and the cross-compiler in Cygwin ("mingw64-x86_64-gcc-...") after that. +# +# Install MinGW http://www.mingw.org +# Note: Do not install MinGW in any location with spaces in the path name! +# The preferred installation target directory is C:\MinGW +# +# Yices2 needs the static and dynamic version of GMP +# and Windows doesn't allow both to be installed in the same dir, so we need to install it twice. +# +# Building GMP(shared) 64: +# +# Download GMP https://gmplib.org/ +# Switch to Cygwin +# +# Unzip/Untar your GMP download to a location ${gmp_build} with for example: +# cd ${gmp_build} +# tar -xf ${gmp_download}/gmp-x.x.x.tar.gz //for a tar.xz ball +# +# cd into/new/gmp/dir +# We need to set mingw64 as compiler. +# CC NM and AR need to match your installed mingw (located at /usr/bin ). +# The --prefix is the install location. You can change it, but remember where you put it. +# +# ./configure --disable-static --enable-shared --prefix=/usr/tools/shared-gmp \ +# --host=x86_64-pc-mingw32 --build=i686-pc-cygwin CC=/usr/bin/x86_64-w64-mingw32-gcc \ +# NM=/usr/bin/x86_64-w64-mingw32-nm AR=/usr/bin/x86_64-w64-mingw32-ar CC_FOR_BUILD=gcc +# +# make +# make check +# make install +# +# That should have "installed" the following files that we need: +# +# /usr/tools/static-gmp/bin/libgmp-10.dll (DLL) +# /usr/tools/static-gmp/lib/libgmp.dll.a (import library) +# /usr/tools/static-gmp/lib/libgmp.la (stuff used by libtool) +# /usr/tools/static-gmp/include/gmp.h +# +# Building GMP (static) 32: +# +# Go back to the dir you Unzipped the tarball (same as shared) +# +# The following installs the static GMP to /tools/static_gmp but you can change that of course: +# You need to use "make clean" after a failed make or it might not configure correctly! +# +# ./configure --disable-shared --enable-static --prefix=/usr/tools/static-gmp \ +# --host=x86_64-pc-mingw32 --build=i686-pc-cygwin CC=/usr/bin/x86_64-w64-mingw32-gcc \ +# NM=/usr/bin/x86_64-w64-mingw32-nm AR=/usr/bin/x86_64-w64-mingw32-ar CC_FOR_BUILD=gcc +# +# make +# make check +# make install +# +# This should have installed: +# +# /usr/tools/static-gmp/lib/libgmp.a +# /usr/tools/static-gmp/include/gmp.h +# +# +# Now we build Yices2 (The Yices2 documentation gives 2 options to configure yices2 here. I used the second.) +# You may need to edit the compiler etc. just like in step 5 + specify where you have installed your GMP +# (CPPFLAGS, LDFLAGS point to the shared GMP. with-static-gmp, with-static-gmp-include-dir point to the static GMP) +# After using configure you need to give 'OPTION=mingw64' to every make command. +# (including make clean) +# +# ./configure --build=x86_64-pc-mingw32 CC=/usr/bin/x86_64-w64-mingw32-gcc \ +# LD=/usr/bin/x86_64-w64-mingw32-ld STRIP=/usr/bin/x86_64-w64-mingw32-strip \ +# RANLIB=/usr/bin/x86_64-w64-mingw32-ranlib CPPFLAGS=-I/usr/tools/shared-gmp/include \ +# LDFLAGS=-L/usr/tools/shared-gmp/lib --with-static-gmp=/usr/tools/static-gmp/lib/libgmp.a \ +# --with-static-gmp-include-dir=/usr/tools/static-gmp/include --host=x86_64-w64-mingw32 +# +# make OPTION=mingw64 +# +# Build the JNI wrapper dll: +# To build yices2 bindings: ./compileForWindows.sh $YICES_SRC_DIR $SHARED_GMP_SRC_DIR $JNI_DIR +# +# After running the script, copy the libyices.dll from the Yices2 folder +# (yices2/build/x86_64-unknown-mingw32-release/bin) and the libyices2j.dll +# to java-smt\lib\native\x86_64-windows or publish it. +# + + +SOURCE="${BASH_SOURCE[0]}" +while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink + DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" + SOURCE="$(readlink "$SOURCE")" + [[ ${SOURCE} != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located +done +DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" + +cd ${DIR} + +JNI_DIR="$3"/include +JNI_HEADERS="-I${JNI_DIR}/ -I${JNI_DIR}/win32/" + +YICES_SRC_DIR="$1" +YICES_RLS_DIR="$1"/build/x86_64-unknown-mingw32-release + +SHARED_GMP_SRC_DIR="$2" + +SRC_FILES="org_sosy_1lab_java_1smt_solvers_yices2_Yices2NativeApi.c" + +# check requirements +if [ ! -f "$YICES_RLS_DIR/bin/libyices.dll" ]; then + echo "You need to specify the directory with the built yices2 on the command line!" + echo "Can not find $YICES_RLS_DIR/bin/libyices.dll" + exit 1 +fi +if [ ! -f "$JNI_DIR/jni.h" ]; then + echo "You need to specify the directory with the downloaded JNI headers on the command line!" + echo "Can not find $JNI_DIR/jni.h" + exit 1 +fi + +OUT_FILE="libyices2j.dll" + +echo "Compiling the C wrapper code and creating the \"$OUT_FILE\" library..." + +# This will compile the JNI wrapper part, given the JNI and the Mathsat header files +x86_64-w64-mingw32-gcc -g -o $OUT_FILE -shared -Wl,-soname,$OUT_FILE \ + -D_JNI_IMPLEMENTATION_ -Wl,--kill-at $JNI_HEADERS \ + -I$YICES_RLS_DIR/dist/include -L$YICES_RLS_DIR/lib -L$SHARED_GMP_SRC_DIR/include -L. \ + org_sosy_1lab_java_1smt_solvers_yices2_Yices2NativeApi.c \ + -lyices $YICES_RLS_DIR/bin/libyices.dll -lgmp -L$SHARED_GMP_SRC_DIR/lib \ + -lstdc++ + +echo "Compilation Done" +echo "Reducing file size by dropping unused symbols..." + +strip ${OUT_FILE} + +echo "Reduction Done" +echo "All Done" + +echo "Please check the following dependencies that will be required at runtime by $OUT_FILE:" +echo "(DLLs like 'kernel32' and 'msvcrt' are provided by Windows)" +objdump -p $OUT_FILE | grep "DLL Name" From 9075e10944a475d2a26f675f583f6b00fc182320 Mon Sep 17 00:00:00 2001 From: baierd Date: Wed, 3 Feb 2021 02:41:09 +0100 Subject: [PATCH 06/13] fix spelling/error + dependency info --- lib/native/source/yices2j/compileForWindows.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/native/source/yices2j/compileForWindows.sh b/lib/native/source/yices2j/compileForWindows.sh index d1655a3cd4..2e53c1d0a2 100755 --- a/lib/native/source/yices2j/compileForWindows.sh +++ b/lib/native/source/yices2j/compileForWindows.sh @@ -103,9 +103,12 @@ # # Build the JNI wrapper dll: # To build yices2 bindings: ./compileForWindows.sh $YICES_SRC_DIR $SHARED_GMP_SRC_DIR $JNI_DIR +# +# Note: You must change the line/file endings of this script on your Windows +# environment to Unix style so that you can run it in Cygwin # # After running the script, copy the libyices.dll from the Yices2 folder -# (yices2/build/x86_64-unknown-mingw32-release/bin) and the libyices2j.dll +# (yices2/build/x86_64-unknown-mingw32-release/bin), the shared gmp dll and the libyices2j.dll # to java-smt\lib\native\x86_64-windows or publish it. # @@ -146,10 +149,10 @@ OUT_FILE="libyices2j.dll" echo "Compiling the C wrapper code and creating the \"$OUT_FILE\" library..." -# This will compile the JNI wrapper part, given the JNI and the Mathsat header files +# This will compile the JNI wrapper part, given the JNI and the Yices2 header files x86_64-w64-mingw32-gcc -g -o $OUT_FILE -shared -Wl,-soname,$OUT_FILE \ -D_JNI_IMPLEMENTATION_ -Wl,--kill-at $JNI_HEADERS \ - -I$YICES_RLS_DIR/dist/include -L$YICES_RLS_DIR/lib -L$SHARED_GMP_SRC_DIR/include -L. \ + -I$YICES_RLS_DIR/dist/include -L$YICES_RLS_DIR/lib -I$SHARED_GMP_SRC_DIR/include -L. \ org_sosy_1lab_java_1smt_solvers_yices2_Yices2NativeApi.c \ -lyices $YICES_RLS_DIR/bin/libyices.dll -lgmp -L$SHARED_GMP_SRC_DIR/lib \ -lstdc++ From a99c3af26ece5efb14aa1e9b7031782df206da35 Mon Sep 17 00:00:00 2001 From: baierd Date: Wed, 3 Feb 2021 02:55:23 +0100 Subject: [PATCH 07/13] checkstyle --- .../java_smt/solvers/yices2/Yices2SolverContext.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/org/sosy_lab/java_smt/solvers/yices2/Yices2SolverContext.java b/src/org/sosy_lab/java_smt/solvers/yices2/Yices2SolverContext.java index 8eff79b4fd..243ffae24d 100644 --- a/src/org/sosy_lab/java_smt/solvers/yices2/Yices2SolverContext.java +++ b/src/org/sosy_lab/java_smt/solvers/yices2/Yices2SolverContext.java @@ -84,10 +84,8 @@ static void loadLibrary() { } /** - * This method loads the given library, depending on the operating system. - * - *

- * Each list is applied in the given ordering. + * This method loads the given library, depending on the operating system. Each list is applied in + * the given ordering. */ private static void loadLibrary(List linuxLibrary, List windowsLibrary) { // we try Linux first, and then Windows. From d7c747a02461d2a4172ba6bb6dea5c7ce53dace3 Mon Sep 17 00:00:00 2001 From: baierd Date: Fri, 5 Feb 2021 13:32:26 +0100 Subject: [PATCH 08/13] Provide a seperate script for Linux based mingw --- .../yices2j/compileForWindowsOnLinux.sh | 183 ++++++++++++++++++ 1 file changed, 183 insertions(+) create mode 100755 lib/native/source/yices2j/compileForWindowsOnLinux.sh diff --git a/lib/native/source/yices2j/compileForWindowsOnLinux.sh b/lib/native/source/yices2j/compileForWindowsOnLinux.sh new file mode 100755 index 0000000000..72bbb933f8 --- /dev/null +++ b/lib/native/source/yices2j/compileForWindowsOnLinux.sh @@ -0,0 +1,183 @@ +#!/usr/bin/env bash + +# This file is part of JavaSMT, +# an API wrapper for a collection of SMT solvers: +# https://github.com/sosy-lab/java-smt +# +# SPDX-FileCopyrightText: 2020 Dirk Beyer +# +# SPDX-License-Identifier: Apache-2.0 + +# ######################################### +# +# INFO: +# This script has to be used with the Yices2 and GMP installed as explained +# below in Windows with Cygwin! +# +# ######################################### +# +# Information as to how to compile Yices2 for Windows: https://github.com/SRI-CSL/yices2/blob/master/doc/COMPILING +# Information as to how to compile GMP for Windows for Yices2: https://github.com/SRI-CSL/yices2/blob/master/doc/GMP +# Note: Cygwin is needed for compiliation, but the binary can be build in a way that it is not needed for execution. +# +# Install Cygwin https://www.cygwin.com/ +# Note: choose to install "mingw64-x86_64-gcc-..." (at least core and g++), +# "mingw64-x86_64-headers", "mingw64-x86_64-runtime", "gcc-core", "gcc-g++", +# "libgcc", "cmake", "bash", "m4" and "make", "automake", "autoconf2.1", +# "autoconf2.5", "autoconf" (the wrapper thingy), "libtool" and "gperf" +# If you miss to install them, just restart the installation file and you can choose them. +# +# It might be possible that you need to install MinGW first +# and the cross-compiler in Cygwin ("mingw64-x86_64-gcc-...") after that. +# +# Install MinGW http://www.mingw.org +# Note: Do not install MinGW in any location with spaces in the path name! +# The preferred installation target directory is C:\MinGW +# +# Yices2 needs the static and dynamic version of GMP +# and Windows doesn't allow both to be installed in the same dir, so we need to install it twice. +# +# Building GMP(shared) 64: +# +# Download GMP https://gmplib.org/ +# Switch to Cygwin +# +# Unzip/Untar your GMP download to a location ${gmp_build} with for example: +# cd ${gmp_build} +# tar -xf ${gmp_download}/gmp-x.x.x.tar.gz //for a tar.xz ball +# +# cd into/new/gmp/dir +# We need to set mingw64 as compiler. +# CC NM and AR need to match your installed mingw (located at /usr/bin ). +# The --prefix is the install location. You can change it, but remember where you put it. +# +# ./configure --disable-static --enable-shared --prefix=/usr/tools/shared-gmp \ +# --host=x86_64-pc-mingw32 --build=i686-pc-cygwin CC=/usr/bin/x86_64-w64-mingw32-gcc \ +# NM=/usr/bin/x86_64-w64-mingw32-nm AR=/usr/bin/x86_64-w64-mingw32-ar CC_FOR_BUILD=gcc +# +# make +# make check +# make install +# +# That should have "installed" the following files that we need: +# +# /usr/tools/static-gmp/bin/libgmp-10.dll (DLL) +# /usr/tools/static-gmp/lib/libgmp.dll.a (import library) +# /usr/tools/static-gmp/lib/libgmp.la (stuff used by libtool) +# /usr/tools/static-gmp/include/gmp.h +# +# Building GMP (static) 32: +# +# Go back to the dir you Unzipped the tarball (same as shared) +# +# The following installs the static GMP to /tools/static_gmp but you can change that of course: +# You need to use "make clean" after a failed make or it might not configure correctly! +# +# ./configure --disable-shared --enable-static --prefix=/usr/tools/static-gmp \ +# --host=x86_64-pc-mingw32 --build=i686-pc-cygwin CC=/usr/bin/x86_64-w64-mingw32-gcc \ +# NM=/usr/bin/x86_64-w64-mingw32-nm AR=/usr/bin/x86_64-w64-mingw32-ar CC_FOR_BUILD=gcc +# +# make +# make check +# make install +# +# This should have installed: +# +# /usr/tools/static-gmp/lib/libgmp.a +# /usr/tools/static-gmp/include/gmp.h +# +# +# Now we build Yices2 (The Yices2 documentation gives 2 options to configure yices2 here. I used the second.) +# You may need to edit the compiler etc. just like in step 5 + specify where you have installed your GMP +# (CPPFLAGS, LDFLAGS point to the shared GMP. with-static-gmp, with-static-gmp-include-dir point to the static GMP) +# After using configure you need to give 'OPTION=mingw64' to every make command. +# (including make clean) +# +# ./configure --build=x86_64-pc-mingw32 CC=/usr/bin/x86_64-w64-mingw32-gcc \ +# LD=/usr/bin/x86_64-w64-mingw32-ld STRIP=/usr/bin/x86_64-w64-mingw32-strip \ +# RANLIB=/usr/bin/x86_64-w64-mingw32-ranlib CPPFLAGS=-I/usr/tools/shared-gmp/include \ +# LDFLAGS=-L/usr/tools/shared-gmp/lib --with-static-gmp=/usr/tools/static-gmp/lib/libgmp.a \ +# --with-static-gmp-include-dir=/usr/tools/static-gmp/include --host=x86_64-w64-mingw32 +# +# make OPTION=mingw64 +# +# Build the JNI wrapper dll: +# To build yices2 bindings: ./compileForWindows.sh $YICES_SRC_DIR $SHARED_GMP_SRC_DIR $JNI_DIR +# +# Note: You must change the line/file endings of this script on your Windows +# environment to Unix style so that you can run it in Cygwin +# +# After running the script, copy the libyices.dll from the Yices2 folder +# (yices2/build/x86_64-unknown-mingw32-release/bin), the shared gmp dll and the libyices2j.dll +# to java-smt\lib\native\x86_64-windows or publish it. +# +# ################################################################################# +# +# Easier way of building: Download Yices2 dll for Windows from the website. +# Build GMP on Linux with mingw for Windows. +# Use this script with both. +# +# Command to build GMP on Linux with mingw for Windows: +# ./configure --disable-static --enable-shared --host=x86_64-pc-mingw32 --build=x86_64-linux-gnu CC=x86_64-w64-mingw32-gcc CC_FOR_BUILD=gcc CPPFLAGS=-D__USE_MINGW_ANSI_STDIO LDFLAGS="-static-libgcc -static-libstdc++" +# +# +# +# +# + + +SOURCE="${BASH_SOURCE[0]}" +while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink + DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" + SOURCE="$(readlink "$SOURCE")" + [[ ${SOURCE} != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located +done +DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" + +cd ${DIR} + +JNI_DIR="$3"/include +JNI_HEADERS="-I${JNI_DIR}/ -I${JNI_DIR}/win32/" + +YICES_SRC_DIR="$1" + + +SHARED_GMP_SRC_DIR="$2" + +SRC_FILES="org_sosy_1lab_java_1smt_solvers_yices2_Yices2NativeApi.c" + +# check requirements +if [ ! -f "$YICES_SRC_DIR/bin/libyices.dll" ]; then + echo "You need to specify the directory with the built yices2 on the command line!" + echo "Can not find $YICES_SRC_DIR/bin/libyices.dll" + exit 1 +fi +if [ ! -f "$JNI_DIR/jni.h" ]; then + echo "You need to specify the directory with the downloaded JNI headers on the command line!" + echo "Can not find $JNI_DIR/jni.h" + exit 1 +fi + +OUT_FILE="libyices2j.dll" + +echo "Compiling the C wrapper code and creating the \"$OUT_FILE\" library..." + +# This will compile the JNI wrapper part, given the JNI and the Yices2 header files +x86_64-w64-mingw32-gcc -g -o $OUT_FILE -shared -Wl,-soname,$OUT_FILE \ + -D_JNI_IMPLEMENTATION_ -Wl,--kill-at $JNI_HEADERS \ + -I$YICES_SRC_DIR/include -L$YICES_SRC_DIR/lib -I$SHARED_GMP_SRC_DIR/include -L. \ + org_sosy_1lab_java_1smt_solvers_yices2_Yices2NativeApi.c \ + -lyices $YICES_SRC_DIR/bin/libyices.dll -lgmp -L$SHARED_GMP_SRC_DIR/lib \ + -lstdc++ + +echo "Compilation Done" +echo "Reducing file size by dropping unused symbols..." + +strip ${OUT_FILE} + +echo "Reduction Done" +echo "All Done" + +echo "Please check the following dependencies that will be required at runtime by $OUT_FILE:" +echo "(DLLs like 'kernel32' and 'msvcrt' are provided by Windows)" +objdump -p $OUT_FILE | grep "DLL Name" From f6086d49ca7eec3d97dfedcf8d0b655e2785eff2 Mon Sep 17 00:00:00 2001 From: Baier D Date: Sat, 27 Feb 2021 15:01:57 +0100 Subject: [PATCH 09/13] Update Yices2 Windows Build to static GMP --- lib/native/source/yices2j/compileForWindows.sh | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/native/source/yices2j/compileForWindows.sh b/lib/native/source/yices2j/compileForWindows.sh index 2e53c1d0a2..7ae191ec2d 100755 --- a/lib/native/source/yices2j/compileForWindows.sh +++ b/lib/native/source/yices2j/compileForWindows.sh @@ -89,7 +89,8 @@ # # Now we build Yices2 (The Yices2 documentation gives 2 options to configure yices2 here. I used the second.) # You may need to edit the compiler etc. just like in step 5 + specify where you have installed your GMP -# (CPPFLAGS, LDFLAGS point to the shared GMP. with-static-gmp, with-static-gmp-include-dir point to the static GMP) +# (CPPFLAGS, LDFLAGS point to the shared GMP. with-static-gmp, with-static-gmp-include-dir point to the static GMP. +# On Windows a static GMP is also PIC per default.) # After using configure you need to give 'OPTION=mingw64' to every make command. # (including make clean) # @@ -99,7 +100,8 @@ # LDFLAGS=-L/usr/tools/shared-gmp/lib --with-static-gmp=/usr/tools/static-gmp/lib/libgmp.a \ # --with-static-gmp-include-dir=/usr/tools/static-gmp/include --host=x86_64-w64-mingw32 # -# make OPTION=mingw64 +# make static-dist OPTION=mingw64 +# static-dist linkds gmp statically into yices # # Build the JNI wrapper dll: # To build yices2 bindings: ./compileForWindows.sh $YICES_SRC_DIR $SHARED_GMP_SRC_DIR $JNI_DIR @@ -152,13 +154,18 @@ echo "Compiling the C wrapper code and creating the \"$OUT_FILE\" library..." # This will compile the JNI wrapper part, given the JNI and the Yices2 header files x86_64-w64-mingw32-gcc -g -o $OUT_FILE -shared -Wl,-soname,$OUT_FILE \ -D_JNI_IMPLEMENTATION_ -Wl,--kill-at $JNI_HEADERS \ - -I$YICES_RLS_DIR/dist/include -L$YICES_RLS_DIR/lib -I$SHARED_GMP_SRC_DIR/include -L. \ + -I$YICES_RLS_DIR/static_dist/include -L$YICES_RLS_DIR/static_lib -I$SHARED_GMP_SRC_DIR/include -L. \ org_sosy_1lab_java_1smt_solvers_yices2_Yices2NativeApi.c \ - -lyices $YICES_RLS_DIR/bin/libyices.dll -lgmp -L$SHARED_GMP_SRC_DIR/lib \ + -lyices $YICES_RLS_DIR/static_bin/libyices.dll -lgmp -L$SHARED_GMP_SRC_DIR/lib \ -lstdc++ echo "Compilation Done" echo "Reducing file size by dropping unused symbols..." +# pwinthread is linked into yices2, but sometimes this doesn't work properly as it only links against symbols used by compile time not runtime! +# You can try to not strip and if that doesn't work you need to add the --whole-archive flag to the linking process like so: +# +# Note that you should deactivate the flag after pwinthread! +echo "Note: If in the future multithread support fails, this might be the cause!" strip ${OUT_FILE} From c674f4eed48dabcc2df50ec99259e35e469dcbe3 Mon Sep 17 00:00:00 2001 From: Baier D Date: Sat, 27 Feb 2021 15:41:36 +0100 Subject: [PATCH 10/13] Update compile instructions for static Yices2 --- lib/native/source/yices2j/compileForWindows.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/native/source/yices2j/compileForWindows.sh b/lib/native/source/yices2j/compileForWindows.sh index 7ae191ec2d..a631a781b5 100755 --- a/lib/native/source/yices2j/compileForWindows.sh +++ b/lib/native/source/yices2j/compileForWindows.sh @@ -97,7 +97,7 @@ # ./configure --build=x86_64-pc-mingw32 CC=/usr/bin/x86_64-w64-mingw32-gcc \ # LD=/usr/bin/x86_64-w64-mingw32-ld STRIP=/usr/bin/x86_64-w64-mingw32-strip \ # RANLIB=/usr/bin/x86_64-w64-mingw32-ranlib CPPFLAGS=-I/usr/tools/shared-gmp/include \ -# LDFLAGS=-L/usr/tools/shared-gmp/lib --with-static-gmp=/usr/tools/static-gmp/lib/libgmp.a \ +# LDFLAGS=-L/usr/tools/static-gmp/lib --with-static-gmp=/usr/tools/static-gmp/lib/libgmp.a \ # --with-static-gmp-include-dir=/usr/tools/static-gmp/include --host=x86_64-w64-mingw32 # # make static-dist OPTION=mingw64 From c73eda59be8e6aea45b3dafdb6bafd8e9fc04198 Mon Sep 17 00:00:00 2001 From: Baier D Date: Wed, 7 Apr 2021 14:12:08 +0200 Subject: [PATCH 11/13] Update Yices2 Windows build script for Cygwin --- .../source/yices2j/compileForWindows.sh | 37 ++++++++++++------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/lib/native/source/yices2j/compileForWindows.sh b/lib/native/source/yices2j/compileForWindows.sh index a631a781b5..ace65979f3 100755 --- a/lib/native/source/yices2j/compileForWindows.sh +++ b/lib/native/source/yices2j/compileForWindows.sh @@ -93,25 +93,25 @@ # On Windows a static GMP is also PIC per default.) # After using configure you need to give 'OPTION=mingw64' to every make command. # (including make clean) +# adding "static-dist" linkds gmp statically into yices. This means that binaries etc. are in the build folders static_bin/ and no longer in bin/ in yices2. # # ./configure --build=x86_64-pc-mingw32 CC=/usr/bin/x86_64-w64-mingw32-gcc \ # LD=/usr/bin/x86_64-w64-mingw32-ld STRIP=/usr/bin/x86_64-w64-mingw32-strip \ # RANLIB=/usr/bin/x86_64-w64-mingw32-ranlib CPPFLAGS=-I/usr/tools/shared-gmp/include \ -# LDFLAGS=-L/usr/tools/static-gmp/lib --with-static-gmp=/usr/tools/static-gmp/lib/libgmp.a \ +# LDFLAGS=-L/usr/tools/shared-gmp/lib --with-static-gmp=/usr/tools/static-gmp/lib/libgmp.a \ # --with-static-gmp-include-dir=/usr/tools/static-gmp/include --host=x86_64-w64-mingw32 # # make static-dist OPTION=mingw64 -# static-dist linkds gmp statically into yices # # Build the JNI wrapper dll: -# To build yices2 bindings: ./compileForWindows.sh $YICES_SRC_DIR $SHARED_GMP_SRC_DIR $JNI_DIR +# To build yices2 bindings: ./compileForWindows.sh $YICES_SRC_DIR $SHARED_GMP_SRC_DIR $STATIC_GMP_SRC_DIR $JNI_DIR # # Note: You must change the line/file endings of this script on your Windows # environment to Unix style so that you can run it in Cygwin # # After running the script, copy the libyices.dll from the Yices2 folder -# (yices2/build/x86_64-unknown-mingw32-release/bin), the shared gmp dll and the libyices2j.dll -# to java-smt\lib\native\x86_64-windows or publish it. +# (yices2/build/x86_64-unknown-mingw32-release/bin) and the libyices2j.dll +# to java-smt\lib\native\x86_64-windows and/or publish it. # @@ -125,20 +125,22 @@ DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" cd ${DIR} -JNI_DIR="$3"/include JNI_HEADERS="-I${JNI_DIR}/ -I${JNI_DIR}/win32/" YICES_SRC_DIR="$1" YICES_RLS_DIR="$1"/build/x86_64-unknown-mingw32-release SHARED_GMP_SRC_DIR="$2" +STATIC_GMP_SRC_DIR="$2" + +JNI_DIR="$3"/include SRC_FILES="org_sosy_1lab_java_1smt_solvers_yices2_Yices2NativeApi.c" # check requirements if [ ! -f "$YICES_RLS_DIR/bin/libyices.dll" ]; then echo "You need to specify the directory with the built yices2 on the command line!" - echo "Can not find $YICES_RLS_DIR/bin/libyices.dll" + echo "Can not find $YICES_RLS_DIR/static_bin/libyices.dll" exit 1 fi if [ ! -f "$JNI_DIR/jni.h" ]; then @@ -149,17 +151,24 @@ fi OUT_FILE="libyices2j.dll" -echo "Compiling the C wrapper code and creating the \"$OUT_FILE\" library..." +echo "Compiling the C wrapper code..." -# This will compile the JNI wrapper part, given the JNI and the Yices2 header files -x86_64-w64-mingw32-gcc -g -o $OUT_FILE -shared -Wl,-soname,$OUT_FILE \ +x86_64-w64-mingw32-gcc \ -D_JNI_IMPLEMENTATION_ -Wl,--kill-at $JNI_HEADERS \ - -I$YICES_RLS_DIR/static_dist/include -L$YICES_RLS_DIR/static_lib -I$SHARED_GMP_SRC_DIR/include -L. \ - org_sosy_1lab_java_1smt_solvers_yices2_Yices2NativeApi.c \ - -lyices $YICES_RLS_DIR/static_bin/libyices.dll -lgmp -L$SHARED_GMP_SRC_DIR/lib \ - -lstdc++ + -I$YICES_RLS_DIR/static_dist/include -L$YICES_RLS_DIR/static_lib -L. -I$STATIC_GMP_SRC_DIR/include -I. -Iincludes -I$SHARED_GMP_SRC_DIR/include \ + -c org_sosy_1lab_java_1smt_solvers_yices2_Yices2NativeApi.c -o org_sosy_1lab_java_1smt_solvers_yices2_Yices2NativeApi.o echo "Compilation Done" +echo "Creating the \"$OUT_FILE\" library..." + +# This will compile the JNI wrapper part, given the JNI and the Yices2 header files +x86_64-w64-mingw32-gcc -Wredundant-decls -Wno-format -O3 -fomit-frame-pointer -fno-stack-protector -Wall -g -o $OUT_FILE -shared -Wl,-soname,$OUT_FILE \ + -Wl,--out-implib=$YICES_RLS_DIR/static_lib/libyices.dll.a -Wl,--no-undefined \ + -L. -L$YICES_RLS_DIR/static_lib -L$SHARED_GMP_SRC_DIR/lib -L$STATIC_GMP_SRC_DIR/lib \ + -I$SHARED_GMP_SRC_DIR/include org_sosy_1lab_java_1smt_solvers_yices2_Yices2NativeApi.o -Wl,-Bdynamic -lyices $YICES_RLS_DIR/static_bin/libyices.dll \ + -Wl,-Bstatic -static-libstdc++ -lstdc++ -lgmp -L$STATIC_GMP_SRC_DIR/lib -lm + +echo "Linking Done" echo "Reducing file size by dropping unused symbols..." # pwinthread is linked into yices2, but sometimes this doesn't work properly as it only links against symbols used by compile time not runtime! # You can try to not strip and if that doesn't work you need to add the --whole-archive flag to the linking process like so: From 114a9f84f0c04bfe386b5cd5f0a8b1ef25c03f46 Mon Sep 17 00:00:00 2001 From: Baier D Date: Wed, 7 Apr 2021 14:13:29 +0200 Subject: [PATCH 12/13] More information regarding multithreading --- lib/native/source/yices2j/compileForWindows.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/native/source/yices2j/compileForWindows.sh b/lib/native/source/yices2j/compileForWindows.sh index ace65979f3..412c1ac61c 100755 --- a/lib/native/source/yices2j/compileForWindows.sh +++ b/lib/native/source/yices2j/compileForWindows.sh @@ -172,9 +172,9 @@ echo "Linking Done" echo "Reducing file size by dropping unused symbols..." # pwinthread is linked into yices2, but sometimes this doesn't work properly as it only links against symbols used by compile time not runtime! # You can try to not strip and if that doesn't work you need to add the --whole-archive flag to the linking process like so: -# -# Note that you should deactivate the flag after pwinthread! -echo "Note: If in the future multithread support fails, this might be the cause!" +# -Wl,-Bstatic,--whole-archive +# Note that you should deactivate the flag after pwinthread with: -Wl,-Bdynamic (or -Wl,-Bstatic if you prefer to link statically but not the whole archive) +echo "Note: If in the future multithread support fails, please refer to the compiliation script for help!" strip ${OUT_FILE} From 9f7f2138fb40ef1d03babc07448123bd8b9d01ba Mon Sep 17 00:00:00 2001 From: baierd Date: Wed, 7 Apr 2021 14:27:53 +0200 Subject: [PATCH 13/13] Merge w Master + remove old file --- .../yices2j/compileForWindowsOnLinux.sh | 183 ------------------ 1 file changed, 183 deletions(-) delete mode 100755 lib/native/source/yices2j/compileForWindowsOnLinux.sh diff --git a/lib/native/source/yices2j/compileForWindowsOnLinux.sh b/lib/native/source/yices2j/compileForWindowsOnLinux.sh deleted file mode 100755 index 72bbb933f8..0000000000 --- a/lib/native/source/yices2j/compileForWindowsOnLinux.sh +++ /dev/null @@ -1,183 +0,0 @@ -#!/usr/bin/env bash - -# This file is part of JavaSMT, -# an API wrapper for a collection of SMT solvers: -# https://github.com/sosy-lab/java-smt -# -# SPDX-FileCopyrightText: 2020 Dirk Beyer -# -# SPDX-License-Identifier: Apache-2.0 - -# ######################################### -# -# INFO: -# This script has to be used with the Yices2 and GMP installed as explained -# below in Windows with Cygwin! -# -# ######################################### -# -# Information as to how to compile Yices2 for Windows: https://github.com/SRI-CSL/yices2/blob/master/doc/COMPILING -# Information as to how to compile GMP for Windows for Yices2: https://github.com/SRI-CSL/yices2/blob/master/doc/GMP -# Note: Cygwin is needed for compiliation, but the binary can be build in a way that it is not needed for execution. -# -# Install Cygwin https://www.cygwin.com/ -# Note: choose to install "mingw64-x86_64-gcc-..." (at least core and g++), -# "mingw64-x86_64-headers", "mingw64-x86_64-runtime", "gcc-core", "gcc-g++", -# "libgcc", "cmake", "bash", "m4" and "make", "automake", "autoconf2.1", -# "autoconf2.5", "autoconf" (the wrapper thingy), "libtool" and "gperf" -# If you miss to install them, just restart the installation file and you can choose them. -# -# It might be possible that you need to install MinGW first -# and the cross-compiler in Cygwin ("mingw64-x86_64-gcc-...") after that. -# -# Install MinGW http://www.mingw.org -# Note: Do not install MinGW in any location with spaces in the path name! -# The preferred installation target directory is C:\MinGW -# -# Yices2 needs the static and dynamic version of GMP -# and Windows doesn't allow both to be installed in the same dir, so we need to install it twice. -# -# Building GMP(shared) 64: -# -# Download GMP https://gmplib.org/ -# Switch to Cygwin -# -# Unzip/Untar your GMP download to a location ${gmp_build} with for example: -# cd ${gmp_build} -# tar -xf ${gmp_download}/gmp-x.x.x.tar.gz //for a tar.xz ball -# -# cd into/new/gmp/dir -# We need to set mingw64 as compiler. -# CC NM and AR need to match your installed mingw (located at /usr/bin ). -# The --prefix is the install location. You can change it, but remember where you put it. -# -# ./configure --disable-static --enable-shared --prefix=/usr/tools/shared-gmp \ -# --host=x86_64-pc-mingw32 --build=i686-pc-cygwin CC=/usr/bin/x86_64-w64-mingw32-gcc \ -# NM=/usr/bin/x86_64-w64-mingw32-nm AR=/usr/bin/x86_64-w64-mingw32-ar CC_FOR_BUILD=gcc -# -# make -# make check -# make install -# -# That should have "installed" the following files that we need: -# -# /usr/tools/static-gmp/bin/libgmp-10.dll (DLL) -# /usr/tools/static-gmp/lib/libgmp.dll.a (import library) -# /usr/tools/static-gmp/lib/libgmp.la (stuff used by libtool) -# /usr/tools/static-gmp/include/gmp.h -# -# Building GMP (static) 32: -# -# Go back to the dir you Unzipped the tarball (same as shared) -# -# The following installs the static GMP to /tools/static_gmp but you can change that of course: -# You need to use "make clean" after a failed make or it might not configure correctly! -# -# ./configure --disable-shared --enable-static --prefix=/usr/tools/static-gmp \ -# --host=x86_64-pc-mingw32 --build=i686-pc-cygwin CC=/usr/bin/x86_64-w64-mingw32-gcc \ -# NM=/usr/bin/x86_64-w64-mingw32-nm AR=/usr/bin/x86_64-w64-mingw32-ar CC_FOR_BUILD=gcc -# -# make -# make check -# make install -# -# This should have installed: -# -# /usr/tools/static-gmp/lib/libgmp.a -# /usr/tools/static-gmp/include/gmp.h -# -# -# Now we build Yices2 (The Yices2 documentation gives 2 options to configure yices2 here. I used the second.) -# You may need to edit the compiler etc. just like in step 5 + specify where you have installed your GMP -# (CPPFLAGS, LDFLAGS point to the shared GMP. with-static-gmp, with-static-gmp-include-dir point to the static GMP) -# After using configure you need to give 'OPTION=mingw64' to every make command. -# (including make clean) -# -# ./configure --build=x86_64-pc-mingw32 CC=/usr/bin/x86_64-w64-mingw32-gcc \ -# LD=/usr/bin/x86_64-w64-mingw32-ld STRIP=/usr/bin/x86_64-w64-mingw32-strip \ -# RANLIB=/usr/bin/x86_64-w64-mingw32-ranlib CPPFLAGS=-I/usr/tools/shared-gmp/include \ -# LDFLAGS=-L/usr/tools/shared-gmp/lib --with-static-gmp=/usr/tools/static-gmp/lib/libgmp.a \ -# --with-static-gmp-include-dir=/usr/tools/static-gmp/include --host=x86_64-w64-mingw32 -# -# make OPTION=mingw64 -# -# Build the JNI wrapper dll: -# To build yices2 bindings: ./compileForWindows.sh $YICES_SRC_DIR $SHARED_GMP_SRC_DIR $JNI_DIR -# -# Note: You must change the line/file endings of this script on your Windows -# environment to Unix style so that you can run it in Cygwin -# -# After running the script, copy the libyices.dll from the Yices2 folder -# (yices2/build/x86_64-unknown-mingw32-release/bin), the shared gmp dll and the libyices2j.dll -# to java-smt\lib\native\x86_64-windows or publish it. -# -# ################################################################################# -# -# Easier way of building: Download Yices2 dll for Windows from the website. -# Build GMP on Linux with mingw for Windows. -# Use this script with both. -# -# Command to build GMP on Linux with mingw for Windows: -# ./configure --disable-static --enable-shared --host=x86_64-pc-mingw32 --build=x86_64-linux-gnu CC=x86_64-w64-mingw32-gcc CC_FOR_BUILD=gcc CPPFLAGS=-D__USE_MINGW_ANSI_STDIO LDFLAGS="-static-libgcc -static-libstdc++" -# -# -# -# -# - - -SOURCE="${BASH_SOURCE[0]}" -while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink - DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" - SOURCE="$(readlink "$SOURCE")" - [[ ${SOURCE} != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located -done -DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" - -cd ${DIR} - -JNI_DIR="$3"/include -JNI_HEADERS="-I${JNI_DIR}/ -I${JNI_DIR}/win32/" - -YICES_SRC_DIR="$1" - - -SHARED_GMP_SRC_DIR="$2" - -SRC_FILES="org_sosy_1lab_java_1smt_solvers_yices2_Yices2NativeApi.c" - -# check requirements -if [ ! -f "$YICES_SRC_DIR/bin/libyices.dll" ]; then - echo "You need to specify the directory with the built yices2 on the command line!" - echo "Can not find $YICES_SRC_DIR/bin/libyices.dll" - exit 1 -fi -if [ ! -f "$JNI_DIR/jni.h" ]; then - echo "You need to specify the directory with the downloaded JNI headers on the command line!" - echo "Can not find $JNI_DIR/jni.h" - exit 1 -fi - -OUT_FILE="libyices2j.dll" - -echo "Compiling the C wrapper code and creating the \"$OUT_FILE\" library..." - -# This will compile the JNI wrapper part, given the JNI and the Yices2 header files -x86_64-w64-mingw32-gcc -g -o $OUT_FILE -shared -Wl,-soname,$OUT_FILE \ - -D_JNI_IMPLEMENTATION_ -Wl,--kill-at $JNI_HEADERS \ - -I$YICES_SRC_DIR/include -L$YICES_SRC_DIR/lib -I$SHARED_GMP_SRC_DIR/include -L. \ - org_sosy_1lab_java_1smt_solvers_yices2_Yices2NativeApi.c \ - -lyices $YICES_SRC_DIR/bin/libyices.dll -lgmp -L$SHARED_GMP_SRC_DIR/lib \ - -lstdc++ - -echo "Compilation Done" -echo "Reducing file size by dropping unused symbols..." - -strip ${OUT_FILE} - -echo "Reduction Done" -echo "All Done" - -echo "Please check the following dependencies that will be required at runtime by $OUT_FILE:" -echo "(DLLs like 'kernel32' and 'msvcrt' are provided by Windows)" -objdump -p $OUT_FILE | grep "DLL Name"