From 53987f9db914daa26e630a6b19bf5e9a973c1d77 Mon Sep 17 00:00:00 2001 From: Federico Fissore Date: Fri, 6 Nov 2015 13:41:59 +0100 Subject: [PATCH] Windows: msvc*.dll are not found when loading AStyle.dll. Forcing load. Fixes #4076 --- .../packages/formatter/AStyleInterface.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/app/src/cc/arduino/packages/formatter/AStyleInterface.java b/app/src/cc/arduino/packages/formatter/AStyleInterface.java index 97341f4a0..4224bf164 100644 --- a/app/src/cc/arduino/packages/formatter/AStyleInterface.java +++ b/app/src/cc/arduino/packages/formatter/AStyleInterface.java @@ -30,20 +30,27 @@ package cc.arduino.packages.formatter; import processing.app.Base; +import processing.app.helpers.OSUtils; import java.io.File; public class AStyleInterface { static { - File astyleLib = new File(Base.getContentFile("lib"), System.mapLibraryName("astylej")); - String astylePath = astyleLib.getAbsolutePath(); + if (OSUtils.isWindows()) { + loadLib(Base.getContentFile(System.mapLibraryName("msvcp100"))); + loadLib(Base.getContentFile(System.mapLibraryName("msvcr100"))); + } + loadLib(new File(Base.getContentFile("lib"), System.mapLibraryName("astylej"))); + } + + private static void loadLib(File lib) { try { - System.load(astylePath); + System.load(lib.getAbsolutePath()); } catch (UnsatisfiedLinkError e) { e.printStackTrace(); System.out.println(e.getMessage()); - System.out.println("Cannot load native library " + astylePath); + System.out.println("Cannot load native library " + lib.getAbsolutePath()); System.out.println("The program has terminated!"); System.exit(1); }