I have a Windows-only game that can be extended by plugins and a Linux library I would like to use. The application (Unity game) runs fine under Wine/Proton. I've found that Winelib can do this, and I was following the User's Guide, notably the 5th section which mentions my exact use case.
After some attempts (like removing --single-target arg from winemaker), I got to the point where the Proton debug log keeps showing c000007b which seems to be STATUS_BAD_IMAGE_FORMAT.
Note that I renamed the Linux library (and linked against that), to avoid a potential conflict between that and my wrapper.
I only have a 64-bit version of the library and it is called from C# code using the cdecl calling convention. This is what I've tried so far (and combinations of these):
- Added a .spec file with contents (first without the -arch and with different ordinals):
1 cdecl -arch=x86_64 LibraryFunc (long ptr ptr) LibraryFuncWine
- Added the library's header and a .c file:
#include "library_header.h"
#include <windef.h> /* Part of the Wine header files */
enum ELibResult WINAPI LibraryFuncWine(Version version, struct CreateParams* params, struct ICore** result)
{
enum ELibResult ret = LibraryFunc(version, params, result);
return ret;
}
- Used winemaker as
winemaker --nosource-fix --dll --nomfc -I. -L. -llinux_library .
thenmake
- Copied the .dll.so file all around the game
- Copied the .dll.so file to steamapps/common/Proton 5.0/dist/lib64/wine/ and the native library to one level higher (lib64/) and removed the others
- Also tried to copy to lib/ instead of lib64/
- Added a dll override for the file and set it to builtin
- Removed the referenced DLLs (odbc32, ole32, oleaut32, winspool, odbccp32) and libraries (uuid) from the makefile
- Add
--mno-cygwin
to compiler flags - Add
-m64
and-fPIC
to compiler/linker flags (based on Wine spec files) - I've also tried making a .def file and using that
- Used winemaker again with the
--nomsvcrt
argument added and ranmake
(the header file includes string.h)
From the Proton log (+module, the others didn't provide any more info for me):
00dc:trace:module:load_dll looking for L"Z:\\D\\a\\library\\path\\library_name" in L"Z:\\D\\gamepath;C:\\windows\\system32;C:\\windows\\system;C:\\windows;C:\\Program Files (x86)\\Steam;.;C:\\windows\\system32;C:\\windows;C:\\windows\\system32\\wbem;C:\\windows\\system32\\WindowsPowershell\\v1.0"
00dc:trace:module:get_load_order looking for L"Z:\\D\\a\\library\\path\\library_name.dll"
00dc:trace:module:get_load_order_value got standard key b for L"library_name"
00dc:trace:module:load_builtin_dll Trying built-in L"library_name.dll"
00dc:trace:module:load_so_dll loading L"\\??\\Z:\\D\\a\\library\\path\\library_name.dll" from so lib "/D/Games/SteamLibrary/steamapps/common/Proton 5.0/dist/bin/../lib64/wine/library_name.dll.so"
00dc:warn:module:load_dll Failed to load module L"Z:\\D\\a\\library\\path\\library_name"; status=c000007b
The same is repeated with and without .dll and starting with lib (library_name.dll, liblibrary_name and liblibrary_name.dll).
I was unable to get any more logs on what exactly goes wrong besides that error code.
On the C# side (ran by Unity in Proton) it results in a DllNotFoundException.
Wine version (winebuild, winegcc): 5.9 (staging) - gcc 9.0.1
Proton version: 5.0 - wine-5.0-603-g068dee4