0

quick question: is it safe to have both ming32 and ming64 runtimes in path?

As they are 32 vs. 64 I would guess dlls would not clash and properly resolved in both cased, but maybe I am missing something.

FYI: It works in fact on my computer, I am just not sure about the theory.

1 Answers1

0

The rule is simple, Win will attempt to locate:

  • Executables (when not launched with full path)
  • DLLs (loaded (recursively) by executables)

in the directories from %PATH% in the order that they appear.

References:

A MinGW version is stand alone (it doesn't depend on the other), so if all its dirs are in %PATH%, it will be chosen automatically, and the 2nd version is simply going be ignored therefore its presence in %PATH% is useless (actually, it will add additional overhead when the OS will search those dirs too).
However, if dirs from the 2 versions are inserted interleavedly (some dirs from 1st version, some from 2nd version, some other dirs from 1st version, ...), then you might (and most likely will) get in trouble, so don't do it.

I guess you need both variants to generate 064bit and 032bit binaries. But doesn't GCC's -m32 argument do the trick?

In short: there are some situations when it's OK (to have both versions in %PATH%), there are others when it's not. But, in any case, having the 2nd version will come with no benefit.

On a related topic, check [SO]: Python Ctypes - loading dll throws OSError: [WinError 193] %1 is not a valid Win32 application (@CristiFati's answer) for details about mixing processes and .dlls built for different architectures.

CristiFati
  • 38,250
  • 9
  • 50
  • 87
  • that's exactly what I though first - but then: 64bit and 32bit dlls are incompatible as they cannot be used in the same process - hence the 64 bit binary will ignore the available 32 bit dlls even if they are first in the path, and vica versa, wont they? that's actually what I am curious about – Arvid Terzibaschian Dec 22 '21 at 09:37
  • When it will find one, it will attempt to load it. In case of failure, it won't try to load it from somewhere else (search subsequent *dir*s), but it will throw an error (https://stackoverflow.com/questions/57187566/python-ctypes-loading-dll-throws-oserror-winerror-193-1-is-not-a-valid-win/57297745#57297745). – CristiFati Dec 22 '21 at 10:49
  • thanks for clarification - yep seems it fails when name matches but wordsize does not. so I guess I am just lucky I that specific case – Arvid Terzibaschian Dec 22 '21 at 19:39