VOGONS


Compile SVN in macOS?

Topic actions

Reply 100 of 172, by Dominus

User metadata
Rank DOSBox Moderator
Rank
DOSBox Moderator

Generally building static is frowned upon when building for Apple and Apple especially made it hard on purpose to do so. In *theory* you can just exchange bundled dylibs with newer ones (if the version reported matches (the one you see with otool)).
Then there are things like munt that don't provide a static lib right away (no problem when you do your own prefix but once you rely on a package manager you only get dylibs) or the monster fluidsynth that pulls in a lot of libraries and if I understood correctly one of those (glib2) won't work correctly if compiled in statically.
Not to mention that patching or changing the makefile is always risky or prone to fail (maybe even silently because a new dylib dependency of one of the libs) and that's annoying for my buildbot workflow 😀

So for my big other project (Exult) I've abandoned static and with the workflow of dylibbundler it's easy to bundle.

Windows 3.1x guide for DOSBox
60 seconds guide to DOSBox
DOSBox SVN snapshot for macOS (10.4-11.x ppc/intel 32/64bit) notarized for gatekeeper

Reply 102 of 172, by almeath

User metadata
Rank Member
Rank
Member
Dominus wrote on 2021-03-11, 22:07:
Generally building static is frowned upon when building for Apple and Apple especially made it hard on purpose to do so. In *the […]
Show full quote

Generally building static is frowned upon when building for Apple and Apple especially made it hard on purpose to do so. In *theory* you can just exchange bundled dylibs with newer ones (if the version reported matches (the one you see with otool)).
Then there are things like munt that don't provide a static lib right away (no problem when you do your own prefix but once you rely on a package manager you only get dylibs) or the monster fluidsynth that pulls in a lot of libraries and if I understood correctly one of those (glib2) won't work correctly if compiled in statically.
Not to mention that patching or changing the makefile is always risky or prone to fail (maybe even silently because a new dylib dependency of one of the libs) and that's annoying for my buildbot workflow 😀

So for my big other project (Exult) I've abandoned static and with the workflow of dylibbundler it's easy to bundle.

Yes, I guess that all makes sense. It would actually be harder than patching the make files if were not for the availability of the dylib bundler program. Otherwise, it would all have to be done manually with install_name_tool, and that could take a long time with libraries like fluidsynth.

I have used the amended command you gave me to fix my current app package. It now has the Glide libraries in /lib but of course, it still fails to look inside the wrapper due to the underlying issue with the OpenGlide code.. at least for now I have done all I can with it. A few weeks ago I thought it was impossible to get OpenGlide working at all, so I am happy with the progress thus far.

@emendelson - thanks for the intense effort on the script this week .. I will give it a try over the weekend.

DOSBox SVN for macOS (x86-64) - customized with Munt MT-32, Nuked OPL3, 3dfx Voodoo, Extra RAM, Large HD, and more.
https://github.com/almeath/DOSBox-SVN-64-bit-for-macOS

Reply 103 of 172, by almeath

User metadata
Rank Member
Rank
Member

@emendelson - I did a quick test with your script on my Mojave system and it appears to work perfectly. I will try it on my Big Sur install and report back soon as possible.

@Dominus - I have solved the dylib location problem with OpenGlide. I will type up how I did it and report back as well.

DOSBox SVN for macOS (x86-64) - customized with Munt MT-32, Nuked OPL3, 3dfx Voodoo, Extra RAM, Large HD, and more.
https://github.com/almeath/DOSBox-SVN-64-bit-for-macOS

Reply 104 of 172, by Dominus

User metadata
Rank DOSBox Moderator
Rank
DOSBox Moderator

Ooohh good news!

Windows 3.1x guide for DOSBox
60 seconds guide to DOSBox
DOSBox SVN snapshot for macOS (10.4-11.x ppc/intel 32/64bit) notarized for gatekeeper

Reply 105 of 172, by almeath

User metadata
Rank Member
Rank
Member

The issue with OpenGlide is it insists on looking for its own copy of SDL1, and ignores the one already packaged into my app wrapper with dylibbundler.

So, I started by making a fresh non-static build of my patched SVN source, packing that into my custom app wrapper, and installing the standard dylib dependencies with dylibbundler.

My wrapper contains a launcher binary that calls a shell script, which basically redirects everything DOSBox needs to inside the wrapper, including the configuration/preferences file. This is because I like to package my games as individual apps.

I resolved the problem by first adding an extra line to the shell script that specifies a fall-back path for dylibs (i.e. if they cannot otherwise be located at the system level in usr/local.

#!/bin/bash

#run game
realpath() {
[[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"
}
DYLD_LIBRARY_PATH="`realpath`dosbox/"
export DYLD_FALLBACK_LIBRARY_PATH="`realpath`lib/glide"
echo $DYLD_LIBRARY_PATH
./dosbox/dosbox -conf dosbox_settings.conf -conf dosbox_launch.conf

I had tested with keeping the Glide libraries in the same /lib folder as the other dylibs, but it still showed me the Glide dylib was looking for SDL in usr/local/cellar/SDL.

But after trial and error, I found out that if I put the Glide libraries in a sub-folder of Resources/lib in my app package, it finds the Glide library in there (i.e. /lib/glide).

Lastly, I had to place a copy of libSDL-1.2.0.dylib inside the same sub-folder containing the Glide dylibs.

This means there are two copies of SDL in the app wrapper - one that DOSBox binary finds under Resources/lib and another that Glide finds under Resources/lib/glide.

With the edited shell script command, I then checked in Activity Monitor that everything was pointing to the internal locations:

dosbox.app/Contents/Resources/lib/glide/libSDL-1.2.0.dylib

dosbox.app/Contents/Resources/lib/glide/libglide2x.0.dylib

dosbox.app/Contents/Resources/lib/libSDL-1.2.0.dylib

The second entry is the one that DOSBox itself is using.

The correct ini and log files were generated by OpenGlide, confirming it was working correctly. I launched and tested the Glide functionality in Lands of Lore 2.

I should also add that I temporarily removed the SDL folder in usr/local/Cellar, because my script only specifies a fall-back location. If a macOS install has SDL installed, Glide will still look in there, but if it is missing, the script will ensure that it looks inside the wrapper instead.

EDIT - I have not yet uploaded the corrected wrapper to my Github site, but will do so over the weekend.

EDIT 2 - the updated wrapper is now available: https://www.dropbox.com/s/51ni2k0d2wlis4k/DOS … rapper.zip?dl=0

Last edited by almeath on 2021-03-13, 08:41. Edited 1 time in total.

DOSBox SVN for macOS (x86-64) - customized with Munt MT-32, Nuked OPL3, 3dfx Voodoo, Extra RAM, Large HD, and more.
https://github.com/almeath/DOSBox-SVN-64-bit-for-macOS

Reply 106 of 172, by Dominus

User metadata
Rank DOSBox Moderator
Rank
DOSBox Moderator

This way of loading the lib wasn't really well thought out by the OpenGlide devs back then 🙁
Another way that should work without the fallback path, is patching glide.cpp in Dosbox source (src/hardware) and hardcode the same path as being used in the dylibbundler script

#elif defined(MACOSX)
hdll = dlopen("@executable_path/../lib/libglide2x.dylib", RTLD_NOW);
#else

and then change the path in libglide2x.dylib to the sdl lib via install_name_tool.

But none of that is really satisfactory 🙁

Windows 3.1x guide for DOSBox
60 seconds guide to DOSBox
DOSBox SVN snapshot for macOS (10.4-11.x ppc/intel 32/64bit) notarized for gatekeeper

Reply 107 of 172, by emendelson

User metadata
Rank Oldbie
Rank
Oldbie

Well, Dominus, your bug report already got results in SDL 1-2:

https://github.com/libsdl-org/SDL-1.2/commit/ … cdac2636c82ff5f

I figured this out this morning when I tried to add the patch to my script, and it kept failing - and I finally took the trouble to look at the original file, and found that it didn't need the patch at all. Well done!

Reply 108 of 172, by Dominus

User metadata
Rank DOSBox Moderator
Rank
DOSBox Moderator

Thanks, but most of the thanks belong to Greatcodeholio 😉

Windows 3.1x guide for DOSBox
60 seconds guide to DOSBox
DOSBox SVN snapshot for macOS (10.4-11.x ppc/intel 32/64bit) notarized for gatekeeper

Reply 110 of 172, by Dominus

User metadata
Rank DOSBox Moderator
Rank
DOSBox Moderator
Dominus wrote on 2021-03-12, 11:50:
This way of loading the lib wasn't really well thought out by the OpenGlide devs back then :( Another way that should work witho […]
Show full quote

This way of loading the lib wasn't really well thought out by the OpenGlide devs back then 🙁
Another way that should work without the fallback path, is patching glide.cpp in Dosbox source (src/hardware) and hardcode the same path as being used in the dylibbundler script

#elif defined(MACOSX)
hdll = dlopen("@executable_path/../lib/libglide2x.dylib", RTLD_NOW);
#else

and then change the path in libglide2x.dylib to the sdl lib via install_name_tool.

But none of that is really satisfactory 🙁

My idea doesn't work. Seems the only way to use it is the dylib fallback you already implemented in the wrapper 🙁

Windows 3.1x guide for DOSBox
60 seconds guide to DOSBox
DOSBox SVN snapshot for macOS (10.4-11.x ppc/intel 32/64bit) notarized for gatekeeper

Reply 111 of 172, by emendelson

User metadata
Rank Oldbie
Rank
Oldbie

@almeath - I've now had closer look at your very impressive wrapper. When you get a chance, could you point me in the direction of the code for your launcher executable? That would very, very useful to have. I've been using AppleScript to do similar things, but the launcher is clearly a superior idea. I'm very impressed!

Reply 112 of 172, by kjliew

User metadata
Rank Oldbie
Rank
Oldbie

I wonder if any of you macOS guys would be interested to get OpenGlide X11 working through XQuartz. Even though XQuartz/OpenGL was deprecated (so was SDL1.2), a search from Google showed that it still works and nothing breaks including support for OpenGL/GLX, even on Apple M1. I actually share the same OpenGlide for DOSBox and QEMU on Linux with OpenGlide X11. My fork of OpenGlide has a more robust GL context initialization through X11/GLX.

Feel free to check it out at:
https://github.com/kjliew/qemu-xtra/tree/master/openglide

Reply 113 of 172, by Dominus

User metadata
Rank DOSBox Moderator
Rank
DOSBox Moderator

Xquartz has become quite a kludge. The only reason I had to use xquartz was Exult Studio which as of this year is finally running native.
And yes, it still works, I even tried it on an Apple DTK. But getting stuff compiled against X11 and then have ot actually work not always easy.
So I pass 😉

Windows 3.1x guide for DOSBox
60 seconds guide to DOSBox
DOSBox SVN snapshot for macOS (10.4-11.x ppc/intel 32/64bit) notarized for gatekeeper

Reply 114 of 172, by almeath

User metadata
Rank Member
Rank
Member
emendelson wrote on 2021-03-12, 16:38:

@almeath - I've now had closer look at your very impressive wrapper. When you get a chance, could you point me in the direction of the code for your launcher executable? That would very, very useful to have. I've been using AppleScript to do similar things, but the launcher is clearly a superior idea. I'm very impressed!

Thank you - however I do not actually know much about the underlying code of the Launcher binary. I acquired it from another app package and utilized it for my wrapper. All I know is that when launched from within /Contents/MacOS of a Mac application wrapper, it calls a bash script, which must have the title "script" and be located inside /Contents/Resources.

The Launcher itself could be called anything. You could test it yourself by using the Mac application Platypus, to bundle the Launcher into a fresh app package, re-naming "Launcher" to anything you like. I tested this all out and it works fine, so you could use it for making any Mac app, not just DOSBox wrappers.

By the way, I tidied up my wrapper (now re-uploaded, linked in the post above) as I realized I had it doing a relay with the bash script ("script") launching an Apple osascript ("run.apple"), which in turn activated another bash script ("script_dos"), which is the one referenced in my post above. I have now just placed the "script_dos" information in "script" and it seems to work fine.

DOSBox SVN for macOS (x86-64) - customized with Munt MT-32, Nuked OPL3, 3dfx Voodoo, Extra RAM, Large HD, and more.
https://github.com/almeath/DOSBox-SVN-64-bit-for-macOS

Reply 115 of 172, by almeath

User metadata
Rank Member
Rank
Member
kjliew wrote on 2021-03-13, 01:31:

I wonder if any of you macOS guys would be interested to get OpenGlide X11 working through XQuartz. Even though XQuartz/OpenGL was deprecated (so was SDL1.2), a search from Google showed that it still works and nothing breaks including support for OpenGL/GLX, even on Apple M1. I actually share the same OpenGlide for DOSBox and QEMU on Linux with OpenGlide X11. My fork of OpenGlide has a more robust GL context initialization through X11/GLX.

Feel free to check it out at:
https://github.com/kjliew/qemu-xtra/tree/master/openglide

I had a go at compiling this under Mojave. I needed to do chmod +x on bootstrap, and modify some headers to point to the correct X11 location, but then it ended up failing quite badly when dealing with the extension function declarations in openglide/Glextensions.h. Basically, most of those extensions are completely unrecognized by the latest version of X11/XQuartz which I have installed.

DOSBox SVN for macOS (x86-64) - customized with Munt MT-32, Nuked OPL3, 3dfx Voodoo, Extra RAM, Large HD, and more.
https://github.com/almeath/DOSBox-SVN-64-bit-for-macOS

Reply 116 of 172, by kjliew

User metadata
Rank Oldbie
Rank
Oldbie

Hey, openglide/Glextensions.h is the common code. If you can compile it with SDL, then you should be able to do the same with X11. Perhaps SDL_opengl.h is doing something there. When you run $ ./configure --disable-sdl, did it detect support for X?

You do have autotools (automake/autoconf) to run configure, don't you?

Reply 117 of 172, by almeath

User metadata
Rank Member
Rank
Member
kjliew wrote on 2021-03-13, 09:50:

Hey, openglide/Glextensions.h is the common code. If you can compile it with SDL, then you should be able to do the same with X11. Perhaps SDL_opengl.h is doing something there. When you run $ ./configure --disable-sdl, did it detect support for X?

You do have autotools (automake/autoconf) to run configure, don't you?

I do have automake and autoconf installed via Homebrew. Running a standard configure and make does succeed.

When running configure with SDL disabled, the full output is below.

(I will keep playing around with it - just bear in mind I am not hugely knowledgable in all this, I am largely self-taught, and always learning with the insights and assistance of others with more experience than me)

checking build system type... x86_64-apple-darwin18.7.0
checking host system type... x86_64-apple-darwin18.7.0
checking target system type... x86_64-apple-darwin18.7.0
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... ../openglide/install-sh -c -d
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for g++... g++
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking for style of include used by make... GNU
checking dependency style of g++... gcc3
checking how to print strings... printf
checking for gcc... gcc
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking dependency style of gcc... gcc3
checking for a sed that does not truncate output... /usr/bin/sed
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc... /Library/Developer/CommandLineTools/usr/bin/ld
checking if the linker (/Library/Developer/CommandLineTools/usr/bin/ld) is GNU ld... no
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 196608
checking how to convert x86_64-apple-darwin18.7.0 file names to x86_64-apple-darwin18.7.0 format... func_convert_file_noop
checking how to convert x86_64-apple-darwin18.7.0 file names to toolchain format... func_convert_file_noop
checking for /Library/Developer/CommandLineTools/usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... dlltool
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @FILE support... no
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for a working dd... /bin/dd
checking how to truncate binary pipes... /bin/dd bs=4096 count=1
checking for mt... no
checking if : is a manifest tool... no
checking for dsymutil... dsymutil
checking for nmedit... nmedit
checking for lipo... lipo
checking for otool... otool
checking for otool64... no
checking for -single_module linker flag... yes
checking for -exported_symbols_list linker flag... yes
Show last 65 lines
checking for -force_load linker flag... yes
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... yes
checking for gcc option to produce PIC... -fno-common -DPIC
checking if gcc PIC flag -fno-common -DPIC works... yes
checking if gcc static flag -static works... no
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/Library/Developer/CommandLineTools/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin18.7.0 dyld
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking how to run the C++ preprocessor... g++ -E
checking for ld used by g++... /Library/Developer/CommandLineTools/usr/bin/ld
checking if the linker (/Library/Developer/CommandLineTools/usr/bin/ld) is GNU ld... no
checking whether the g++ linker (/Library/Developer/CommandLineTools/usr/bin/ld) supports shared libraries... yes
checking for g++ option to produce PIC... -fno-common -DPIC
checking if g++ PIC flag -fno-common -DPIC works... yes
checking if g++ static flag -static works... no
checking if g++ supports -c -o file.o... yes
checking if g++ supports -c -o file.o... (cached) yes
checking whether the g++ linker (/Library/Developer/CommandLineTools/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin18.7.0 dyld
checking how to hardcode library paths into programs... immediate
checking for ANSI C header files... (cached) yes
checking size of unsigned char... 1
checking size of unsigned short... 2
checking size of unsigned int... 4
checking size of unsigned long... 8
checking size of unsigned long long... 8
checking size of int *... 8
checking for X... libraries , headers
checking for gethostbyname... yes
checking for connect... yes
checking for remove... yes
checking for shmat... yes
checking for IceConnectionNumber in -lICE... no
checking for target cpu type... x86-64 bit compatible
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating sdk2_unix.h
config.status: creating platform/Makefile
config.status: creating platform/linux/Makefile
config.status: creating platform/sdl/Makefile
config.status: creating platform/windows/Makefile
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing libtool commands

DOSBox SVN for macOS (x86-64) - customized with Munt MT-32, Nuked OPL3, 3dfx Voodoo, Extra RAM, Large HD, and more.
https://github.com/almeath/DOSBox-SVN-64-bit-for-macOS

Reply 118 of 172, by Dominus

User metadata
Rank DOSBox Moderator
Rank
DOSBox Moderator

I found a way to use the dynamic libs and *not* have to resort to the dylib fallback path stuff:
Edit src/hardware/glide.cpp:323 to

#elif defined(MACOSX)
hdll = dlopen("@executable_path/libglide2x.dylib", RTLD_NOW);
#else

- then compile, make the bundle, run the dylibbundler to place your libs.
- then place the openglide libs in the same folder as the dosbox binary is
- use install_name_tool to change the path of the SDL lib via:

install_name_tool -change /opt/x86_64/lib/libSDL-1.2.0.dylib @loader_path/../lib/libSDL-1.2.0.dylib dosbox.app/contents/resources/dosbox/libglide2x.dylib

(you need to adapt the path /opt/x86_64/lib/libSDL-1.2.0.dylib to whatever otool -L dosbox.app/contents/resources/dosbox/libglide2x.dylib returns 😀)

(what it does: the edit in glide.cpp makes DOSBox look for the libglide2x relative to where it got started from, in this case the same folder. This can be adapted to place the libglide2x wherever you want in your bundle but then the path needs to be adapted in glide.cpp and the install_name_tool line.
install_name_tool uses basically the same but uses loader_path that is meant for plugins that are not executed but loaded. The path is relative to the libglide2x.dylib *NOT* the dosbox binary)

Windows 3.1x guide for DOSBox
60 seconds guide to DOSBox
DOSBox SVN snapshot for macOS (10.4-11.x ppc/intel 32/64bit) notarized for gatekeeper

Reply 119 of 172, by almeath

User metadata
Rank Member
Rank
Member

That's a cool solution, thanks Dominus.

While both approaches achieve the same functionality with probably no difference in real world use, your solution is cleaner in that it does not rely on having two copies of SDL dylib inside the wrapper.

There might be a use case where people want to compile DOSBox and OpenGlide from source, and access the Glide libraries from usr/local via a single install of the DOSBox app or binary. Will your patch prevent that approach from working?

Last edited by almeath on 2021-03-13, 11:51. Edited 2 times in total.

DOSBox SVN for macOS (x86-64) - customized with Munt MT-32, Nuked OPL3, 3dfx Voodoo, Extra RAM, Large HD, and more.
https://github.com/almeath/DOSBox-SVN-64-bit-for-macOS