Page 1 of 2

Developing OS under Mac OS X

Posted: Thu Feb 26, 2009 2:45 pm
by Srowen
Hello everbody of the forum!
I'm an italian engineering student and i'm trying to develop my own s.o. I follow the Bran's Kernel Development Tutorial and i finished it.
But now i decide to re-write my o.s.. I'm a MacBook user and i don't like to use virtual machine to emulate windows or linux. So i decide to use the Mac os X compiler, the gcc. With .c files and .asm files there aren't any problem but when i use the linker (the same code of the tutorial) i've got some problem and so i can't get the .bin file.
does anyone use leopard or tiger to develop his os? can anyone help me? maybe there is a tutorial on how to set up for example net beans or similar... thanks for your help..

Re: Developing OS under Mac OS X

Posted: Thu Feb 26, 2009 3:16 pm
by Combuster
I haven't got a Mac, but you should try making a GCC Cross-Compiler, which should help. After that you can just set your favorite editor to use the generated applications.

Re: Developing OS under Mac OS X

Posted: Thu Feb 26, 2009 3:34 pm
by xDDunce
yes, i had the same kind of trouble. a cross-compiler sorted my problem out though so try that.

i can verify that gcc 4.2.4 and the latest binutils both compile without any errors using the wiki tutorial and the Mac terminal.

Good Luck!
James.

Re: Developing OS under Mac OS X

Posted: Fri Feb 27, 2009 9:50 am
by Srowen
but the gcc that is already installed in leopard (installing Xcode) is ok to compile the o.s.?

Re: Developing OS under Mac OS X

Posted: Fri Feb 27, 2009 9:57 am
by jal
Srowen wrote:but the gcc that is already installed in leopard (installing Xcode) is ok to compile the o.s.?
What executable format does Mac use? elf? If so, yes, if not, probably no.


JAL

Re: Developing OS under Mac OS X

Posted: Fri Feb 27, 2009 10:01 am
by Colonel Kernel
Srowen wrote:but the gcc that is already installed in leopard (installing Xcode) is ok to compile the o.s.?
No, you will need to create a gcc cross-compiler.

Re: Developing OS under Mac OS X

Posted: Fri Feb 27, 2009 10:12 am
by quok
jal wrote:
Srowen wrote:but the gcc that is already installed in leopard (installing Xcode) is ok to compile the o.s.?
What executable format does Mac use? elf? If so, yes, if not, probably no.

JAL
You'll need a cross compiler, unless you plan on using the Mach-O format. The GCC that's installed by default is only capable of producing Mach-O files (and Universal Binaries, of course). I use GCC 4.2.4 and Binutils 2.18 without any problems. The cross-compiler tutorial on the wiki works without any problems, provided you of course follow the instructions. :)

If you have problems though, I can create a generic i586-elf and x86_64-elf toolchain for OS X, throw it into a DMG and send it your way. Earlier this week I took my script that does the cross-tools compilation and made it work with macports.

Speaking of macports, you may be able to install a gcc from there that will create ELF files, but I haven't tried it yet, so it may not work.

Re: Developing OS under Mac OS X

Posted: Fri Feb 27, 2009 10:42 am
by quok
quok wrote: Speaking of macports, you may be able to install a gcc from there that will create ELF files, but I haven't tried it yet, so it may not work.
Just checked this out... GCC 4.0.1 is default on OS X 10.5. If you have macports installed, the easiest way to get an i386-elf cross compiler is to do this:

Code: Select all

$ port install i386-elf-gcc
$ port install i386-elf-binutils
These are at versions 4.3.2 and 2.18.50.0.9 respectively, so if you want to use versions other than those, you're on your own as far as macports is concerned.

Re: Developing OS under Mac OS X

Posted: Fri Feb 27, 2009 4:27 pm
by Srowen
i've got some problem with the mac ports.. if you can create the dmg file you make me a very happy man! :D :D

i also tired with the tutorial but i think to do something wrong.. :roll:

Re: Developing OS under Mac OS X

Posted: Fri Feb 27, 2009 6:51 pm
by Steve the Pirate
I followed the tutorial, and it was very easy - what exactly was your problem with it?

Re: Developing OS under Mac OS X

Posted: Sat Feb 28, 2009 3:54 am
by Srowen
When i try to do the command

Code: Select all

../gcc-x.x.x/configure --target=$TARGET --prefix=$PREFIX --disable-nls 
       --enable-languages=c,c++ --without-headers


it say:

Code: Select all

configure: error: Building GCC requires GMP 4.1+ and MPFR 2.3.0+.
Try the --with-gmp and/or --with-mpfr options to specify their locations.
Copies of these libraries' source code can be found at their respective
hosting sites as well as at ftp://gcc.gnu.org/pub/gcc/infrastructure/.
See also http://gcc.gnu.org/install/prerequisites.html for additional info.
If you obtained GMP and/or MPFR from a vendor distribution package, make
sure that you have installed both the libraries and the header files.
They may be located in separate packages.
and also before, when i build the binutilis, it say, at the end, after the command "make install":

Code: Select all

make[3]: Nothing to be done for `install'.
make[1]: Nothing to be done for `install-target'.

Re: Developing OS under Mac OS X

Posted: Sat Feb 28, 2009 4:10 am
by AJ
Hi,

To build the latest versions of GCC (4.3.+, I think), you need GMP and MPFR - the versions that come with Cygwin are too old. There is a note about that in the Cross Compiler article along with a link to a page showing you how to build GMP and MPFR.

Cheers,
Adam

Re: Developing OS under Mac OS X

Posted: Sat Feb 28, 2009 4:15 am
by Steve the Pirate
Yep, just download the GMP and MPFR libraries, and build them as normal (if I remember correctly) - ie. don't use the prefix and target configure options.

I don't know about your second problem though...

Re: Developing OS under Mac OS X

Posted: Sat Feb 28, 2009 4:22 am
by Srowen
i tried the gcc version 3.3 and now, at the command "make all-gcc" it say:

Code: Select all

../../gcc-3.3/gcc/crtstuff.c: In function `frame_dummy':
../../gcc-3.3/gcc/crtstuff.c:316: warning: passing arg 1 of `__register_frame_info' discards qualifiers from pointer target type
make[1]: *** [crtbegin.o] Error 1
make: *** [all-gcc] Error 2

Re: Developing OS under Mac OS X

Posted: Sat Feb 28, 2009 4:25 am
by Srowen
mmm.. i had

Code: Select all

   ../gcc-x.x.x/configure --target=$TARGET --prefix=$PREFIX --disable-nls \
       --enable-languages=c,c++ --without-headers    --with-newlib
now i think to have compiled it...no error message..