VOGONS


First post, by emendelson

User metadata
Rank Oldbie
Rank
Oldbie

Everything in this post was worked out by Dominus, not by me, but I thought it might be useful to put all the details together in one place. Here how to build a standalone version of DOSBox SVN using the revised SDL 1.2 code that works correctly under Lion. This assumes that you already have DOSBox SVN code on your system.

EDIT: These instructions create a standalone build that can be used on any other Lion system, not just your own. (Dominus spells this out in one of his replies.) I needed to do this because I've build a downloadable application around DOSBox that I distribute freely.

1. Install MacPorts from http://www.macports.org

2. To make this version of DOSBox portable, and if (like me) you don't need sdl_net or sdl_sound, then install these items only:

sudo port install libsdl +universal +no_x11 
sudo port install libpng +universal
sudo port install pkgconfig +universal

3. Install Mercurial for OS X (find via Google), and then download the latest SDL 1.2 source code by using the hg clone command described on this page: http://www.libsdl.org/hg.php

4. Examine the downloaded code, and (if this has not been fixed by the time you do this), revert the change described on this page: http://hg.libsdl.org/SDL/rev/8e0dd46ad0e0

5. Create the following script in your SDL-1.2 folder and make it executable (chmod +x filename.sh):

#!/bin/sh
export CC='/usr/bin/gcc-4.2 -arch i386'
export CXX='/usr/bin/g++-4.2 -arch i386'
export GCOV='/usr/bin/gcov-4.2 -arch i386'
./autogen.sh

## I didn't need joystick or cdrom, but they're easy to restore using the strings below
# ./configure --enable-static --enable-joystick --enable-cdrom --disable-video-x11 --enable-video-cocoa --enable-video-opengl --without-x --prefix=/path/for/SDL/binaries

## REPLACE path shown below with correct path for current system
./configure --enable-static --disable-video-x11 --enable-video-cocoa --without-x --prefix=/path/for/SDL/binaries

make clean
make
make install

Of course, replace "/path/for/SDL/binaries" with a path that can actually exist on your system. The path should either not exist, or be empty. It should not be the same path that contains the SDL 1.2 source code.

6. Run the script that you created, and see whether the SDL binaries were created in the path that you specified in the --prefix string. If successful, proceed to building DOSBox.

7. In your DOSBox SVN directory, create the following script and make it executable. Replace "/path/for/SDL/binaries" with the actual path that you specfied in step 5.

#!/bin/sh

export CC='/usr/bin/gcc-4.2 -arch i386'
export CXX='/usr/bin/g++-4.2 -arch i386'
export GCOV='/usr/bin/gcov-4.2 -arch i386'

./autogen.sh

./configure --prefix=/opt/local --with-sdl-prefix=/path/for/SDL/binaries
make clean

sed -i.old -e "s@-L/path/for/SDL/binaries/lib -lSDLmain -lSDL -Wl,-framework,Cocoa@-L/path/for/SDL/binaries/lib/ /path/for/SDL/binaries/lib/libSDLmain.a /path/for/SDL/binaries/lib/libSDL.a -Wl,-framework,OpenGL -Wl,-framework,Cocoa -Wl,-framework,ApplicationServices -Wl,-framework,Carbon -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit -Wl,-framework,IOKit@g" Makefile

cd src

sed -i.old -e "s@-L/path/for/SDL/binaries/lib -lSDLmain -lSDL -Wl,-framework,Cocoa@-L/path/for/SDL/binaries/lib/ /path/for/SDL/binaries/lib/libSDLmain.a /path/for/SDL/binaries/lib/libSDL.a -Wl,-framework,OpenGL -Wl,-framework,Cocoa -Wl,-framework,ApplicationServices -Wl,-framework,Carbon -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit -Wl,-framework,IOKit@g" Makefile

cd ..

make

8. Run the script. Test the resulting dosbox executable on a system that does not have MacPorts installed.

If anything is wildly wrong here, I hope someone will correct it. As I said, Dominus worked out every detail of this, and I just put it all together in one post.

PS One further note: I've tested this only with my patched version of SVN, but if it works with my patched version, it should probably work with plain SVN.

Last edited by emendelson on 2012-09-06, 12:18. Edited 2 times in total.

Reply 1 of 18, by Dominus

User metadata
Rank DOSBox Moderator
Rank
DOSBox Moderator

Actually this can all be shortcut if you don't care about Dosbox' screenshot functionality.
Without that you don't need MacPorts at all (I think, I'm not sure whether Dosbox will correctly run .configure if there is no libpng) (or compile it similar to SDL on your own thus eliminating the need for MacPorts)

Some corrections and hints:
in the SDL script the only important things are
./configure --enable-static --disable-video-x11 --without-x --prefix=/path/for/SDL/binaries all other things will get enabled by default anyway (so your builds *DO* have joystick and CD-Rom support), I just let it enable explicitly to make sure it gets done, but it should be done anyway 😀

In step 7 you need to check what your sed command does. At the moment it doesn't do anything useful 😀
You want to edit Makefile and replace the "Libs = ..." line and replace it with your own to make it build a static version of Dosbox.
So you need to replace "-L/path/for/SDL/binaries/lib -lSDLmain -lSDL" with "-L/path/for/SDL/binaries/lib /path/for/SDL/binaries/lib/libSDLmain.a /path/for/SDL/binaries/lib/libSDL.a -Wl,-framework,ApplicationServices -Wl,-framework,Carbon -Wl,-framework,IOKit"
How I got to that replacement?
After you've done the Dosbox ./configure --prefix=/opt/local --with-sdl-prefix=/path/for/SDL/binaries look at the Makefiles "Libs = " line. This lists all the libs needed for a dynamic built. You want a static one.
So execute /path/for/SDL/binaries/bin/sdl-config --libs
and /path/for/SDL/binaries/bin/sdl-config --static-libs
The first one gives you the things you need to replace with the second one in the "Libs = " line.

ALSO!!! you will need to replace -lpng with /opt/local/lib/libpng14.a AND -lz with /opt/local/lib/libz.a

(so in the end the whole Libs line in the makefiles should read:
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 /opt/local/lib/libpng14.a /opt/local/lib/libz.a -framework CoreMIDI
)
Since you haven't done the static png/lz thing, I assume your static built might be unstable when you try the screenshot function of Dosbox

Reply 2 of 18, by Dominus

User metadata
Rank DOSBox Moderator
Rank
DOSBox Moderator

sorry, your sed command is correct, you still need to do the whole thing sdl-config --static-libs gives you and the static path for png and libzip.

And to be nitpicky in your guide, make sure to note that the whole sed thing is only needed when the goal is to have a static Dosbox for use on other Macs. On your own mac with all the libs there a dynamic Dosbox works just fine and is one less hassle 😀

Last edited by Dominus on 2011-08-31, 00:02. Edited 1 time in total.

Reply 3 of 18, by emendelson

User metadata
Rank Oldbie
Rank
Oldbie

1.

Dominus wrote:

Some corrections and hints:
in the SDL script the only important things are
./configure --enable-static --disable-video-x11 --without-x --prefix=/path/for/SDL/binaries all other things will get enabled by default anyway (so your builds *DO* have joystick and CD-Rom support), I just let it enable explicitly to make sure it gets done, but it should be done anyway :)

OK - I'll rework that. Thanks!

2.

Just to clarify: you're saying that I can ignore the whole paragraph in your first reply about my sed command?

3.

ALSO!!! you will need to replace -lpng with /opt/local/lib/libpng14.a AND -lz with /opt/local/lib/libz.a […]
Show full quote

ALSO!!! you will need to replace -lpng with /opt/local/lib/libpng14.a AND -lz with /opt/local/lib/libz.a

(so in the end the whole Libs line in the makefiles should read:
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 /opt/local/lib/libpng14.a /opt/local/lib/libz.a -framework CoreMIDI
)
Since you haven't done the static png/lz thing, I assume your static built might be unstable when you try the screenshot function of Dosbox

Hmm... when I run my build on a clean system (no MacPorts or Xcode or SDL installed, my builds don't capture the screen at all. When I press Ctrl-F5, the console doesn't report that a capture occurred, and nothing gets saved in the ~/Library/Preferences/capture directory. But I'll experiment with the changes you suggested anyway. I'll have to check whether anything happens on my own machine. I think I deliberately removed the screen capture ability (following your instructions) many months ago when I first started to attempt this.

4.

I've edited my first post to explain that the point of all this is to create a portable executable that can be run on anyone's Lion machine.

Thanks for getting back so quickly with this!

Last edited by emendelson on 2011-08-31, 00:08. Edited 1 time in total.

Reply 4 of 18, by Dominus

User metadata
Rank DOSBox Moderator
Rank
DOSBox Moderator

Just to clarify: you're saying that I can ignore the whole paragraph about my sed command?

no, my writings got a little confusing, I think...
Your sed block is fine, it's just that it needs fine tuning, so everything "sdl-config --static-libs" gives back is really in the Libs= line (along with the other things). Your sed block is needed to make a static compile of Dosbox, for use on other machines that don't have macports, SDL etc...
The capture command is not working for you because you probably screwed things up by not adding it statically. Lucky that Dosbox doesn't crash 😀
When you change it so it compiles the libpng/libz things static, it will capture on the other systems as well 😀

Reply 5 of 18, by Dominus

User metadata
Rank DOSBox Moderator
Rank
DOSBox Moderator

you can add another sed line to replace -lpng -lz with opt/local/lib/libpng14.a /opt/local/lib/libz.a (you need to replace it both times of course)

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 6 of 18, by emendelson

User metadata
Rank Oldbie
Rank
Oldbie
Dominus wrote:
no, my writings got a little confusing, I think... Your sed block is fine, it's just that it needs fine tuning, so everything "s […]
Show full quote

Just to clarify: you're saying that I can ignore the whole paragraph about my sed command?

no, my writings got a little confusing, I think...
Your sed block is fine, it's just that it needs fine tuning, so everything "sdl-config --static-libs" gives back is really in the Libs= line (along with the other things). Your sed block is needed to make a static compile of Dosbox, for use on other machines that don't have macports, SDL etc...
The capture command is not working for you because you probably screwed things up by not adding it statically. Lucky that Dosbox doesn't crash :)
When you change it so it compiles the libpng/libz things static, it will capture on the other systems as well :)

OK, will work on this tonight and will edit my post once I get everything working. Thanks again for taking such care over this. As I said in another method, I finally got SDL working by pure dumb luck and by reading error messages from the compiler, not by any knowledge.

Reply 7 of 18, by emendelson

User metadata
Rank Oldbie
Rank
Oldbie
Dominus wrote:

you can add another sed line to replace -lpng -lz with opt/local/lib/libpng14.a /opt/local/lib/libz.a (you need to replace it both times of course)

Actually, my makefile doesn't have -lpng or -lz in it at all. In fact, when I go to stock DOSBox SVN, and run ./autogen.sh and ./configure, the makefile doesn't have png or libz at all. So I'm a bit puzzled by all this. My build does seem to work, and doesn't crash when I press Ctrl-F5...

Reply 8 of 18, by Dominus

User metadata
Rank DOSBox Moderator
Rank
DOSBox Moderator

Strange that it doesn't have -png. Are you sure you installed libpng via macports? Because configure should pick that up when it is availlable.

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 9 of 18, by emendelson

User metadata
Rank Oldbie
Rank
Oldbie
Dominus wrote:

Strange that it doesn't have -png. Are you sure you installed libpng via macports? Because configure should pick that up when it is availlable.

Very strange. When I run "sudo port installed" the output includes this line (among many others):

libpng @1.4.8_0+universal (active)

Again, I don't understand this at all.

Reply 10 of 18, by Dominus

User metadata
Rank DOSBox Moderator
Rank
DOSBox Moderator

Oh, well, let's shrug it off and not think about it anymore 😉

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 11 of 18, by emendelson

User metadata
Rank Oldbie
Rank
Oldbie
Dominus wrote:

Oh, well, let's shrug it off and not think about it anymore ;)

Agreed! My application works perfectly for what it's designed to do. But I'll probably now start experimenting with this, and if I find anything useful, I'll report back.

And, once again, a thousand thanks for making this possible. I hope it's OK with you that I tried to put together your advice this way, even if I got a few things wrong or backwards or otherwise confused!

Reply 12 of 18, by Dominus

User metadata
Rank DOSBox Moderator
Rank
DOSBox Moderator

No problem at all 😉
And yes please report anything back, I like to learn new things too.

I have something I'd really like you to test. I'll pm you.

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 14 of 18, by emendelson

User metadata
Rank Oldbie
Rank
Oldbie

I'm happy to report that DOSBox builds perfectly under OS X Mountain Lion, after updating MacPorts, and using the techniques spelled out by Dominus in other postings in this thread. Thank you again to Dominus!

Last edited by emendelson on 2012-07-26, 12:56. Edited 1 time in total.

Reply 15 of 18, by Dominus

User metadata
Rank DOSBox Moderator
Rank
DOSBox Moderator

😉 indeed it does

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 16 of 18, by rien333

User metadata
Rank Newbie
Rank
Newbie

Sorry for reviving such an old thread, but the code in the OP doesn't work for me. The main problem seems to be that the sed command does nothing for me. For example, my MakeFile has the following two lines:

SDL_CONFIG = /usr/local/bin/sdl-config
SDL_LIBS = -L/usr/local/lib -lSDLmain -lSDL -Wl,-framework,Cocoa

which are exactly the same as in MakeFile.old. It seems to me that I should point this lines to my SDL build, but I'm not sure how they exactly should look like. Can anyone tell what I should direct these type of lines to in my MakeFile to, or what they should approximately look like?

Reply 18 of 18, by pherosiden

User metadata
Rank Newbie
Rank
Newbie
rien333 wrote:

Nevermind btw, found out what I needed to know above.

You can download lasted code from SVN (r4000) and build, this worked fine for me, but only on i386 and only output with surface and overlay, enable opengl build errors, x64 build will error.
https://sourceforge.net/p/dosbox/code-0/HEAD/ … e/dosbox/trunk/

NOTE: on mac, color will display incorrect, red and green is swapped. this is SDL_SetVideoMode error and wait for it fixed.