Skip to content

Commit b2e8ea1

Browse files
committed
Windows: run exe from sketch folder where DLLs are copied
1 parent 01a0c52 commit b2e8ea1

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

mode/CppMode.jar

260 Bytes
Binary file not shown.

src/java/CppRunner.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,19 @@ public void launch() {
2121
binary.setExecutable(true);
2222
new Thread(() -> {
2323
try {
24-
ProcessBuilder pb = new ProcessBuilder(binary.getAbsolutePath());
24+
// On Windows, copy exe to sketch folder and run from there
25+
// so DLLs copied alongside it are found
26+
File exeToRun = binary;
27+
String osName2 = System.getProperty("os.name","").toLowerCase();
28+
if (osName2.contains("win")) {
29+
File exeCopy = new File(sketchFolder, binary.getName());
30+
try {
31+
java.nio.file.Files.copy(binary.toPath(), exeCopy.toPath(),
32+
java.nio.file.StandardCopyOption.REPLACE_EXISTING);
33+
exeToRun = exeCopy;
34+
} catch (Exception ignored) {}
35+
}
36+
ProcessBuilder pb = new ProcessBuilder(exeToRun.getAbsolutePath());
2537
pb.directory(sketchFolder);
2638
pb.redirectErrorStream(false);
2739
// Pass sketch folder so loadImage/loadStrings find data/ assets

0 commit comments

Comments
 (0)