ld cannot find shared libraries on non-ASCII paths in mingw64

Jan Beulich jbeulich@suse.com
Tue Nov 18 08:38:57 GMT 2025


On 15.11.2025 16:23, tuug@gmx.us wrote:
> Merely attempting to link a shared library with g++ results in this error message:
> $ g++ -lkernel32
> C:/Users/שזדס/scoop/apps/msys2/2025-08-30/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/15.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find C:/Users/שזדס/scoop/apps/msys2/2025-08-30/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/15.2.0/../../../../lib/crt2.o: No such file or directory◀

The path appearing correct (from all I can tell) in the error message makes me
wonder if this really is an issue with ld. And indeed potentially problematic
code lives in libbfd. _bfd_real_fopen() tries to convert the input string to
wchar_t[], using MultiByteToWideChar() and passing as the code page whatever
MinGW's ___lc_codepage_func() returns (but using hard-coded CP_UTF8 for e.g.
Cygwin). That's an aspect that needs checking on a MinGW installation (I use
Cygwin, so won't easily be able to.)

Following the MultiByteToWideChar() invocation there is indeed questionable
code, though: The loop assumes that it can index the wchar_t[] using the same
indexes that apply to filename[]. That's obviously not going to work when any
multi-byte UTF8 characters are present (as is the case for you). I should be
able to get you a patch for that; would you be able to actually give it a try
(on the hope that this is what is causing the issue for you)?

Jan


More information about the Binutils mailing list