Re: compile kernel

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Esmaeil,
On Fri, Sep 09, 2011 at 03:52:29AM -0400, esmaeil mirzaee wrote:
> Hi all
> I apologize for weak English and speaking ambiguously.
> 
> I download Linux kernel and I love to learn about it.
> I try to compile a file like ~/kernel/acct.c but I've got error anyone
> can help me.
> 
> $ gcc acct.c -o ac
> acct.c:46: fatal error: linux/mm.h: No such file or directory
> compilation terminated.
You should first learn with smaller projects :-) you CAN'T compile the
linux kernel this way (just by passing single files to gcc). Instead:
 - you need specific flags on the command line
 - you have to tell gcc where to look for include files (e.g. where to
   find "linux/mm.h"), also by passing appropriate command line flags
 - you can only compile a single file (adding "-c" to the command line),
   you can't link it into an executable (that's what you tried).
All this procedure is automated for the linux kernel by its Makefile:
The standard way of compiling the kernel is (you can also google for it):
"make menuconfig" (this will ask you MANY questions about which drivers to
include into the kernel)
"make" (to compile and link the kernel itself -- this will run "gcc")
"make modules" (to compile all kernel modules)
"make install" (to install the kernel)

By the ways, that's not a real gcc-related question, so it might be
better to ask it on a mailing-list of your linux-distribution (there,
the people will know how you can install all software necessary to
compile a kernel).

Axel


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux