Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have a Mac running Snow Leopard and I know that I cannot compile the Linux kernel. I have used a Linux VM (virtualbox) to compile the kernel but I was wondering if I could compile it on Eclipse (galileo).

share|improve this question
7  
What does eclipse have to do with compiling linux? You need a toolchain, not an ide. –  vh4x0r Mar 7 '13 at 15:05
1  
You need a Linux-style environment to build the kernel (I very much doubt anybody has built it on anything but Linux, for a long, long time now, so trying to build on MacOS could be an interesting experience...). –  vonbrand Mar 7 '13 at 20:50
add comment

2 Answers 2

The info saying you can't build the kernel in Mac is innacurate. One can set up a cross compiler and have x86 as target architecture or build a kernel for power pc as Yellowdog Linux Distro has done. A sample of a procedure to setup a cross compiler for ARM7:

I’m start­ing a new embed­ded project with ARM7 proces­sor in March so I wanted to play around with the GNU ARM tool­chain. Basi­cally I’m inter­ested in doing cross devel­op­ment on my Mac­book Pro on Mac OS X, using a GCC cross com­piler together with Eclipse CDT. We’ll see if that works out. ;-)

So as a first step, here is how I built a GNU ARM tool­chain on Mac OS X (this should be no dif­fer­ent than build­ing the tool­chain on Linux):

First down­load and unpack the nec­es­sary pack­ages: binu­tils, gcc, newlib and gdb.

$ mkdir ~/crossgcc && cd ~/crossgcc
$ wget ftp://sourceware.org/pub/binutils/snapshots/binutils-2.18.50.tar.bz2
$ tar jxf binutils-2.18.50.tar.bz2
$ wget http://ftp.gnu.org/pub/gnu/gcc/gcc-4.2.3/gcc-4.2.3.tar.bz2
$ tar jxf gcc-4.2.3.tar.bz2
$ wget ftp://sources.redhat.com/pub/newlib/newlib-1.16.0.tar.gz
$ tar zxf newlib-1.16.0.tar.gz
$ wget http://ftp.gnu.org/pub/gnu/gdb/gdb-6.6.tar.gz
$ tar zxf gdb-6.6.tar.gz

The instal­la­tion direc­tory should be /usr/local/crossgcc.

$ sudo mkdir /usr/local/crossgcc
$ sudo chmod 777 /usr/local/crossgcc

First we build the binu­tils:

$ mkdir build-binutils && cd build-binutils
$ ../binutils-2.18.50/configure --target=arm-elf \
--prefix=/usr/local/crossgcc/ 2>&1 | tee configure.log
$ make all install 2>&1 | tee make.log
$ export PATH=$PATH:/usr/local/crossgcc/bin

Build the gcc com­piler with C/C++ sup­port:

$ cd ../gcc-4.2.3
$ ln -s ../newlib-1.16.0/newlib .
$ ln -s ../newlib-1.16.0/libgloss .
$ cd ..
$ mkdir build-gcc && cd build-gcc
$ ../gcc-4.2.3/configure --target=arm-elf \
--prefix=/usr/local/crossgcc/ --with-newlib \
--with-gnu-as --with-gnu-ld --enable-languages=c,c++ 2>&1 | tee configure.log
$ make all install 2>&1 | tee make.log

Build the gdb debug­ger:

$ cd ..
$ mkdir build-gdb && cd build-gdb
$ ../gdb-6.6/configure --target=arm-elf --prefix=/usr/local/crossgcc/
$ make all install 2>&1 | tee make.log

In your case tou need a cross compiler to whatever target architecture you wan't your kernel to be. Notice as compilation will run nativelly in your machine it will be faster than building on VirtualBox.

share|improve this answer
add comment

As long as you have all of the headers and proper tools, Linux kernels can be compiled on other systems. Using Eclipse would not work well (if at all). In a Linux command-line, type "make config". Configure the options for your kernel that is to be made. Then, read the README file that comes with the source code. It will provide information on compiling and installing. For deep information on the kernel, read this article series (http://www.linux.org/threads/%EF%BB%BFthe-linux-kernel-introduction.4203/).

share|improve this answer
    
This is false -- the Linux kernel can be cross-compiled on many other systems. As long as you use a cross-compiler toolchain and have the right headers, it should be fine. I know for a fact it built on OSX, because I did it before in a particularly desperate situation. –  Chris Down Aug 28 '13 at 13:35
1  
Also this comment about "case-sensitive" filesystem makes no sense. –  vfbsilva Sep 2 '13 at 18:28
    
@vfbsilva, thanks for the comment instead of a down-vote. –  Devyn Collier Johnson Sep 3 '13 at 10:42
    
@DevynCollierJohnson also the instructions for building the kernel do not differ when using a compiler or a cross compiler, the toolchains behave equally. I.e. if this is gcc same flags will apply (usually this is the case). Notice this has already been long poitend out by vh4x0r. –  vfbsilva Sep 3 '13 at 13:51
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.