runtimeverification / mpfr-java

GNU MPFR Java Bindings
Other
11 stars 10 forks source link

Windows build is not well supported #11

Open leventeBajczi opened 3 years ago

leventeBajczi commented 3 years ago

After a day of trying, I managed to get the library to build on Windows 10 x64, but I thought I'd document the process in an issue in the hopes that a better build system could be instated.

The working method (based on build64.bat, but not working out-of-the-box):

  1. Download prebuilt MPFR and MPIR libraries from this website
  2. Started a maven build (which will fail, but produce the necessary native library source tree)
  3. Opened the freshly generated vc2010.vcxproj file in Visual Studio 2019, set the build tools to v142 instead of the unsupported v100
  4. Set the include path to include the MpfrMpir\Dynamic\Mpfr folder from the downloaded ZIP, and $(JAVA_HOME)/include, etc
  5. Add as existing item the .lib files from MpfrMpir\Dynamic\Mpfr to the project
  6. Build the project, copy the mpfr_java.dll (and the .dll files from MpfrMpir\Dynamic\Mpfr, but I'm not sure that is needed) into the generated-sources folder as per build64.bat, and package the jar.

This is not perfect either, because there are cryptic MPFR assertion failures in some very rare cases, which are not present in the Linux version of MPFR. This might be due to a CPU-specific instruction this prebuilt DLL assumes.

What does not work:

  1. mvn install - this will complain about missing vcbuild.exe, a compiler deprecated more than 10 years ago (in VC2010).
  2. build64.bat - this will also initially complain about vcbuild.exe missing, also a python interpreter is necessary. Furthermore, where should one receive MPFR and MPIR sources? The script assumes they are readily available, when they are most definitely not. And any particular config buildable by VC2010 is long gone in dead links and outdated forum posts.
  3. VC2010/VC2008: These were not capable of producing x64 code, even with Windows SDK 7.1 installed (which can only be done on Windows 7, due to a .NET 4.0 dependency - which cannot be installed on current Win10 installs due to the existing .NET 4.8 install). A link-time error was produced due to mismatched .obj and .dll machine types.
  4. Cygwin/MinGW - neither the maven install, nor the build64.bat presumes any other compiler such as gcc to be installed. When you build on windows, you seem to be constrained to msbuild/vcbuild.
  5. Newer MPFR versions seem to lack some functions this library requires due to deprecation.

The best solution would be including binary releases in the repo. The next best is a correct documentation of the build process on Windows - because the detailed compilation in the README presumes Linux.

I know this is an old repo, but currently one of the very few open-source, fully IEEE-754-compatible BigFloat implementation for java. It would be very beneficial to keep this alive on all major platforms, including Windows.

Baltoli commented 2 years ago

Unfortunately we don't have the resources to work on developing proper Windows support for the project. If you were to put a documented PR together that integrates with the CI, I could take a look at it and offer the resulting binary builds as release artefacts.