Include X11 on Mac

Questions about Wine on macOS.
Locked
fedorawins
Newbie
Newbie
Posts: 3
Joined: Tue May 24, 2011 11:08 pm

Include X11 on Mac

Post by fedorawins »

Good day,

I wanted to ask if there is a way to include either X11 or XQuartz into a custom compiled wine? The idea is that the program will run whether or not the user has XQuartz installed. Basically a fallback that will be included with the .app that holds the wine binaries.

I am new to Mac and I had some success but I want to understand it more, where the config files of the included XQuartz are and so on and of course what the right way is to include XQuartz.

Thanks for any help,
fedorawins aka James
jjmckenzie
Moderator
Moderator
Posts: 1153
Joined: Wed Apr 27, 2011 11:01 pm

Include X11 on Mac

Post by jjmckenzie »

On 5/24/11 9:13 PM, fedorawins wrote:
Good day,

I wanted to ask if there is a way to include either X11 or XQuartz into a custom compiled wine? The idea is that the program will run whether or not the user has XQuartz installed. Basically a fallback that will be included with the .app that holds the wine binaries.
Wineskin includes a customized X11.
MacOSX Snow Leopard (10.6 series) has Apple's X11 installed. Leopard
does not, but it is on the distribution DVD.
I am new to Mac and I had some success but I want to understand it more, where the config files of the included XQuartz are and so on and of course what the right way is to include XQuartz.
/opt/X11 is where XQuartz installs to.

James McKenzie
fedorawins
Newbie
Newbie
Posts: 3
Joined: Tue May 24, 2011 11:08 pm

Post by fedorawins »

Thanks for the answer. I rather not use other's work as I want to understand it.

So to package XQuartz for users who did not install it I need to copy it out of /opt/X11 and put it inside my app. Is export LD_LIBRARY_PATH the right one or do I need to use DYLD_FALLBACK_LIBRARY_PATH with wine to make it not look into /opt/X11 (where it won't be) but rather in the packaged directory?

Thank you,
fedorawins aka James
doh123
Level 8
Level 8
Posts: 1227
Joined: Tue Jul 14, 2009 1:21 pm

Post by doh123 »

fedorawins wrote:Thanks for the answer. I rather not use other's work as I want to understand it.

So to package XQuartz for users who did not install it I need to copy it out of /opt/X11 and put it inside my app. Is export LD_LIBRARY_PATH the right one or do I need to use DYLD_FALLBACK_LIBRARY_PATH with wine to make it not look into /opt/X11 (where it won't be) but rather in the packaged directory?

Thank you,
fedorawins aka James
This is not easy... it took me a looong time to figure out how to get it all to work to make Wineskin...

If you really want to try, I can give you a couple clues to lead the way. Xquartz needs to have a static location. It has parts (mainly xkb) that cannot run from a location that can change from computer to computer. I build all of WineskinX11 My customized Xquartz for Wineskin) to run out of /tmp/Wineskin, since everyone has a fully read/write /tmp folder, and making symlinks is easy. I also modify the executables and dylibs to run off an @executable_path instead of a set location, so only a couple of things actually look at that location during start up.... look into using install_name_tool for that type of modification.... you'd have to build Xquartz yourself, not use a preinstalled copy, because the parts that are hard complied for location will always go back to /opt/X11, and use the files if a user has them on their machine. This might not be a problem today, but int he future it may be as versions and incompatibilities between what is in the app and what is in /opt/X11 come about.... if the user doesn't have /opt/X11/lib at all on their machine, then it will always check the DYLD_FALLBACK_LIBRARY_PATH. Just trying to set the entire library path yourself and not just the fallback can be majorly painful... but go ahead and try if you'd like.

Wineskin is LGPL open source licensed (http://sourceforge.net/projects/wineskin/)... you can always get the source and take a look if you just want to know how it works. You'd really only need to look at the Wineskin.m file, as it handles how the wrapper works, starting up X11 and Wine and everything... You'd have to look at the actual files for Xquartz in a WineskinEngine.bundle in a wrapper and how I modify them after compiling (with otool). The patch files I use to modify the Xquartz source code I haven't made available, but has really no bearing on just bundling Xquartz to use it. For a long time Wineskin used completely unmodified Xquartz...

But really a major point of me making Wineskin is so its easy to do for other people, not so everyone can re-create the wheel :-) If you just want custom Wine builds, Wineskin supports making your own custom engines from Wine source as well.
fedorawins
Newbie
Newbie
Posts: 3
Joined: Tue May 24, 2011 11:08 pm

Post by fedorawins »

Thank you, is that Apple's C language? I see a lot of C mixed with something other.

But basically, without rewriting anything, can I compile Wine and use it with the X11 lib that was installed into /opt/X11 or do I miss something?

Would be great if you could tell me what you did (at a high level) to combine Wine with unmodified XQuartz and how you set the PATH to use the correct libs.

Thanks for any help,
fedorawins aka James
doh123
Level 8
Level 8
Posts: 1227
Joined: Tue Jul 14, 2009 1:21 pm

Post by doh123 »

fedorawins wrote:Thank you, is that Apple's C language? I see a lot of C mixed with something other.

But basically, without rewriting anything, can I compile Wine and use it with the X11 lib that was installed into /opt/X11 or do I miss something?

Would be great if you could tell me what you did (at a high level) to combine Wine with unmodified XQuartz and how you set the PATH to use the correct libs.

Thanks for any help,
fedorawins aka James
Its Objective C, so there is some C code in there for things that work better that way, though most of it is all ObjC/Cocoa.

If Wine starts up it will launch Mac OS X default X11... so you need to manually have it launch the X11 you want, then only start up Wine in that X11...

There are 2 methods/functions to look at in Wineskin.m to see how Wineskin starts up.
- (NSString *)startX11;
- (NSString *)startWine;
if you know ObjC code you should be able to figure out how its starting up X11 and how its starting up Wine. The "WineskinX11" program its calling in normal Xquartz.app is the actual "X11.bin" file in its MacOS folder. You basically start up X11 under a certain $DISPLAY setting, and then when you start up Wine, make sure its set for the same $DISPLAY value. Just remember that Xquartz runs partially from /opt/X11 and also the actual Xquartz.app.

The problems to how all the dylibs and executables are linked to look for the others... thats where using otool on them to see what they are, and install_name_tool to modify them is all about. Wine itself is the easiest part of all this.
Locked