Reply 20 of 69, by Dominus
- Rank
- DOSBox Moderator
Yes, but if there is a MacPorts installation one really shouldn't muck with it...
Yes, but if there is a MacPorts installation one really shouldn't muck with it...
A static compile isn't even needed. Plenty of OSX apps put dylibs (or frameworks if they are more attuned to OSX development) in the .app.
The real problem is that Ykhwong's zip of libs is very messy (a bunch of symlinks and some libs that seem to not be used - I think he just zipped his entire /opt/ folder), and is, in fact, broken (libphysfs).
If I can figure out what is causing my bus error 10, I will post up a cleaned set of libs somewhere.
Dominus, thank you for otools advice.
Now I'm working on new .app repack of Ykhwong's dosbox which will be relinking its libraries paths on each start (if application is moved from one folder to another folder or renamed it has to relink its libraries paths to itself). I'll report when I'll get stable results with any name support in the .app name and when it will be running flawlessly on 10.6, 10.7, 10.8 and 10.9 Mac OSes X.
For those who wants to know how to relink libraries path there are two tools of Xcode are needed: install_name_tool and, otool.
Examples: /path_to_otool/otool -L /path_to_binary/dosbox
it shows paths to all needed libraries.
And this how it must be done:
/path_to_install_name_tool/install_name_tool -change `/path_to_otool/otool -L /path_to_binary/dosbox | grep 'name_of_library' | cut (*i don know how to do it right now but you have to cut the output from the right side to space righter the ".dylib" extension*)` /path_to_your_library/name_of_library /path_to_binary/dosbox
I think it's not the best way to make references between libraries. I'll have to make references for libraries (not only for binary of dosbox but for libraries of the libraries of dosbox etc.).... There will be a huge code and it may work slowly. Or I'll try to install_name_tool as a array procedure. There is one more tool. It's called libtool. Maybe it can make things better. I have more time to understand all of this.
Libtool is for compiling not for tinkering afterwards.
Try to find something on the net for how to change the lib paths to be a resource in the App bundle. I'm sure I saw something like that before...
See http://qt-project.org/doc/qt-4.8/deployment-mac.html for an example further down:
Install_name_tool -change ....
The part with @executeable_path/../
I'm only at my phone right now that's why I'm a bit cryptic but with this you could be set...
And make sure with otool that the dylibs don't point at one of the other dylibs (you'd need to change that too then)
wrote:See http://qt-project.org/doc/qt-4.8/deployment-mac.html for an example further down: Install_name_tool -change .... The part w […]
See http://qt-project.org/doc/qt-4.8/deployment-mac.html for an example further down:
Install_name_tool -change ....
The part with @executeable_path/../
I'm only at my phone right now that's why I'm a bit cryptic but with this you could be set...
Yeah, I read it before. It surely have to work for some Xcode/Qt builds with typical structure of folders inside .app bundle. I can only use Applescript right now. And "dosbox" have to be the main binary in .app file to work with "Contents/" folder as with @executable_path/../
I think I have to try Xcode (I used Applescript editor before). It can create Applescripts with nice and easy GUI editor and maybe it can easy relink libraries for additional external executables(because otool, install_name_tool are Xcode utilities)
I'll give it a try...
ok, just took a look, didn't realize what a mess his built is until I extracted his lib 7zip.
@Taewoong, you really need to get this build under control, the way you are doing it is bad (startring with building an x11 SDL which is unnecessaryfor DOSBox, then making users copy thee libs to the macports folder...). Ok for personal use but offering for download is *not* something I'd recommend. Several things that need to be done, let me know if you ever want me to give you a hand there...
I've started editing the dosbox binary and the dylibs as recommended on that qt page I referenced earlier. I haven't finished yet with all dylibs but if you do it like this:
CHANGE='install_name_tool -change'
ID='install_name_tool -id'
TARGET=
LIBPATH=@executable_path/../Resources/lib
TARGET=dosbox
$CHANGE libtbb.dylib $LIBPATH/libtbb.dylib $TARGET
$CHANGE /opt/local/lib/libSDL_sound-1.0.1.dylib $LIBPATH/libSDL_sound-1.0.1.dylib $TARGET
$CHANGE /opt/local/lib/libpng15.15.dylib $LIBPATH/libpng15.15.dylib $TARGET
$CHANGE /opt/local/lib/libz.1.dylib $LIBPATH/libz.1.2.7.dylib $TARGET
$CHANGE /opt/local/lib/libfreetype.6.dylib $LIBPATH/libfreetype.6.dylib $TARGET
$CHANGE /opt/local/lib/libbz2.1.0.dylib $LIBPATH/libbz2.1.0.6.dylib $TARGET
$CHANGE /opt/local/lib/libSDL_net-1.2.0.dylib $LIBPATH/libSDL_net-1.2.0.dylib $TARGET
$CHANGE /opt/local/lib/libGL.1.dylib $LIBPATH/libGL.1.dylib $TARGET
$CHANGE /opt/local/lib/libfluidsynth.1.dylib $LIBPATH/libfluidsynth.1.dylib $TARGET
$CHANGE /opt/local/lib/libphysfs.1.dylib $LIBPATH/libphysfs.2.0.2.dylib $TARGET
$CHANGE /opt/local/lib/libstdc++.6.dylib $LIBPATH/libstdc++.6.dylib $TARGET
$CHANGE /opt/local/lib/gcc47/libgcc_s.1.dylib $LIBPATH/gcc47/libgcc_s.1.dylib $TARGET
$CHANGE /opt/local/lib/libSDL-1.2.0.dylib $LIBPATH/libSDL-1.2.0.dylib $TARGET
$CHANGE /opt/local/lib/libX11.6.dylib $LIBPATH/libX11.6.dylib $TARGET
TARGET=libSDL_sound-1.0.1.dylib
$ID $LIBPATH/libSDL_sound-1.0.1.dylib $TARGET
$CHANGE /opt/local/lib/libSDL-1.2.0.dylib $LIBPATH/libSDL-1.2.0.dylib $TARGET
$CHANGE /opt/local/lib/libvorbisfile.3.dylib $LIBPATH/libvorbisfile.3.dylib $TARGET
$CHANGE /opt/local/lib/libvorbis.0.dylib $LIBPATH/libvorbis.0.dylib $TARGET
$CHANGE /opt/local/lib/libogg.0.dylib $LIBPATH/libogg.0.dylib $TARGET
$CHANGE /opt/local/lib/libFLAC.8.dylib $LIBPATH/libFLAC.8.dylib $TARGET
TARGET=libvorbisfile.3.dylib
$ID $LIBPATH/libvorbisfile.3.dylib $TARGET
$CHANGE /opt/local/lib/libvorbis.0.dylib $LIBPATH/libvorbis.0.dylib $TARGET
$CHANGE /opt/local/lib/libogg.0.dylib $LIBPATH/libogg.0.dylib $TARGET
TARGET=libvorbis.0.dylib
$ID $LIBPATH/libvorbis.0.dylib $TARGET
$CHANGE /opt/local/lib/libogg.0.dylib $LIBPATH/libogg.0.dylib $TARGET
TARGET=libogg.0.dylib
$ID $LIBPATH/libogg.0.dylib $TARGET
TARGET=libFLAC.8.dylib
$ID $LIBPATH/libFLAC.8.dylib $TARGET
$CHANGE /opt/local/lib/libogg.0.dylib $LIBPATH/libogg.0.dylib $TARGET
TARGET=libpng15.15.dylib
$ID $LIBPATH/libpng15.15.dylib $TARGET
TARGET=libz.1.2.7.dylib
$ID $LIBPATH/libz.1.2.7.dylib $TARGET
TARGET=libfreetype.6.dylib
$ID $LIBPATH/libfreetype.6.dylib $TARGET
$CHANGE /opt/local/lib/libz.1.dylib $LIBPATH/libz.1.2.7.dylib $TARGET
$CHANGE /opt/local/lib/libbz2.1.0.dylib $LIBPATH/libbz2.1.0.6.dylib $TARGET
TARGET=libSDL_net-1.2.0.dylib
$ID $LIBPATH/libSDL_net-1.2.0.dylib $TARGET
$CHANGE /opt/local/lib/libSDL-1.2.0.dylib $LIBPATH/libSDL-1.2.0.dylib $TARGET
$CHANGE /opt/local/lib/libXrandr.2.dylib $LIBPATH/libXrandr.2.dylib $TARGET
$CHANGE /opt/local/lib/libXext.6.dylib $LIBPATH/libXext.6.dylib $TARGET
$CHANGE /opt/local/lib/libXrender.1.dylib $LIBPATH/libXrender.1.dylib $TARGET
$CHANGE /opt/local/lib/libX11.6.dylib $LIBPATH/libX11.6.dylib $TARGET
$CHANGE /opt/local/lib/libxcb.1.dylib $LIBPATH/libxcb.1.dylib $TARGET
$CHANGE /opt/local/lib/libXau.6.dylib $LIBPATH/libXau.6.dylib $TARGET
$CHANGE /opt/local/lib/libXdmcp.6.dylib $LIBPATH/libXdmcp.6.dylib $TARGET
TARGET=libGL.1.dylib
$ID $LIBPATH/libGL.1.dylib $TARGET
$CHANGE /opt/local/lib/libX11-xcb.1.dylib $LIBPATH/libX11-xcb.1.dylib $TARGET
$CHANGE /opt/local/lib/libxcb.1.dylib $LIBPATH/libxcb.1.dylib $TARGET
$CHANGE /opt/local/lib/libX11.6.dylib $LIBPATH/libX11.6.dylib $TARGET
$CHANGE /opt/local/lib/libXext.6.dylib $LIBPATH/libXext.6.dylib $TARGET
TARGET=libfluidsynth.1.dylib
$ID $LIBPATH/libfluidsynth.1.dylib $TARGET
$CHANGE /opt/local/lib/libreadline.6.2.dylib $LIBPATH/libreadline.6.2.dylib $TARGET
$CHANGE /opt/local/lib/libncurses.5.dylib $LIBPATH/libncurses.5.dylib $TARGET
$CHANGE /opt/local/lib/libjack.0.dylib $LIBPATH/libjack.0.dylib $TARGET
$CHANGE /opt/local/lib/libportaudio.2.dylib $LIBPATH/libportaudio.2.dylib $TARGET
$CHANGE /opt/local/lib/libgthread-2.0.0.dylib $LIBPATH/libgthread-2.0.0.dylib $TARGET
$CHANGE /opt/local/lib/libglib-2.0.0.dylib $LIBPATH/libglib-2.0.0.dylib $TARGET
$CHANGE /opt/local/lib/libintl.8.dylib $LIBPATH/libintl.8.dylib $TARGET
$CHANGE /opt/local/lib/libsndfile.1.dylib $LIBPATH/libsndfile.1.dylib $TARGET
TARGET=libphysfs.2.0.2.dylib
$ID $LIBPATH/libphysfs.1.dylib $TARGET
$CHANGE /opt/local/lib/libz.1.dylib $LIBPATH/libz.1.2.7.dylib $TARGET
TARGET=libstdc++.6.dylib
$ID $LIBPATH/libstdc++.6.dylib $TARGET
TARGET=./gcc47/libgcc_s.1.dylib
$ID $LIBPATH/gcc47/libgcc_s.1.dylib $TARGET
TARGET=libSDL-1.2.0.dylib
$ID $LIBPATH/libSDL-1.2.0.dylib $TARGET
This is all in Terminal.app and for the first part you need to be in the path where the dosbox binary is and then for dylibs you need to be in the path where you extracted them.
The above list is not yet done for every dylib but once it is you can put the dosbox binary into the Dosbox.app/Contents/MacOS in a bundle and the libs into Dosbox.app/Contents/Resources/lib and the app should almost work (needs some plist file etc...)
It's a grind to do all this...
After processing TARGET=dosbox you have to switch LIBPATH=@executable_path
I'm working around on that. I use the power of Oracle Database to build terminal script fast and easy for copy/paste
It seems to work in this case because dosbox is the executeable and the libs get loaded from there, even the libs referenced by the dylibs
You know it probably just works with settinh the dylib path environment setting prior to launching dosbox... Totally forgot that one... AGAIN
Even though it was mentioned here a couple of times...
export DYLD_LIBRARY_PATH="./LIBS/"
?
I'm not a developer, but Google says that it links to built-in libraries in binary.
I believe that I have to make application where you can choose directory with libraries and process paths to the libraries to another paths.
I've some experience with applescript.
No, it links to dynamic linked libraries in binaries, exactly the problem here. I jus wonder if you can set this for app bundles with the @executable/../ thing I did above...
Hmm, I'm stucked with terminal dynamic generating of scripts
cd to your lib folder and type:
Red$ otool -L libSDL_sound-1.0.1.dylib | grep -w "$(echo $(ls -l | grep ^- | awk '{print $9}') | sed -e "s/ /$(echo "\\\|")/g")" | grep -v 'libSDL_sound-1.0.1.dylib:' | cut -d' ' -f 1 | cut -c 2- | sed 's/.*/install_name_tool -change &/' | sed "s/.*/& @executable_path\/..\/Resources\/LIBS\//"
Output:
install_name_tool -change /opt/local/lib/libSDL_sound-1.0.1.dylib @executable_path/../Resources/LIBS/
install_name_tool -change @executable_path/../Resources/LIBS/libSDL-1.2.0.dylib @executable_path/../Resources/LIBS/
install_name_tool -change /opt/local/lib/libvorbisfile.3.dylib @executable_path/../Resources/LIBS/
install_name_tool -change /opt/local/lib/libvorbis.0.dylib @executable_path/../Resources/LIBS/
install_name_tool -change /opt/local/lib/libFLAC.8.dylib @executable_path/../Resources/LIBS/
install_name_tool -change /opt/local/lib/libogg.0.dylib @executable_path/../Resources/LIBS/
I'm stucked to add postfixes with sed using the names of libraries in each line.
I want to add ${echo & | cut to_name_of_dylibs_with_extensions} where & is a entire line before command
I suck at regular expressions 😉
Yeah! I did this goddamn regular expression.
MacBook-Pro-Egor:LIBS Red$ otool -L libSDL_sound-1.0.1.dylib | grep -w "$(echo $(ls -l | grep ^- | awk '{print $9}') | sed -e "s/ /$(echo "\\\|")/g")" | grep -v 'libSDL_sound-1.0.1.dylib:' | cut -d' ' -f 1 | cut -c 2- | sed "s/.*/& #&/" | rev | sed 's/\/.*#/ /g' | rev | sed 's/ / #/' | sed 's/.*/install_name_tool -change &/' | sed 's/#/@executable_path\/..\/Resources\/LIBS\//' | sed 's/.*/& libSDL_sound-1.0.1.dylib/'
install_name_tool -change /opt/local/lib/libSDL_sound-1.0.1.dylib @executable_path/../Resources/LIBS/libSDL_sound-1.0.1.dylib libSDL_sound1.0.1.dylib
install_name_tool -change @executable_path/../Resources/LIBS/libSDL-1.2.0.dylib @executable_path/../Resources/LIBS/libSDL-1.2.0.dylib libSDL_sound-1.0.1.dylib
install_name_tool -change /opt/local/lib/libvorbisfile.3.dylib @executable_path/../Resources/LIBS/libvorbisfile.3.dylib libSDL_sound-1.0.1.dylib
install_name_tool -change /opt/local/lib/libvorbis.0.dylib @executable_path/../Resources/LIBS/libvorbis.0.dylib libSDL_sound-1.0.1.dylib
install_name_tool -change /opt/local/lib/libFLAC.8.dylib @executable_path/../Resources/LIBS/libFLAC.8.dylib libSDL_sound-1.0.1.dylib
install_name_tool -change /opt/local/lib/libogg.0.dylib @executable_path/../Resources/LIBS/libogg.0.dylib libSDL_sound-1.0.1.dylib
Now there is one little thing to do with applescript: to get such generated scripts into text variable with ";" delimiter and execute for every item in lib, lib/gcc47, lib/gcc47/i386 folder with repeat cycle.
In fact my script will allow to change any path to any path, because I use grep pattern for otool out of all names of the files in lib folder.
One more thing is to get subfolder link, but I believe I need one more otool script for it.
You also need install_name_tool -id for the very first entry in the dylibs you can see with otool -L which is the lib itself.
And the broken symlinks need to be fixed or you point at them in some few cases.
People, I got to work Ykhwong's DosBox with libraries mapped inside .app bundle.
There is a one thing to do: I have to find the best way to run it.
Jarvik7. I finally remembered when I got bus error 10. I used applescript to run DosBox with command: do shell script (path_to_dosbox as text) & "dosbox"
It causes bus error 10.
But when I use in applescript:
tell application "Terminal" do script (path_to_dosbox as text) & "dosbox" end tell
it works great, but I'm not sure that I want to see Terminal running even on background. But it seems that Ykhwong's dosbox doesn't work without terminal. I'm not sure but I think it produces the "bus" to dosbox. And dosbox uses some terminal commands.... perhaps..
Full script
tell application "Terminal"
do script "export DYLD_LIBRARY_PATH=\"@executable_path/../Resources/LIBS/\" ; " & (the_path as text) & "dosbox ; exit"
end tell
do shell script "sleep 5 ; killall -c Terminal"
works not too bad.
Dominus, thanks for advices.
Soon I can upload that version when I'll define the best method to run and when I'll choose place for .conf file and DriveC
Some screenshots.
Do shell script
Do script in terminal