Standalone Wine for console Win32 executables

Open forum for end-user questions about Wine. Before asking questions, check out the Wiki as a first step.
Forum Rules
Locked
FamilyGuy
Level 2
Level 2
Posts: 10
Joined: Tue Apr 12, 2011 3:19 pm

Standalone Wine for console Win32 executables

Post by FamilyGuy »

Hi,

First of all, I've searched for a while about this topic both on google and using the search form of this forum before posting and couldn't find anything, so I'm asking it here in the hope someone knows the answer.

I have a lot of simple old console executables for windows that I'd like to execute under Linux using bash scripts. They work well with Wine, but I'd like my scripts to work even if wine isn't installed. I don't have access to the sourcecode of these executables, and I can't reverse engineer them because of a lack of skills on the topic.
So I was wondering if there's any way to get a minimalistic wine build that would be standalone and could be used to launch a win32 console program with a command line similar to this: ./winestandalone win32program
I'd like to avoid dependencies for anything else than what's in the working directory. I don't care if I have to include libraries as well, as long as it works from a usb-drive under Ubuntu without wine installed.

I know something similar exists for OSX, it's called WineBottler.

Thank you very much!

FG
doh123
Level 8
Level 8
Posts: 1227
Joined: Tue Jul 14, 2009 1:21 pm

Post by doh123 »

with Wineskin (Mac OS X) I have to put basically everything Wine may need including Wine all in a folder... this is mainly tons of libraries... this ends up being close to 300 files, mainly since I have to have a full X server as well... you'll have to get it all handled right so the libraries look for other libraries in the right places, etc... not sure how to do that on Linux, but it must be possible.
FamilyGuy
Level 2
Level 2
Posts: 10
Joined: Tue Apr 12, 2011 3:19 pm

Post by FamilyGuy »

Thank you for this quick reply, it's fun to know it's at least doable under OSX.

Furthermore, I'm not even looking for a full-featured "standalone" wine, I "only" want it to executes old and simple win32 exes in console mode.

If someone could point me out to which files I'd need or if it's possible at all to do considering how wine works on windows I'd greatly appreciat

Thank you very much!

FG
Thunderbird
Level 5
Level 5
Posts: 336
Joined: Mon Nov 24, 2008 8:10 am

Post by Thunderbird »

That heavily depends on what dlls your program needs. Using WINEDEBUG=+loaddll you can see what dlls it needs. You can get rid of most then. Note that even console applications are usually not pure console applications and you would need X11..
FamilyGuy
Level 2
Level 2
Posts: 10
Joined: Tue Apr 12, 2011 3:19 pm

Post by FamilyGuy »

I'll check what WINEDEBUG outputs and post it once I'll have access to my Linux computer.

I really think it would work without X11, it's a 1997 exe with it's own dll that comes with it.

Does anyone know what is the bare minimum wine files needed to execute a "hello world" compiled under windows with g++?

Thank you very much for the support!

FG
oiaohm
Level 8
Level 8
Posts: 1020
Joined: Fri Feb 29, 2008 2:54 am

Post by oiaohm »

A true console hello world built with g++ for windows runs perfectly without X11.

I am sorry to say FamilyGuy 1997 exe more often than not would have used wmain so activate a window hidden. So not really console.

WINEDEBUG=+loaddll Truely does tell you the answers familyguy
FamilyGuy
Level 2
Level 2
Posts: 10
Joined: Tue Apr 12, 2011 3:19 pm

Post by FamilyGuy »

Here's what WINEDEBUG=+loaddll wine program.exe outputs:

Code: Select all

trace:loaddll:load_builtin_dll Loaded L"KERNEL32.dll" at 0x7b810000: builtin
trace:loaddll:load_native_dll Loaded L"Z:\\home\\me\\Desktop\\program.exe" at 0x400000: native
trace:loaddll:load_builtin_dll Loaded L"C:\\windows\\system32\\msvcrt.dll" at 0x681c0000: builtin
trace:loaddll:load_native_dll Loaded L"Z:\\home\\me\\Desktop\\program.dll" at 0x10000000: native
So the only wine dlls needed seems to be KERNEL32.dll, which is not a surprise, and msvcrt.dll, am I right?
Now how could I create a smallish "portable" wine with only those dlls? By portable I mean that I could use it from a thumb drive on a pc with linux, but without wine.

Thank you all for the support again,

FG
User avatar
DanKegel
Moderator
Moderator
Posts: 1164
Joined: Wed May 14, 2008 11:44 am

Re: Standalone Wine for console Win32 executables

Post by DanKegel »

FamilyGuy wrote: So I was wondering if there's any way to get a minimalistic wine build that would be standalone and could be used to launch a win32 console program with a command line similar to this: ./winestandalone win32program
I'd like to avoid dependencies for anything else than what's in the working directory. I don't care if I have to include libraries as well, as long as it works from a usb-drive under Ubuntu without wine installed.
So you're looking for Portable Wine, I guess.

Here's how to strip it down to just the files needed:
strace -e trace=open -o files.log -f wine myexe.exe
grep -v ENOENT files2.log | grep -v home | sed 's/.*("//;s/",.*//' | grep / | sed 's,/bin/\.\.,,' | grep wine | sort -u > files.txt

files.txt contains just the needed files.

To make this portable, you need to do that on an uninstalled
copy of wine (in the source tree where it was built).

Et voila!
FamilyGuy
Level 2
Level 2
Posts: 10
Joined: Tue Apr 12, 2011 3:19 pm

Re: Standalone Wine for console Win32 executables

Post by FamilyGuy »

Here's the file.txt I get:

Code: Select all

/usr/bin/wine
/usr/lib/libwine.so.1
/usr/lib/wine/kernel32.dll.so
/usr/lib/wine/msvcrt.dll.so
/usr/lib/wine/ntdll.dll.so
DanKegel wrote:To make this portable, you need to do that on an uninstalled copy of wine (in the source tree where it was built).
I don't understand that part sorry. Do I only need to copy these files next to my executable and run wine myexe.exe or am I missing something?

Again, I'm impressed by the support, thank you guys!

FG
doh123
Level 8
Level 8
Posts: 1227
Joined: Tue Jul 14, 2009 1:21 pm

Post by doh123 »

the problem with just taking a minimal Wine install.. is assuming that the dependencies it needs are already installed on the machine its going to be running on.... i'm talking about stuff like freetype or libjpeg or whatever, not just Wine.

If you just want Wine, you can always build from source setting a different prefix (./configure --prefix=<where to install wine>) for install then when you do the make install it will install it to the folder you specified as a prefix, and you have just Wine in that folder and usable now... even copied from machine to machine, so you'd probably just want to add it as is in a Wine folder along with your program.. then a script that launches by adding the CurrentFolder/Wine/bin to the front of $PATH, then doing wine name.exe to launch.... but you can run into tons of problems between distros and what dependencies they have and where they might put them, and what versions they are.

If you really want to make sure it will never have a problem, you need to get copies of all the libraries that are dependencies and have portable copies of them, and set LD library paths and stuff so it uses the right ones and junk like that, which can get very complicated and confusing.
FamilyGuy
Level 2
Level 2
Posts: 10
Joined: Tue Apr 12, 2011 3:19 pm

Post by FamilyGuy »

This would be a problem for a wide-use intended wine portable. While my goal is to run two or three very very very simple binaries. As show by WINEDEBUG=+loaddll wine program.exe the dependencies seems to be KERNEL32.DLL, msvcrt.dll and a dll that goes with the program.

Correct me if I'm wrong.

I'd like a small insight to how to finish the portable stripped-down wine version I need, I don't quite understand what DanKegel meant by:
To make this portable, you need to do that on an uninstalled
copy of wine (in the source tree where it was built).
Thank you,

FG
John Drescher

Standalone Wine for console Win32 executables

Post by John Drescher »

On Wed, Apr 13, 2011 at 1:20 PM, FamilyGuy <[email protected]> wrote:
This would be a problem for a wide-use intended wine portable. While my goal is to run two or three very very very simple binaries. As show by WINEDEBUG=+loaddll wine program.exe the dependencies seems to be  KERNEL32.DLL, msvcrt.dll and a dll that goes with the program.

Correct me if I'm wrong.

I'd like a small insight to how to finish the portable stripped-down wine version I need, I don't quite understand what DanKegel meant by:
To make this portable, you need to do that on an uninstalled
copy of wine (in the source tree where it was built).
He meant do not use the distribution package. Uninstall that. Build
wine from source then do not do the install stage and run your above
command to produce the list.

John
FamilyGuy
Level 2
Level 2
Posts: 10
Joined: Tue Apr 12, 2011 3:19 pm

Post by FamilyGuy »

Oh, I see. It'll take some more time then ...
I'll report once done!

Thank you all!

FG
FamilyGuy
Level 2
Level 2
Posts: 10
Joined: Tue Apr 12, 2011 3:19 pm

Post by FamilyGuy »

Ok, so I've compiled wine from sources but I haven't installed it:

Code: Select all

./configure
make depend
make
Now wine works using the "wine" script found in the main folder of the sources, or using the loader/wine executable. However when I do these commands:

Code: Select all

strace -e trace=open -o files.log -f ./wine myexe.exe 
grep -v ENOENT files.log | grep -v home | sed 's/.*("//;s/",.*//' | grep / | sed 's,/bin/\.\.,,' | grep ./wine | sort -u > files.txt 
The resulting files.txt is empty if ran from loader/wine, or only contains ./wine, if ran from main folder script.

Maybe there's a modification to make to those commands to fit a portable install, it was spitting filenames out when I tried it with a installed version of wine.

Also, how is it possible to separate the compiled files from the sources without installing wine with make install?

Thank you very much!

FG
James McKenzie

Standalone Wine for console Win32 executables

Post by James McKenzie »

On 4/15/11 6:28 AM, FamilyGuy wrote:
Ok, so I've compiled wine from sources but I haven't installed it:

Code:
./configure
make depend
make


Now wine works using the "wine" script found in the main folder of the sources, or using the loader/wine executable. However when I do these commands:

Code:
strace -e trace=open -o files.log -f ./wine myexe.exe
grep -v ENOENT files.log | grep -v home | sed 's/.*("//;s/",.*//' | grep / | sed 's,/bin/\.\.,,' | grep ./wine | sort -u> files.txt


The resulting files.txt is empty if ran from loader/wine, or only contains ./wine, if ran from main folder script.
The grep ./wine is why...

I may have time to look at this today and provide a solution to what you
need. However, don't count on it.

James McKenzie
doh123
Level 8
Level 8
Posts: 1227
Joined: Tue Jul 14, 2009 1:21 pm

Post by doh123 »

why didn't you just do a ./configure --prefix=$HOME/Desktop/temp or something so 'make install' would have put it all there... then you have just Wine and nothing else in that temp folder, and you can pull out any extra Wine stuff you don't need for the particular program.
FamilyGuy
Level 2
Level 2
Posts: 10
Joined: Tue Apr 12, 2011 3:19 pm

Post by FamilyGuy »

I just got it working. Here's the files I kept:

Code: Select all

dlls  libs  loader  programs  server  mydll.dll  myexe.exe  tools  wine

./dlls:
advapi32  kernel32  msvcrt  ntdll

./dlls/advapi32:
advapi32.dll.so

./dlls/kernel32:
kernel32.dll.so

./dlls/msvcrt:
msvcrt.dll.so

./dlls/ntdll:
ntdll.dll.so

./libs:
wine

./libs/wine:
libwine.so.1

./loader:
wine  wine-preloader

./programs:
wineboot

./programs/wineboot:
wineboot.exe.so

./server:
wineserver

./tools:
winewrapper
It stills have some errors when launching my program because of missing dlls, but it works anyway for my program. Is there anyway to stop wine from outputting errors?

Thank you all for your support!

FG
User avatar
DanKegel
Moderator
Moderator
Posts: 1164
Joined: Wed May 14, 2008 11:44 am

Post by DanKegel »

Hey, that's pretty minimal!

You can suppress Wine errors with WINEDEBUG=-all

See
http://wiki.winehq.org/FAQ#head-51e2c09 ... e97170c503
FamilyGuy
Level 2
Level 2
Posts: 10
Joined: Tue Apr 12, 2011 3:19 pm

Post by FamilyGuy »

Hi again,

WINEDEBUG=-all didn't do the trick, so I added the files that caused error messages but that were not required for my executables. My minimalistic (11.5MiB) portable wine setup is now:

Code: Select all

wine:
dlls  libs  loader  programs  server  wine

wine/dlls:
advapi32  kernel32  msvcrt  ntdll  rpcrt4

wine/dlls/advapi32:
advapi32.dll.so

wine/dlls/kernel32:
kernel32.dll.so

wine/dlls/msvcrt:
msvcrt.dll.so

wine/dlls/ntdll:
ntdll.dll.so

wine/dlls/rpcrt4:
rpcrt4.dll.so

wine/libs:
wine

wine/libs/wine:
libwine.so.1

wine/loader:
wine  wine-preloader

wine/programs:
services  wineboot

wine/programs/services:
services.exe.so

wine/programs/wineboot:
wineboot.exe.so

wine/server:
wineserver
The file named wine in the main folder is the winewrapper. I modified it to run my portable wine in its own prefix in order to avoid problem with a hypothetical wine install. I used this command: export WINEPREFIX=$HOME/.wine-portable/

Now I got 2 small problems.
1) I can't find how to delete ~/.wine-portable/ using the wrapper (for those who might want to check the wrapper is the /tools/winewrapper/ files in the wines sources)
No matter where I insert a rm -r $HOME/.wine-portable command it does not get executed.

2) It always output this error: wine: failed to update /home/user/.wine-portable with /home/user/Desktop/test3/wine/loader/../tools/wine.inf: No such file or directory

Any help would be greatly appreciated!

Thank you in advance!

FG
Locked