VOGONS


Building under OS X and Xcode 5.0

Topic actions

Reply 20 of 35, by Dominus

User metadata
Rank DOSBox Moderator
Rank
DOSBox Moderator

Yeah, clang has a feast with Dosbox warnings. I don't think you need to worry about that too much. Eventually the devs might want to clean that up. I think I posted some warnings ages ago... I need to look it up, there is a compiler switch to silence the warnings...

The -j9 switch makes compiling a lot faster since it compiles stuff in parallel. And the clutterless makes it appear faster 😉

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 21 of 35, by emendelson

User metadata
Rank Oldbie
Rank
Oldbie

EDIT: When I first posted this message, I asked this question:

I may want to add screenshot support to my solution someday. How can I link libpng statically to this project? I have png.h in /opt/local/include/libpng15.

I now see that you already answered the question a couple of years ago. Here is what I think is the answer (I haven't tested whether the screenshot function actually works!):

1. near the top of the build script, UNcomment the line:

export LDFLAGS='-L/opt/local/lib '$SDK' '$OPT 

2. after the first sed command and error-test add this code:

sed -i.old1 -e "s@-lpng -lz@/opt/local/lib/libpng15.a /opt/local/lib/libz.a@g" Makefile || {
DIE=1
error_quit "$(( $LINENO -2 )) : 1st sed for png-z failed."
}

3. After what WAS the second sed command and error-test (and is now the third sed command and error-test, add this code:

sed -i.old1 -e "s@-lpng -lz@/opt/local/lib/libpng15.a /opt/local/lib/libz.a@g" Makefile || {
DIE=1
error_quit "$(( $LINENO -2 )) : 2st sed for png-z failed."
}

I see that it should be easy to combine these sed commands with the preceding commands, but I haven't tried yet. Onward!

EDIT: Screen capture works correctly after these changes.

Reply 22 of 35, by Dominus

User metadata
Rank DOSBox Moderator
Rank
DOSBox Moderator

Great! 😉

An updated AppleScript for a mail rule when new messages arrive, this time only for Dosbox

set subj to "DOSBox"
tell application "Mail"
activate
set icon_path to ((path to applications folder) as string) & subj & ".app:Contents:Resources:" & subj & ".icns"
set snapshotdialog to display dialog "New revision!!!

Build " & subj & " snapshot?
" buttons {"Cancel", "OK"} giving up after 110 with icon alias icon_path with title subj
if button returned of snapshotdialog = "OK" or gave up of snapshotdialog is true then
tell application "Terminal"
activate
tell application "System Events" to tell process "Terminal" to keystroke "t" using {command down}
delay 1
do script "cd ~/code/sh; . " & subj & "snapshot.sh" in selected tab of the front window
end tell
end if
end tell

As for your patched compile maybe we can have a look to make your SDLmain.cpp up to current again. I'm not sure that is that safe to have that not up to date with current SVN.

Another thing I do in my script: I no longer use sed but have a patch file to change the libs.

--- ./Makefile 
+++ ./Makefile
139c139
< LIBS = -lSDL_sound -L/opt/exult.i386/lib -lSDLmain -lSDL -Wl,-framework,Cocoa -lpng -lz -lSDL_net -framework OpenGL -framework CoreMIDI -framework AudioUnit -framework AudioToolbox
---
> LIBS = -L/opt/exult.i386/lib /opt/exult.i386/lib/libSDLmain.a /opt/exult.i386/lib/libSDL.a -Wl,-framework,OpenGL -Wl,-framework,Cocoa -Wl,-framework,ApplicationServices -Wl,-framework,Carbon -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit -Wl,-framework,IOKit -framework CoreMIDI /opt/exult.i386/lib/libpng.a /opt/exult.i386/lib/libz.a /opt/exult.i386/lib/libSDL_net.a /opt/exult.i386/lib/libSDL_sound.a /opt/exult.i386/lib/libogg.a /opt/exult.i386/lib/libvorbis.a /opt/exult.i386/lib/libvorbisfile.a /opt/exult.i386/lib/libvorbisenc.a
155c155
< SDL_LIBS = -L/opt/exult.i386/lib -lSDLmain -lSDL -Wl,-framework,Cocoa
---
> SDL_LIBS = -L/opt/exult.i386/lib /opt/exult.i386/lib/libSDLmain.a /opt/exult.i386/lib/libSDL.a -Wl,-framework,OpenGL -Wl,-framework,Cocoa -Wl,-framework,ApplicationServices -Wl,-framework,Carbon -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit -Wl,-framework,IOKit

--- ./src/Makefile
+++ ./src/Makefile
143c143
< LIBS = -lSDL_sound -L/opt/exult.i386/lib -lSDLmain -lSDL -Wl,-framework,Cocoa -lpng -lz -lSDL_net -framework OpenGL -framework CoreMIDI -framework AudioUnit -framework AudioToolbox
---
> LIBS = -L/opt/exult.i386/lib /opt/exult.i386/lib/libSDLmain.a /opt/exult.i386/lib/libSDL.a -Wl,-framework,OpenGL -Wl,-framework,Cocoa -Wl,-framework,ApplicationServices -Wl,-framework,Carbon -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit -Wl,-framework,IOKit -framework CoreMIDI /opt/exult.i386/lib/libpng.a /opt/exult.i386/lib/libz.a /opt/exult.i386/lib/libSDL_net.a /opt/exult.i386/lib/libSDL_sound.a /opt/exult.i386/lib/libogg.a /opt/exult.i386/lib/libvorbis.a /opt/exult.i386/lib/libvorbisfile.a /opt/exult.i386/lib/libvorbisenc.a
159c159
< SDL_LIBS = -L/opt/exult.i386/lib -lSDLmain -lSDL -Wl,-framework,Cocoa
---
> SDL_LIBS = -L/opt/exult.i386/lib /opt/exult.i386/lib/libSDLmain.a /opt/exult.i386/lib/libSDL.a -Wl,-framework,OpenGL -Wl,-framework,Cocoa -Wl,-framework,ApplicationServices -Wl,-framework,Carbon -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit -Wl,-framework,IOKit

so instead of calling two times sed I only run once "patch -p0 -i intel.diff"
That patch needs to be adapted to your needs, though. I'm also building with SDL_sound, so my static compile is a bit different to yours (not to mention different paths 😀)

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 23 of 35, by emendelson

User metadata
Rank Oldbie
Rank
Oldbie

Thank you for your offer to look at my SDLmain.cpp. I remembered, after posting my message, that SDLmain.cpp is the one file that is completely different in my Windows and OS X builds, because I've adapted the modifications made in the dbDOS project that add pasting from the Windows clipboard and a custom system menu (the menu that drops down from the icon in the upper left corner of the window). In my OS X project, SDLmain.cpp closely tracks SVN, because I wasn't able to add those Windows-style features. The version of SDLmain.cpp that's out of step in my project in the Win32 one.

I really don't expect you to spend time on a Windows-based project, but if anyone is interested in using these added Windows-based features, here's the file, attached.

I made this by modifying the file from the dbDOS 1.5 code (http://www.dbdos.com, in the patches section). The author seems to have based it on Megabuild and added the clipboard and one or two other things. The rest of my project uses patched SVN, but it was beyond my abilities to put the added features into current code.

Again, I don't expect anyone to spend time on this, but if someone is interested in the added features - which I only modified, and didn't write - it may be worth a look.

Reply 24 of 35, by emendelson

User metadata
Rank Oldbie
Rank
Oldbie
Dominus wrote:
Another thing I do in my script: I no longer use sed but have a patch file to change the libs. […]
Show full quote

Another thing I do in my script: I no longer use sed but have a patch file to change the libs.

--- ./Makefile 
+++ ./Makefile
139c139
< LIBS = -lSDL_sound -L/opt/exult.i386/lib -lSDLmain -lSDL -Wl,-framework,Cocoa -lpng -lz -lSDL_net -framework OpenGL -framework CoreMIDI -framework AudioUnit -framework AudioToolbox
---
> LIBS = -L/opt/exult.i386/lib /opt/exult.i386/lib/libSDLmain.a /opt/exult.i386/lib/libSDL.a -Wl,-framework,OpenGL -Wl,-framework,Cocoa -Wl,-framework,ApplicationServices -Wl,-framework,Carbon -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit -Wl,-framework,IOKit -framework CoreMIDI /opt/exult.i386/lib/libpng.a /opt/exult.i386/lib/libz.a /opt/exult.i386/lib/libSDL_net.a /opt/exult.i386/lib/libSDL_sound.a /opt/exult.i386/lib/libogg.a /opt/exult.i386/lib/libvorbis.a /opt/exult.i386/lib/libvorbisfile.a /opt/exult.i386/lib/libvorbisenc.a
155c155
< SDL_LIBS = -L/opt/exult.i386/lib -lSDLmain -lSDL -Wl,-framework,Cocoa
---
> SDL_LIBS = -L/opt/exult.i386/lib /opt/exult.i386/lib/libSDLmain.a /opt/exult.i386/lib/libSDL.a -Wl,-framework,OpenGL -Wl,-framework,Cocoa -Wl,-framework,ApplicationServices -Wl,-framework,Carbon -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit -Wl,-framework,IOKit

--- ./src/Makefile
+++ ./src/Makefile
143c143
< LIBS = -lSDL_sound -L/opt/exult.i386/lib -lSDLmain -lSDL -Wl,-framework,Cocoa -lpng -lz -lSDL_net -framework OpenGL -framework CoreMIDI -framework AudioUnit -framework AudioToolbox
---
> LIBS = -L/opt/exult.i386/lib /opt/exult.i386/lib/libSDLmain.a /opt/exult.i386/lib/libSDL.a -Wl,-framework,OpenGL -Wl,-framework,Cocoa -Wl,-framework,ApplicationServices -Wl,-framework,Carbon -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit -Wl,-framework,IOKit -framework CoreMIDI /opt/exult.i386/lib/libpng.a /opt/exult.i386/lib/libz.a /opt/exult.i386/lib/libSDL_net.a /opt/exult.i386/lib/libSDL_sound.a /opt/exult.i386/lib/libogg.a /opt/exult.i386/lib/libvorbis.a /opt/exult.i386/lib/libvorbisfile.a /opt/exult.i386/lib/libvorbisenc.a
159c159
< SDL_LIBS = -L/opt/exult.i386/lib -lSDLmain -lSDL -Wl,-framework,Cocoa
---
> SDL_LIBS = -L/opt/exult.i386/lib /opt/exult.i386/lib/libSDLmain.a /opt/exult.i386/lib/libSDL.a -Wl,-framework,OpenGL -Wl,-framework,Cocoa -Wl,-framework,ApplicationServices -Wl,-framework,Carbon -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit -Wl,-framework,IOKit

so instead of calling two times sed I only run once "patch -p0 -i intel.diff"
That patch needs to be adapted to your needs, though. I'm also building with SDL_sound, so my static compile is a bit different to yours (not to mention different paths 😀)

I'm going to use your patch method in my build script instead of sed, as you suggest. One question: in my build script, following your suggestion, I change the makefile both in the top-level directory and in src. Do you do the same thing with your patch file??

Thanks again for all your help with this.

Reply 26 of 35, by emendelson

User metadata
Rank Oldbie
Rank
Oldbie
Dominus wrote:

Yes, notice how it first patches ./makefile and then ./src/makefile

Next time I'll look first and then ask! 😉 Apologies for the time-wasting question...

Reply 27 of 35, by emendelson

User metadata
Rank Oldbie
Rank
Oldbie

No surprises here: I wanted to confirm that, by following Dominus's instructions, I was able to build DOSBox under OS X 10.9 Mavericks. Lots of warnings appeared, but no errors. Thanks again to Dominus for figuring out how to do this!

Reply 28 of 35, by emendelson

User metadata
Rank Oldbie
Rank
Oldbie

I recently tried to build my DOSBox project again under Mavericks, using the script generously supplied by Dominus, which has worked well for years with minor revisions. I hadn't built DOSBox since last December.

This time, I got an error about not being able to find libpng 1.5, but that was because macports had updated me to libpng 1.6, so I changed every reference to libpng15 in my script to libpng16, and built successfully again. The resulting build works perfectly on my system.

Unfortunately, when I try to run it it on a clean install of OS X 10.9.3, without macports installed, I get this error message:

dyld: Library not loaded: /opt/local/lib/libX11.6.dylib

What puzzles me about this is that I didn't know I was using X11 at all in my build. There's no reference to it the build script. (Of course, /opt/local/lib/libX11.6.dylib is present on the system I build with, thanks to macports, but I'm trying to make a static build that I can distribute - and the build I made in December works perfectly on the same clean install of OS X in which the new build fails.)

I hope Dominus has an easy answer to this problem - he's guided me every step of the way so far - but if not, I hope someone else might have an idea about how to solve it.

Thanks for any help.

Reply 29 of 35, by Dominus

User metadata
Rank DOSBox Moderator
Rank
DOSBox Moderator

Some library is pulling in x11...
Maybe SDL or maybe libpng 1.6 OR you are pulling in a xquartz lib accidentally. So investigate sdl and libpng whether they are built without x11 (or if it is libpng whether there is a no_x11 variant)

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 30 of 35, by emendelson

User metadata
Rank Oldbie
Rank
Oldbie

That was quick! I think you found the answer. The results of "sudo port installed" include:

libsdl @1.2.15_3+universal+x11 (active)

I'm waiting for an "upgrade outdated" to complete before I try to replace this with a no-x11 installation of libsdl. This thread seems as if it might be useful:

http://mac-os-forge.2317878.n4.nabble.com/no- … t-td118330.html

It looks as if I'm going to need to uninstall quite a few packages and then reinstall them with -x11....

Reply 31 of 35, by Dominus

User metadata
Rank DOSBox Moderator
Rank
DOSBox Moderator

Yup that's it 😉
But you won't need to change all of them.
First look up which port that depends on x11 also depends on SDL (my guess is none but who knows). There is some port command to list dependents but I don't know without looking it up 😉
Then find out if that port can be installed without x11. This way you won't need to force upgrade too many ports.

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 32 of 35, by emendelson

User metadata
Rank Oldbie
Rank
Oldbie

You solved it! Thank you.

Just to be thorough, I uninstalled everything that showed up in

sudo port installed | grep x11

which turned out to be a lot. If I need any of it, I'll just reinstall it with the -x11 +quartz option.

Incidentally, when I reinstalled libsdl, I needed to use the +universal option to create an executable that worked in a clean system. Oddly enough, my usual system had no trouble with the executable that I built without the +universal variant of libsdl, but that non-universal build wouldn't run in my clean system. So I installed +universal, built again, and now the executable worked in the clean system. So I've got it working now again, thanks to your help!

Last edited by emendelson on 2014-05-29, 16:54. Edited 2 times in total.

Reply 34 of 35, by emendelson

User metadata
Rank Oldbie
Rank
Oldbie

My usual system is 10.9.3 on a 2012 Macbook Air, and it seems to think it is a 64-bit system, so I'm puzzled. I may have done something else wrong, and will experiment. I'll report back if I learn more. Meanwhile, thank you again for sorting this out so quickly!

Reply 35 of 35, by emendelson

User metadata
Rank Oldbie
Rank
Oldbie

A possibly interesting development about building DOSBox under OS X 10.9:

My Mavericks system was getting bloated, so I wiped the disk and installed it again. I installed MacPorts but didn't install any ports. Using the script that I put together with Dominus's help, I then tried to build a static-linked DOSBox.

The build failed because I didn't have autoconf, so I installed autoconf through MacPorts, and built again - without having downloaded sdl or anything else through MacPorts. The resulting build didn't have libpng, SDL_net, or libSDL_sound, but I don't use those anyway.

The autogen.sh part of the script generated these messages:

./autogen.sh: line 8: aclocal: command not found
./autogen.sh: line 10: automake: command not found

but this didn't seem to make any difference.

This does seem to make it easier to build DOSBox. Thanks again to Dominus for figuring out how to do it!