Skip to content

Commit 53987f9

Browse files
author
Federico Fissore
committed
Windows: msvc*.dll are not found when loading AStyle.dll. Forcing load.
Fixes #4076
1 parent 90f09e9 commit 53987f9

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

app/src/cc/arduino/packages/formatter/AStyleInterface.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,27 @@
3030
package cc.arduino.packages.formatter;
3131

3232
import processing.app.Base;
33+
import processing.app.helpers.OSUtils;
3334

3435
import java.io.File;
3536

3637
public class AStyleInterface {
3738

3839
static {
39-
File astyleLib = new File(Base.getContentFile("lib"), System.mapLibraryName("astylej"));
40-
String astylePath = astyleLib.getAbsolutePath();
40+
if (OSUtils.isWindows()) {
41+
loadLib(Base.getContentFile(System.mapLibraryName("msvcp100")));
42+
loadLib(Base.getContentFile(System.mapLibraryName("msvcr100")));
43+
}
44+
loadLib(new File(Base.getContentFile("lib"), System.mapLibraryName("astylej")));
45+
}
46+
47+
private static void loadLib(File lib) {
4148
try {
42-
System.load(astylePath);
49+
System.load(lib.getAbsolutePath());
4350
} catch (UnsatisfiedLinkError e) {
4451
e.printStackTrace();
4552
System.out.println(e.getMessage());
46-
System.out.println("Cannot load native library " + astylePath);
53+
System.out.println("Cannot load native library " + lib.getAbsolutePath());
4754
System.out.println("The program has terminated!");
4855
System.exit(1);
4956
}

0 commit comments

Comments
 (0)