Developing OS under Mac OS X

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Srowen
Member
Member
Posts: 60
Joined: Thu Feb 26, 2009 2:31 pm
Location: Genova, ITALY

Developing OS under Mac OS X

Post 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..
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Developing OS under Mac OS X

Post 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.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
xDDunce
Member
Member
Posts: 173
Joined: Tue Aug 12, 2008 4:04 pm
Contact:

Re: Developing OS under Mac OS X

Post 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.
Srowen
Member
Member
Posts: 60
Joined: Thu Feb 26, 2009 2:31 pm
Location: Genova, ITALY

Re: Developing OS under Mac OS X

Post by Srowen »

but the gcc that is already installed in leopard (installing Xcode) is ok to compile the o.s.?
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Re: Developing OS under Mac OS X

Post 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
User avatar
Colonel Kernel
Member
Member
Posts: 1437
Joined: Tue Oct 17, 2006 6:06 pm
Location: Vancouver, BC, Canada
Contact:

Re: Developing OS under Mac OS X

Post 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.
Top three reasons why my OS project died:
  1. Too much overtime at work
  2. Got married
  3. My brain got stuck in an infinite loop while trying to design the memory manager
Don't let this happen to you!
quok
Member
Member
Posts: 490
Joined: Wed Oct 18, 2006 10:43 pm
Location: Kansas City, KS, USA

Re: Developing OS under Mac OS X

Post 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.
quok
Member
Member
Posts: 490
Joined: Wed Oct 18, 2006 10:43 pm
Location: Kansas City, KS, USA

Re: Developing OS under Mac OS X

Post 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.
Srowen
Member
Member
Posts: 60
Joined: Thu Feb 26, 2009 2:31 pm
Location: Genova, ITALY

Re: Developing OS under Mac OS X

Post 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:
User avatar
Steve the Pirate
Member
Member
Posts: 152
Joined: Fri Dec 15, 2006 7:01 am
Location: Brisbane, Australia
Contact:

Re: Developing OS under Mac OS X

Post by Steve the Pirate »

I followed the tutorial, and it was very easy - what exactly was your problem with it?
My Site | My Blog
Symmetry - My operating system.
Srowen
Member
Member
Posts: 60
Joined: Thu Feb 26, 2009 2:31 pm
Location: Genova, ITALY

Re: Developing OS under Mac OS X

Post 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'.
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Re: Developing OS under Mac OS X

Post 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
User avatar
Steve the Pirate
Member
Member
Posts: 152
Joined: Fri Dec 15, 2006 7:01 am
Location: Brisbane, Australia
Contact:

Re: Developing OS under Mac OS X

Post 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...
My Site | My Blog
Symmetry - My operating system.
Srowen
Member
Member
Posts: 60
Joined: Thu Feb 26, 2009 2:31 pm
Location: Genova, ITALY

Re: Developing OS under Mac OS X

Post 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
Srowen
Member
Member
Posts: 60
Joined: Thu Feb 26, 2009 2:31 pm
Location: Genova, ITALY

Re: Developing OS under Mac OS X

Post 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..
Post Reply