@@ -663,22 +663,26 @@ private void checkWindowsDLLs(RunnerListener listener, File binary) throws Excep
663663 File binaryDir = new File (binary .getParent ());
664664 binaryDir .mkdirs ();
665665
666+ // DLL search dirs: bundled first, then WinLibs portable gcc, then MSYS2
667+ java .util .List <File > dllSources = new java .util .ArrayList <>();
668+ dllSources .add (bundledDir );
669+ File portableGccBin = InstallWizard .getPortableGccDir ();
670+ if (portableGccBin .exists ()) dllSources .add (portableGccBin );
671+ for (String msysDir : new String []{"C:\\ msys64\\ mingw64\\ bin" ,"C:\\ msys2\\ mingw64\\ bin" })
672+ dllSources .add (new File (msysDir ));
673+
666674 for (String dll : allDlls ) {
667- File src2 = new File (bundledDir , dll );
668- if (!src2 .exists ()) continue ;
669- // Copy next to binary
670- File dest = new File (binaryDir , dll );
671- try { java .nio .file .Files .copy (src2 .toPath (), dest .toPath (),
672- java .nio .file .StandardCopyOption .REPLACE_EXISTING );
673- } catch (Exception e ) {
674- System .err .println ("[CppMode] Failed to copy " + dll + ": " + e .getMessage ());
675+ for (File sourceDir : dllSources ) {
676+ File src2 = new File (sourceDir , dll );
677+ if (!src2 .exists ()) continue ;
678+ // Copy next to binary
679+ try { java .nio .file .Files .copy (src2 .toPath (), new File (binaryDir , dll ).toPath (),
680+ java .nio .file .StandardCopyOption .REPLACE_EXISTING ); } catch (Exception ignored ) {}
681+ // Copy to sketch folder
682+ try { java .nio .file .Files .copy (src2 .toPath (), new File (sketch .getFolder (), dll ).toPath (),
683+ java .nio .file .StandardCopyOption .REPLACE_EXISTING ); } catch (Exception ignored ) {}
684+ break ; // found in this source dir
675685 }
676- // Copy to sketch folder -- CppRunner sets sketch folder as cwd
677- // so Windows finds DLLs there at runtime
678- File sketchDest = new File (sketch .getFolder (), dll );
679- try { java .nio .file .Files .copy (src2 .toPath (), sketchDest .toPath (),
680- java .nio .file .StandardCopyOption .REPLACE_EXISTING );
681- } catch (Exception ignored ) {}
682686 }
683687
684688 // If all required DLLs exist in bundledDir, we're good -- they were
0 commit comments