public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* compile kernel
@ 2011-09-09  7:52 esmaeil mirzaee
  2011-09-09  8:22 ` Axel Freyn
  2011-09-09  8:56 ` Pelle Windestam
  0 siblings, 2 replies; 5+ messages in thread
From: esmaeil mirzaee @ 2011-09-09  7:52 UTC (permalink / raw)
  To: kernelnewbies, gcc-help

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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: compile kernel
  2011-09-09  7:52 compile kernel esmaeil mirzaee
@ 2011-09-09  8:22 ` Axel Freyn
  2011-09-09  8:56 ` Pelle Windestam
  1 sibling, 0 replies; 5+ messages in thread
From: Axel Freyn @ 2011-09-09  8:22 UTC (permalink / raw)
  To: gcc-help

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: compile kernel
  2011-09-09  7:52 compile kernel esmaeil mirzaee
  2011-09-09  8:22 ` Axel Freyn
@ 2011-09-09  8:56 ` Pelle Windestam
  2011-09-09  9:17   ` esmaeil mirzaee
  1 sibling, 1 reply; 5+ messages in thread
From: Pelle Windestam @ 2011-09-09  8:56 UTC (permalink / raw)
  To: esmaeil mirzaee; +Cc: kernelnewbies, gcc-help

>
> $ gcc acct.c -o ac
> acct.c:46: fatal error: linux/mm.h: No such file or directory
> compilation terminated.
>

That is because gcc does not know where to look for the included
mm.h-file, the gcc compiler needs to be specifically told where to
look for include files if they are not in the standard directories.
You can do that by passing it the -I option followed by the directory
to look in.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: compile kernel
  2011-09-09  8:56 ` Pelle Windestam
@ 2011-09-09  9:17   ` esmaeil mirzaee
  2011-09-09 10:07     ` Jonathan Wakely
  0 siblings, 1 reply; 5+ messages in thread
From: esmaeil mirzaee @ 2011-09-09  9:17 UTC (permalink / raw)
  To: Pelle Windestam; +Cc: kernelnewbies, gcc-help

Thank you for reply

On Fri, Sep 9, 2011 at 4:55 AM, Pelle Windestam <pelle@windestam.se> wrote:
>>
>> $ gcc acct.c -o ac
>> acct.c:46: fatal error: linux/mm.h: No such file or directory
>> compilation terminated.
>>
>
> That is because gcc does not know where to look for the included
> mm.h-file, the gcc compiler needs to be specifically told where to
> look for include files if they are not in the standard directories.
> You can do that by passing it the -I option followed by the directory
> to look in.

You mean I must put the address of library when I try to compile if yes.
~/linux-2.6.39.3/kernel the file is in this place (acct.c).
Could you give me form of compile command it can be like this
gcc -i ~/linux-2.6.39.3/kernel acct.c -o acct

esmaeil

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: compile kernel
  2011-09-09  9:17   ` esmaeil mirzaee
@ 2011-09-09 10:07     ` Jonathan Wakely
  0 siblings, 0 replies; 5+ messages in thread
From: Jonathan Wakely @ 2011-09-09 10:07 UTC (permalink / raw)
  To: esmaeil mirzaee; +Cc: Pelle Windestam, kernelnewbies, gcc-help

On 9 September 2011 10:16, esmaeil mirzaee wrote:
> Thank you for reply
>
> On Fri, Sep 9, 2011 at 4:55 AM, Pelle Windestam <pelle@windestam.se> wrote:
>>>
>>> $ gcc acct.c -o ac
>>> acct.c:46: fatal error: linux/mm.h: No such file or directory
>>> compilation terminated.
>>>
>>
>> That is because gcc does not know where to look for the included
>> mm.h-file, the gcc compiler needs to be specifically told where to
>> look for include files if they are not in the standard directories.
>> You can do that by passing it the -I option followed by the directory
>> to look in.
>
> You mean I must put the address of library when I try to compile if yes.

The location of the header files, not libraries.  And -I is not the same as -i

> ~/linux-2.6.39.3/kernel the file is in this place (acct.c).
> Could you give me form of compile command it can be like this
> gcc -i ~/linux-2.6.39.3/kernel acct.c -o acct

As Axel said on the gcc-help list, you cannot compile the kernel like
that, acct.c is only one small part of a much larger system. You need
to use the makefiles generated by the kernel configuration process,
which contain the "recipes" for compiling the pieces of the kernel and
linking them together.

You should probably start with something simpler than the Linux kernel.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-09-09 10:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-09  7:52 compile kernel esmaeil mirzaee
2011-09-09  8:22 ` Axel Freyn
2011-09-09  8:56 ` Pelle Windestam
2011-09-09  9:17   ` esmaeil mirzaee
2011-09-09 10:07     ` Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).