|
Post by Axl on Jan 22, 2014 6:14:14 GMT -8
What would I need to compile myself under MacOS X?
Current status:
➜ 8086tiny_100 uname -a Darwin Axl.local 12.5.0 Darwin Kernel Version 12.5.0: Sun Sep 29 13:33:47 PDT 2013; root:xnu-2050.48.12~1/RELEASE_X86_64 x86_64
➜ 8086tiny_100 make cc 8086tiny.c `sdl-config --cflags --libs` -o 8086tiny -O3 -fsigned-char /bin/sh: sdl-config: command not found 8086tiny.c:17:10: fatal error: 'SDL.h' file not found #include "SDL.h" ^ 1 error generated. make: *** [8086tiny] Error 1
➜ 8086tiny_100 mdfind -name SDL.h ➜ 8086tiny_100
Thanks
|
|
|
Post by jgeorge on Jan 22, 2014 11:18:05 GMT -8
there's no sdl-config for the OSX SDL. You'll need to manually generate the headers you need. I'm using:
OPTS=-L/Library/Frameworks/SDL.framework -lSDL -I/Library/Frameworks/SDL.framework/Headers -D_GNU_SOURCE=1 -D_REENTRANT
That seems to help, but I can't say that it works, since I can't actually link 8086tiny this way. On my Mac I get:
ld: library not found for -lSDL clang: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [8086tiny] Error 1
So I may not have the -L and -l correct. I think the Mac may be looking for "SDL.dylib" instead of just plain "SDL". I didn't have any success getting the IOCCC source to compile on OSX either, but it compiled under Linux just fine.
|
|
|
Post by jgeorge on Jan 22, 2014 11:40:45 GMT -8
Actually, this fixes the linker error.
OPTS=-framework SDL -I/Library/Frameworks/SDL.framework/Headers -D_GNU_SOURCE=1 -D_REENTRANT
I still can't compile it though, ld fails to find a _main entry point:
Undefined symbols for architecture x86_64: "_main", referenced from: implicit entry/start for main executable (maybe you meant: _SDL_main) ld: symbol(s) not found for architecture x86_64
|
|
|
Post by Adrian Cable on Jan 22, 2014 17:32:59 GMT -8
Interesting - I'd like to know if you resolve this. I use Mac OS X as my main development platform and I have sdl-config. I don't need any changes to the Makefile so things compile.
FYI, my sdl-config outputs the following, which might be useful (particularly the SDLmain bit):
-L/opt/local/lib -lSDLmain -Wl,-framework,AppKit -lSDL -Wl,-framework,Cocoa -I/opt/local/include/SDL -D_GNU_SOURCE=1 -D_THREAD_SAFE
-Adrian
|
|
|
Post by Axl on Jan 23, 2014 0:15:01 GMT -8
Hi Adrian,
how did you install SDL into /opt/local?
|
|
|
Post by Adrian Cable on Jan 23, 2014 3:18:30 GMT -8
Hi Axl, I installed SDL such a long time ago I'm afraid it's difficult to recall!
But, the important thing in my post I think was that -lSDLmain should fix the linker error. Locations of the include files and libraries shouldn't make a difference.
-Adrian
|
|
|
Post by Axl on Jan 23, 2014 5:57:04 GMT -8
I use the .dmg download from www.libsdl.org/download-2.0.php and installed this into /Library/Frameworks/SDL2.framework. $ make OPTS="-L/Library/Frameworks/SDL2.framework -I/Library/Frameworks/SDL2.framework/Headers -D_GNU_SOURCE=1 -D_REENTRANT" CC=gcc This cannot be linked and trying to use "-lSDLmain" doesn't help since there is no SDLmain available. The only lib with SDL2 seems to be $ file /Library/Frameworks/SDL2.framework/SDL2 /Library/Frameworks/SDL2.framework/SDL2: Mach-O universal binary with 2 architectures /Library/Frameworks/SDL2.framework/SDL2 (for architecture x86_64): Mach-O 64-bit dynamically linked shared library x86_64 /Library/Frameworks/SDL2.framework/SDL2 (for architecture i386): Mach-O dynamically linked shared library i386 but -lSDL2 didn't help either. Regards, Axl.
|
|
|
Post by jgeorge on Jan 23, 2014 8:03:39 GMT -8
Adrian, I'm guessing you probably build SDL from source, I think thats the only way you'd get sdl-config on OS X. Let me try building it (instead of downloading the OS X runtime from libsdl.org) and see if that helps at all.
|
|
|
Post by Adrian Cable on Jan 23, 2014 9:43:17 GMT -8
Axl/jgeorge, Two ideas: first you will need the SDL development libraries rather than the runtime libraries. This will include sdl-config and also everything else you will need to build any application (not just 8086tiny) that needs SDL.
Second, you will need SDL 1.2. SDL 2.0 uses a completely different and incompatible API which at the moment isn't supported. If experience shows there are good reasons why I should move to SDL 2.0 (e.g. support for more platforms?) then I would happily consider it.
-Adrian
|
|
|
Post by jgeorge on Jan 23, 2014 11:05:50 GMT -8
Here we go, this works for me: 1) Download SDL 1.2.15 source from libsdl.org/release/SDL-1.2.15.tar.gz2) Download the SDL patch at hg.libsdl.org/SDL/raw-rev/91ad7b43317a into a file (call it "sdl.diff" for example) 3) Unzip the source and apply the patch: gzcat SDL-1.2.15.tar.gz | tar -xvf - cd SDL-1.2.15 patch -p1 < ../sdl.diff 4) Make the SDL Library (this installs in /usr/local/lib and installs sdl-config) sh autogen.sh && sh configure make sudo make install 5) Now you can make 8086tiny from the unmodified source. On Mountain Lion it generates 34 warnings but compiles 6) run 8086 tiny via the runme script I still haven't had any luck compiling with the OS X specific SDL runtime (in /Library/Framework) but this works. A lot of thanks to Adrian for this fantastic little emulator. Joe
|
|
|
Post by Adrian Cable on Jan 23, 2014 13:17:32 GMT -8
Great to hear! A new version will be available in the next couple of days with cleaned-up source so it's warning-free. But, for now, you can safely ignore the warnings.
-Adrian
|
|
|
Post by jgeorge on Jan 23, 2014 14:00:57 GMT -8
Great! I really appreciate all the work you've put into this, it's completely fascinating to me that you can emulate an 8086 in such a ridiculously small amount of code.
In a future version, can you include assistance for how to compile the bios with nasm? OS X seems to choke on int1 and int3 being reserved keywords.
|
|
|
Post by jgeorge on Jan 23, 2014 14:09:03 GMT -8
Axl, if you're building on Mavericks the instructions I posted above will work, except you need to download one more patch (from hg.libsdl.org/SDL/rev/e9466ead70e5) and apply it when building libSDL. Cheers, Joe
|
|
|
Post by Adrian Cable on Jan 23, 2014 16:11:03 GMT -8
jgeorge, Which version of nasm are you using? I just downloaded the latest (NASM 2.11) for Mac OS X and used:
./nasm bios.asm
The result: a working BIOS binary with no errors. Can you give more detail on which NASM version you are using and how you are trying to compile bios.asm?
Thanks!
-Adrian
|
|
|
Post by jgeorge on Jan 23, 2014 21:10:20 GMT -8
Hey Adrian,
The nasm I have in mavericks is apparently VERY old, but its what shipped with the OS.
$ nasm -v NASM version 0.98.40 (Apple Computer, Inc. build 11) compiled on Aug 13 2013
$ nasm bios.asm bios.asm:2505: error: expression syntax error bios.asm:2506: error: expression syntax error bios.asm:2507: error: expression syntax error bios.asm:2508: error: expression syntax error bios.asm:2509: error: expression syntax error bios.asm:2530: error: expression syntax error bios.asm:2532: error: expression syntax error bios.asm:3167: error: expression syntax error bios.asm:3256: error: expression syntax error bios.asm:3260: error: expression syntax error
I installed nasm-2.11 and it ors indeed compile without error. Thanks for the tip!
Joe
|
|