Opened 7 years ago
Closed 7 years ago
#55273 closed defect (fixed)
wine: missing path to MinGW's libstdc++
Reported by: | mojca (Mojca Miklavec) | Owned by: | ryandesign (Ryan Carsten Schmidt) |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | ports | Version: | |
Keywords: | Cc: | casr (Chris Rawnsley), jeremyhu (Jeremy Huddleston Sequoia) | |
Port: | wine wine-devel wine-crossover |
Description
If users try to cross-compile binaries for Windows using MinGW-w64, they cannot run those binaries using Wine unless the binaries are compiled statically. On some IRC channel developers suggested:
Wine requires that the path be set in its own conf file (not
PATH
envvar) that points to wherever the c++ standard library is. At least on Linux.
and
you need something like
wine reg add HKCU\\Environment /v PATH /d "z:\\usr\\$PRE\\bin;z:\\usr\\local\\$PRE\\bin" /f
withPRE=i686-w64-mingw32
or similar
The relevant files are at:
/opt/local/i686-w64-mingw32/lib/libatomic-1.dll /opt/local/i686-w64-mingw32/lib/libgcc_s_sjlj-1.dll /opt/local/i686-w64-mingw32/lib/libgfortran-4.dll /opt/local/i686-w64-mingw32/lib/libobjc-4.dll /opt/local/i686-w64-mingw32/lib/libquadmath-0.dll /opt/local/i686-w64-mingw32/lib/libssp-0.dll /opt/local/i686-w64-mingw32/lib/libstdc++-6.dll
as well as under x86_64-w64-mingw32
, but I could not make 64-bit binaries work with our Wine anyway, so probably only the 32-bit is relevant.
Steps to reproduce:
$ cat hello.cpp #include <iostream> int main() { std::cout << "Hello world\n"; return 0; } $ sudo port install i686-w64-mingw32-gcc $ i686-w64-mingw32-g++ hello.cpp -o hello.exe $ wine hello.exe err:module:import_dll Library libstdc++-6.dll (which is needed by L"Z:\\tmpj\\hello.exe") not found err:module:LdrInitializeThunk Main exe initialization for L"Z:\\tmp\\hello.exe" failed, status c0000135
Change History (7)
comment:1 Changed 7 years ago by ryandesign (Ryan Carsten Schmidt)
Port: | wine-crossover added |
---|
comment:2 Changed 7 years ago by ryandesign (Ryan Carsten Schmidt)
Cc: | jeremyhu added |
---|
comment:3 follow-up: 6 Changed 7 years ago by raimue (Rainer Müller)
The mentioned registry key would be part of the wine prefix you are using. Even if the default PATH was changed, it would only affect new prefixes and do nothing for existing wine prefixes.
Do other Linux distributions really somehow set this by default? For reference, there are similar instructions for Fedora and Gentoo, which appear to be similar to the wine reg add
shown above and are required to be carried out by the user.
You could also experiment with DLL overrides via winecfg or WINEDLLOVERRIDES.
The easiest workaround is probably to just copy (or symlink?) the required DLLs right next to the .exe
and they should be found.
comment:4 Changed 7 years ago by mojca (Mojca Miklavec)
I believe it would be sufficient to provide clear notes, like for Retina display (which was very useful, even though a bit confusing and a number of other settings like font sizes were needed as well, so it would help to have a more extensive wiki entry somewhere anyway). At the moment the user doesn't even know what to do.
I'm also a bit worried that our paths are wrong. Both instructions have PATH
which ends with bin
rather than lib
. I wonder whether I used some wrong flags for building the gcc cross-compiler.
comment:5 Changed 7 years ago by mojca (Mojca Miklavec)
I addressed this in https://github.com/macports/macports-ports/pull/1048:
If you want your MinGW-generated windows binaries to work under wine out-of-the-box (and they are not statically linked), you can instruct wine to automatically search for dll-s by running: wine regedit Nagivate to: [HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment] or [HKEY_CURRENT_USER\Environment] and add Z:\opt\local\i686-w64-mingw32\bin to the 'PATH' variable.
I hope the text is OK. One could use wine reg add
, but I don't want infinitely long notes.
Suggestions welcome.
comment:6 Changed 7 years ago by mojca (Mojca Miklavec)
Replying to raimue:
The easiest workaround is probably to just copy (or symlink?) the required DLLs right next to the
.exe
and they should be found.
The easiest workaround is to build the binaries statically with
-static-libgcc -static-libstdc++
I didn't find a way to achieve the same with libpthreads
though.
Copying gets super annoying when running CMake or Meson with test cases. I don't want to worry about copying all the libraries to all the places where unit tests live.
Since most Wine users are unlikely to ever compile anything for windows under Mac, it makes more sense to add those notes to the cross-compiler than to wine. I only added them to i686
because we don't have support for 64-bit Windows yet.
comment:7 Changed 7 years ago by mojca (Mojca Miklavec)
Resolution: | → fixed |
---|---|
Status: | new → closed |
Sorry, I don't know what to do with this. If someone else does, please feel free to fix the affected ports.