native dll's: Where should I place them?

Questions about Wine on Linux
Post Reply
Opako
Level 2
Level 2
Posts: 13
Joined: Mon Jun 08, 2020 9:23 am

native dll's: Where should I place them?

Post by Opako » Sat Jun 13, 2020 3:02 am

Hello,

When I want to override a dll in the library tab, and this native dll is not already in my wine prefix, then I have to copy it into it.

Question:
Where should I place this native dll?
I guess, in system32 is not the right place, because here is already the builtin dll with the same name and I do not want to delete the builtin dll, because sometimes I want to override it with "native, builtin" in library tab.

So where do you experienced wine-users place your native dll's?

Thank you.

jkfloris
Level 7
Level 7
Posts: 993
Joined: Thu Aug 14, 2014 10:10 am

Re: native dll's: Where should I place them?

Post by jkfloris » Sat Jun 13, 2020 3:36 pm

From the Wine Wiki:
DLLs usually get loaded in the following order:
  • The directory the program was started from.
  • The current directory.
  • The Windows system directory.
  • The Windows directory.
  • The PATH variable directories.
In other words, option 1: put the dll in the same directory as the exe.

Opako
Level 2
Level 2
Posts: 13
Joined: Mon Jun 08, 2020 9:23 am

Re: native dll's: Where should I place them?

Post by Opako » Sun Jun 14, 2020 5:40 am

Thank you @jkfloris.

Opako
Level 2
Level 2
Posts: 13
Joined: Mon Jun 08, 2020 9:23 am

Re: native dll's: Where should I place them?

Post by Opako » Sun Jun 21, 2020 3:09 am

1) I uderstand what is meant with "The directory the program was started from". This is the path where the exe was.

2) But I do not understand what is meant with "the current directory". Which is the current directory? When I have installed microsoft word: Which is now the current directory?

3) "The Windows directory". I guess you mean this one:
~/.local/share/wineprefixes/Wine MS Office/drive_c/windows/
Right?

4) I do not understand what is meant with "The windows system directory."
This: ~/.local/share/wineprefixes/Wine MS Office/drive_c/windows/system
or this: ~/.local/share/wineprefixes/Wine MS Office/drive_c/windows/system32

5) I do not understand "The PATH variable directories".
What is this? Where is this? For example if I have installed MS Word.

Thank you.

Cybermax
Level 4
Level 4
Posts: 212
Joined: Fri Dec 01, 2017 5:26 pm

Re: native dll's: Where should I place them?

Post by Cybermax » Fri Jun 26, 2020 6:08 am

2: Not really sure, but sometimes programs can load sub-programs from other directories. Example: When you run Battle.net, and THEN click "Run" on a game, it could be that the "current directory" is then the folder where Battle.net is installed, even tho the .exe you are starting from the "launcher" is in a different folder. This is a wee bit tricky, and usually fails, as there is no clear indication of where the "current directory" is tbh. (See also #4 below)
I am fairly sure if you put a .dll in the folder where "Word.exe" is, it will not be used if you just put "Native", as it might not be seen from the program launcher - Office then might start the actual word.exe "from" a different space.

To further elaborate this, i would HIGHLY recommend making separate wineprefixes for each program/game, as having eg. Office + Steam/Battle.net or whatever on the SAME prefix + dabbling with various .dll overrides messes things up. Sure there are application profiles you can use in the winecfg settings, but it is not recommended tbh (unless you absolutely have to). Both from personal experience, and per recommendation from WineHQ.

3. Yes, given that your wineprefix actually is called "Wine MS Office"

4. Depends. There are 2 "system directories" on default 64-bit wine/windows. The system directories are (using your example):
~/.local/share/wineprefixes/Wine MS Office/drive_c/windows/system32 (for 64-bit .dll's)
~/.local/share/wineprefixes/Wine MS Office/drive_c/windows/syswow64 (for 32-bit dll's).

This means if you start a 32-bit program located in eg. ~/.local/share/wineprefixes/Wine MS Office/drive_c/Program Files (x86)/My Program/Program.exe it will read its 32-bit dll's from ~/.local/share/wineprefixes/Wine MS Office/drive_c/windows/syswow64. If however this is "pure" 64-bit program it would probably be located in ~/.local/share/wineprefixes/Wine MS Office/drive_c/Program Files/My Program/Program.exe , and read its dll's from ~/.local/share/wineprefixes/Wine MS Office/drive_c/windows/system32.
A lot of programs are kinda semi 32/64-bit so some bits might be 32-bit, and some bits might be 64-bit (typical game launchers and stuff, that the launcher itself is 32-bit, but launches a 64-bit .exe). This is also a thing that might make the overrides i explained in #2 above a bit tricky. Cos if you put a 32-bit .dll in the same folder as the .exe, and it THEN launches a 64-bit program you are bound to have problems.

5. The "PATH" variable works much the same way as in Linux. Environmental variable you can set. Not really used that much, so i cannot say the order Wine/Windows uses the PATH variable when loading dll's.

Safest and most successfully working is to use the "system directories" ref. #3. Put your custom dll's in their respective 64 and 32-bit system folders, and override. Usually scripts like winetricks do this correctly, but as i said above, if you install multiple programs in the same wineprefix this might lead to trouble down the road.

Opako
Level 2
Level 2
Posts: 13
Joined: Mon Jun 08, 2020 9:23 am

Re: native dll's: Where should I place them?

Post by Opako » Fri Jun 26, 2020 8:32 am

Thanks for the detailed information.
Safest and most successfully working is to use the "system directories" ref. #3.
This is another question:
When I put my native dll into system32, then it looks like the builtin dll then is deleted, because they have the same name. Even when I make this with winetricks.

But what is, when I nevertheless want to set this "dll" to "native, builtin" in winecfg ?

I guess this would not work, because the builtin is deleted now. (?)
Strange.

As wine gives the possibility to set a dll in winecfg to "native, builtin", I would expect a folder, where I can put my native dlls in, without having to worry about deleting the builtin version.

spoon0042
Level 5
Level 5
Posts: 304
Joined: Thu Dec 24, 2009 11:00 am

Re: native dll's: Where should I place them?

Post by spoon0042 » Sun Jun 28, 2020 1:12 pm

afaik wine doesn't actually use the dlls in $WINEPREFIX/drive_c/windows if those are set to 'builtin' but rather the installed wine dlls -- /opt/wine-*/lib and /opt/wine-*/lib64 if you're using winehq packages. So you don't have to worry about overwriting anything.

Post Reply