LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-08-2009, 05:40 PM   #1
sulacco
Member
 
Registered: Apr 2006
Posts: 46

Rep: Reputation: 15
Have a trouble with compiling simple dirver.


Hi, ppl. I'm from windows world, but very much like to switch to real
working with hardwere, here is my problem:

i need to compile such a simple dirver(using Fedora 8):
<code>
#include <linux/module.h>

static int hello_init(void)
{
return 0;
}

static void hello_exit(void)
{
return;
}

module_init(hello_init);
module_exit(hello_exit);

</code>




While trying to compile a this simple piece of software I have went through many difficulties such as compiling and installing kernel and
learned much things but still have errors. I learned that some headers needed to be installed, but there so many Linux clones and everyone of them use different schedules to do this. There comes errors:

Code:
gcc -O2 -DMODULE -D__KERNEL__ -W -Wall -Wstrict-prototypes -Wmissing-prototypes -isystem /lib/modules/`uname -r`/build/include   -c -o hello.o hello.c
In file included from /lib/modules/2.6.28/build/include/linux/prefetch.h:13,
                 from /lib/modules/2.6.28/build/include/linux/list.h:6,
                 from /lib/modules/2.6.28/build/include/linux/module.h:9,
                 from hello.c:1:
/lib/modules/2.6.28/build/include/linux/types.h:198: error: expected  =',  ,',  ;',  asm' or  __attribute__' before  phys_addr_t'
/lib/modules/2.6.28/build/include/linux/types.h:201: error: expected  =',  ,',  ;',  asm' or  __attribute__' before  resource_size_t'
In file included from /lib/modules/2.6.28/build/include/linux/list.h:6,
                 from /lib/modules/2.6.28/build/include/linux/module.h:9,
                 from hello.c:1:
/lib/modules/2.6.28/build/include/linux/prefetch.h:14:27: error: asm/processor.h: No such file or directory
/lib/modules/2.6.28/build/include/linux/prefetch.h:15:23: error: asm/cache.h: No such file or directory
In file included from /lib/modules/2.6.28/build/include/linux/module.h:9,
                 from hello.c:1:
/lib/modules/2.6.28/build/include/linux/list.h:7:24: error: asm/system.h: No such file or directory
In file included from /lib/modules/2.6.28/build/include/linux/kernel.h:11,
                 from /lib/modules/2.6.28/build/include/linux/cache.h:4,
                 from /lib/modules/2.6.28/build/include/linux/time.h:7,
                 from /lib/modules/2.6.28/build/include/linux/stat.h:60,
                 from /lib/modules/2.6.28/build/include/linux/module.h:10,
                 from hello.c:1:
/lib/modules/2.6.28/build/include/linux/linkage.h:5:25: error: asm/linkage.h: No such file or directory
In file included from /lib/modules/2.6.28/build/include/linux/kernel.h:15,
                 from /lib/modules/2.6.28/build/include/linux/cache.h:4,
                 from /lib/modules/2.6.28/build/include/linux/time.h:7,
                 from /lib/modules/2.6.28/build/include/linux/stat.h:60,
                 from /lib/modules/2.6.28/build/include/linux/module.h:10,
                 from hello.c:1:
/lib/modules/2.6.28/build/include/linux/bitops.h:17:24: error: asm/bitops.h: No such file or directory
In file included from /lib/modules/2.6.28/build/include/linux/kernel.h:16,
                 from /lib/modules/2.6.28/build/include/linux/cache.h:4,
                 from /lib/modules/2.6.28/build/include/linux/time.h:7,
                 from /lib/modules/2.6.28/build/include/linux/stat.h:60,
                 from /lib/modules/2.6.28/build/include/linux/module.h:10,
                 from hello.c:1:
/lib/modules/2.6.28/build/include/linux/log2.h:32: error: expected  )' before  n'
/lib/modules/2.6.28/build/include/linux/log2.h:40: error: expected  )' before  n'
In file included from /lib/modules/2.6.28/build/include/linux/byteorder/little_endian.h:106,
                 from /usr/include/asm/byteorder.h:53,
                 from /lib/modules/2.6.28/build/include/linux/kernel.h:20,
                 from /lib/modules/2.6.28/build/include/linux/cache.h:4,
                 from /lib/modules/2.6.28/build/include/linux/time.h:7,
                 from /lib/modules/2.6.28/build/include/linux/stat.h:60,
                 from /lib/modules/2.6.28/build/include/linux/module.h:10,
                 from hello.c:1:
/lib/modules/2.6.28/build/include/linux/byteorder/generic.h:143: error: expected declaration specifiers or  ...' before  u16'
/lib/modules/2.6.28/build/include/linux/byteorder/generic.h: In function  le16_add_cpu':
/lib/modules/2.6.28/build/include/linux/byteorder/generic.h:145: error:  val' undeclared (first use in this function)
/lib/modules/2.6.28/build/include/linux/byteorder/generic.h:145: error: (Each undeclared identifier is reported only once
/lib/modules/2.6.28/build/include/linux/byteorder/generic.h:145: error: for each function it appears in.)
/lib/modules/2.6.28/build/include/linux/byteorder/generic.h: At top level:
/lib/modules/2.6.28/build/include/linux/byteorder/generic.h:148: error: expected declaration specifiers or  ...' before  u32'
/lib/modules/2.6.28/build/include/linux/byteorder/generic.h: In function  le32_add_cpu':
/lib/modules/2.6.28/build/include/linux/byteorder/generic.h:150: error:  val' undeclared (first use in this function)
/lib/modules/2.6.28/build/include/linux/byteorder/generic.h: At top level:
/lib/modules/2.6.28/build/include/linux/byteorder/generic.h:153: error: expected declaration specifiers or  ...' before  u64'
/lib/modules/2.6.28/build/include/linux/byteorder/generic.h: In function  le64_add_cpu':
/lib/modules/2.6.28/build/include/linux/byteorder/generic.h:155: error:  val' undeclared (first use in this function)
/lib/modules/2.6.28/build/include/linux/byteorder/generic.h: At top level:
/lib/modules/2.6.28/build/include/linux/byteorder/generic.h:158: error: expected declaration specifiers or  ...' before  u16'
/lib/modules/2.6.28/build/include/linux/byteorder/generic.h: In function  be16_add_cpu':
/lib/modules/2.6.28/build/include/linux/byteorder/generic.h:160: error:  val' undeclared (first use in this function)
/lib/modules/2.6.28/build/include/linux/byteorder/generic.h: At top level:
/lib/modules/2.6.28/build/include/linux/byteorder/generic.h:163: error: expected declaration specifiers or  ...' before  u32'
/lib/modules/2.6.28/build/include/linux/byteorder/generic.h: In function  be32_add_cpu':
/lib/modules/2.6.28/build/include/linux/byteorder/generic.h:165: error:  val' undeclared (first use in this function)
/lib/modules/2.6.28/build/include/linux/byteorder/generic.h: At top level:
/lib/modules/2.6.28/build/include/linux/byteorder/generic.h:168: error: expected declaration specifiers or  ...' before  u64'
/lib/modules/2.6.28/build/include/linux/byteorder/generic.h: In function  be64_add_cpu':
/lib/modules/2.6.28/build/include/linux/byteorder/generic.h:170: error:  val' undeclared (first use in this function)
In file included from /lib/modules/2.6.28/build/include/linux/cache.h:4,
                 from /lib/modules/2.6.28/build/include/linux/time.h:7,
                 from /lib/modules/2.6.28/build/include/linux/stat.h:60,
                 from /lib/modules/2.6.28/build/include/linux/module.h:10,
                 from hello.c:1:
/lib/modules/2.6.28/build/include/linux/kernel.h:21:21: error: asm/bug.h: No such file or directory
In file included from /lib/modules/2.6.28/build/include/linux/cache.h:4,
                 from /lib/modules/2.6.28/build/include/linux/time.h:7,
                 from /lib/modules/2.6.28/build/include/linux/stat.h:60,
                 from /lib/modules/2.6.28/build/include/linux/module.h:10,
                 from hello.c:1:
/lib/modules/2.6.28/build/include/linux/kernel.h: At top level:
/lib/modules/2.6.28/build/include/linux/kernel.h:314: error: expected declaration specifiers or  ...' before  u8'
/lib/modules/2.6.28/build/include/linux/kernel.h: In function  pack_hex_byte':
/lib/modules/2.6.28/build/include/linux/kernel.h:316: error:  byte' undeclared (first use in this function)
In file included from /lib/modules/2.6.28/build/include/linux/preempt.h:9,
                 from /lib/modules/2.6.28/build/include/linux/spinlock.h:50,
                 from /lib/modules/2.6.28/build/include/linux/seqlock.h:29,
                 from /lib/modules/2.6.28/build/include/linux/time.h:8,
                 from /lib/modules/2.6.28/build/include/linux/stat.h:60,
                 from /lib/modules/2.6.28/build/include/linux/module.h:10,
                 from hello.c:1:
/lib/modules/2.6.28/build/include/linux/thread_info.h: At top level:
/lib/modules/2.6.28/build/include/linux/thread_info.h:26: error: expected specifier-qualifier-list before  u32'
/lib/modules/2.6.28/build/include/linux/thread_info.h:39: error: expected specifier-qualifier-list before  u64'
In file included from /lib/modules/2.6.28/build/include/linux/preempt.h:9,
                 from /lib/modules/2.6.28/build/include/linux/spinlock.h:50,
                 from /lib/modules/2.6.28/build/include/linux/seqlock.h:29,
                 from /lib/modules/2.6.28/build/include/linux/time.h:8,
                 from /lib/modules/2.6.28/build/include/linux/stat.h:60,
                 from /lib/modules/2.6.28/build/include/linux/module.h:10,
                 from hello.c:1:
/lib/modules/2.6.28/build/include/linux/thread_info.h:55:29: error: asm/thread_info.h: No such file or directory
/lib/modules/2.6.28/build/include/linux/thread_info.h: In function  set_ti_thread_flag':
/lib/modules/2.6.28/build/include/linux/thread_info.h:66: error: dereferencing pointer to incomplete type
/lib/modules/2.6.28/build/include/linux/thread_info.h: In function  clear_ti_thread_flag':
/lib/modules/2.6.28/build/include/linux/thread_info.h:71: error: dereferencing pointer to incomplete type
/lib/modules/2.6.28/build/include/linux/thread_info.h: In function  test_and_set_ti_thread_flag':
/lib/modules/2.6.28/build/include/linux/thread_info.h:76: error: dereferencing pointer to incomplete type
/lib/modules/2.6.28/build/include/linux/thread_info.h: In function  test_and_clear_ti_thread_flag':
/lib/modules/2.6.28/build/include/linux/thread_info.h:81: error: dereferencing pointer to incomplete type
/lib/modules/2.6.28/build/include/linux/thread_info.h: In function  test_ti_thread_flag':
/lib/modules/2.6.28/build/include/linux/thread_info.h:86: error: dereferencing pointer to incomplete type
In file included from /lib/modules/2.6.28/build/include/linux/seqlock.h:29,
                 from /lib/modules/2.6.28/build/include/linux/time.h:8,
                 from /lib/modules/2.6.28/build/include/linux/stat.h:60,
                 from /lib/modules/2.6.28/build/include/linux/module.h:10,
                 from hello.c:1:
/lib/modules/2.6.28/build/include/linux/spinlock.h:348:24: error: asm/atomic.h: No such file or directory
In file included from /lib/modules/2.6.28/build/include/linux/seqlock.h:29,
                 from /lib/modules/2.6.28/build/include/linux/time.h:8,
                 from /lib/modules/2.6.28/build/include/linux/stat.h:60,
                 from /lib/modules/2.6.28/build/include/linux/module.h:10,
                 from hello.c:1:
/lib/modules/2.6.28/build/include/linux/spinlock.h: At top level:
/lib/modules/2.6.28/build/include/linux/spinlock.h:357: error: expected  )' before  *' token
In file included from /lib/modules/2.6.28/build/include/linux/time.h:9,
                 from /lib/modules/2.6.28/build/include/linux/stat.h:60,
                 from /lib/modules/2.6.28/build/include/linux/module.h:10,
                 from hello.c:1:
/lib/modules/2.6.28/build/include/linux/math64.h:5:23: error: asm/div64.h: No such file or directory
In file included from /lib/modules/2.6.28/build/include/linux/time.h:9,
                 from /lib/modules/2.6.28/build/include/linux/stat.h:60,
                 from /lib/modules/2.6.28/build/include/linux/module.h:10,
                 from hello.c:1:
/lib/modules/2.6.28/build/include/linux/math64.h:66: error: expected  =',  ,',  ;',  asm' or  __attribute__' before  div_u64'
/lib/modules/2.6.28/build/include/linux/math64.h:77: error: expected  =',  ,',  ;',  asm' or  __attribute__' before  div_s64'
/lib/modules/2.6.28/build/include/linux/math64.h:84: error: expected  =',  ,',  ;',  asm' or  __attribute__' before  iter_div_u64_rem'
/lib/modules/2.6.28/build/include/linux/math64.h:87: error: expected  =',  ,',  ;',  asm' or  __attribute__' before  __iter_div_u64_rem'
In file included from /lib/modules/2.6.28/build/include/linux/stat.h:60,
                 from /lib/modules/2.6.28/build/include/linux/module.h:10,
                 from hello.c:1:
/lib/modules/2.6.28/build/include/linux/time.h:133: error: expected  )' before  nsec'
/lib/modules/2.6.28/build/include/linux/time.h:145: error: expected  =',  ,',  ;',  asm' or  __attribute__' before  timespec_to_ns'
/lib/modules/2.6.28/build/include/linux/time.h:157: error: expected  =',  ,',  ;',  asm' or  __attribute__' before  timeval_to_ns'
/lib/modules/2.6.28/build/include/linux/time.h:169: error: expected  ;',  ,' or  )' before  nsec'
/lib/modules/2.6.28/build/include/linux/time.h:177: error: expected  ;',  ,' or  )' before  nsec'
/lib/modules/2.6.28/build/include/linux/time.h:187: error: expected declaration specifiers or  ...' before  u64'
/lib/modules/2.6.28/build/include/linux/time.h: In function  timespec_add_ns':
/lib/modules/2.6.28/build/include/linux/time.h:189: error:  ns' undeclared (first use in this function)
In file included from /lib/modules/2.6.28/build/include/linux/module.h:10,
                 from hello.c:1:
/lib/modules/2.6.28/build/include/linux/stat.h: At top level:
/lib/modules/2.6.28/build/include/linux/stat.h:63: error: expected specifier-qualifier-list before  u64'
In file included from /lib/modules/2.6.28/build/include/linux/mmzone.h:9,
                 from /lib/modules/2.6.28/build/include/linux/gfp.h:4,
                 from /lib/modules/2.6.28/build/include/linux/kmod.h:22,
                 from /lib/modules/2.6.28/build/include/linux/module.h:13,
                 from hello.c:1:
/lib/modules/2.6.28/build/include/linux/wait.h:26:25: error: asm/current.h: No such file or directory
In file included from /lib/modules/2.6.28/build/include/linux/bitmap.h:8,
                 from /lib/modules/2.6.28/build/include/linux/nodemask.h:89,
                 from /lib/modules/2.6.28/build/include/linux/mmzone.h:16,
                 from /lib/modules/2.6.28/build/include/linux/gfp.h:4,
                 from /lib/modules/2.6.28/build/include/linux/kmod.h:22,
                 from /lib/modules/2.6.28/build/include/linux/module.h:13,
                 from hello.c:1:
/lib/modules/2.6.28/build/include/linux/string.h:19:24: error: asm/string.h: No such file or directory
In file included from /lib/modules/2.6.28/build/include/linux/nodemask.h:89,
                 from /lib/modules/2.6.28/build/include/linux/mmzone.h:16,
                 from /lib/modules/2.6.28/build/include/linux/gfp.h:4,
                 from /lib/modules/2.6.28/build/include/linux/kmod.h:22,
                 from /lib/modules/2.6.28/build/include/linux/module.h:13,
                 from hello.c:1:
/lib/modules/2.6.28/build/include/linux/bitmap.h: In function  bitmap_zero':
/lib/modules/2.6.28/build/include/linux/bitmap.h:142: error:  BITS_PER_LONG' undeclared (first use in this function)
/lib/modules/2.6.28/build/include/linux/bitmap.h: In function  bitmap_fill':
/lib/modules/2.6.28/build/include/linux/bitmap.h:157: error:  BITS_PER_LONG' undeclared (first use in this function)
/lib/modules/2.6.28/build/include/linux/bitmap.h: In function  bitmap_copy':
/lib/modules/2.6.28/build/include/linux/bitmap.h:163: error:  BITS_PER_LONG' undeclared (first use in this function)
/lib/modules/2.6.28/build/include/linux/bitmap.h: In function  bitmap_and':
/lib/modules/2.6.28/build/include/linux/bitmap.h:174: error:  BITS_PER_LONG' undeclared (first use in this function)
/lib/modules/2.6.28/build/include/linux/bitmap.h: In function  bitmap_or':
/lib/modules/2.6.28/build/include/linux/bitmap.h:183: error:  BITS_PER_LONG' undeclared (first use in this function)
/lib/modules/2.6.28/build/include/linux/bitmap.h: In function  bitmap_xor':
/lib/modules/2.6.28/build/include/linux/bitmap.h:192: error:  BITS_PER_LONG' undeclared (first use in this function)
/lib/modules/2.6.28/build/include/linux/bitmap.h: In function  bitmap_andnot':
/lib/modules/2.6.28/build/include/linux/bitmap.h:201: error:  BITS_PER_LONG' undeclared (first use in this function)
/lib/modules/2.6.28/build/include/linux/bitmap.h: In function  bitmap_complement':
/lib/modules/2.6.28/build/include/linux/bitmap.h:210: error:  BITS_PER_LONG' undeclared (first use in this function)
/lib/modules/2.6.28/build/include/linux/bitmap.h: In function  bitmap_equal':
/lib/modules/2.6.28/build/include/linux/bitmap.h:219: error:  BITS_PER_LONG' undeclared (first use in this function)
/lib/modules/2.6.28/build/include/linux/bitmap.h: In function  bitmap_intersects':
/lib/modules/2.6.28/build/include/linux/bitmap.h:228: error:  BITS_PER_LONG' undeclared (first use in this function)
/lib/modules/2.6.28/build/include/linux/bitmap.h: In function  bitmap_subset':
/lib/modules/2.6.28/build/include/linux/bitmap.h:237: error:  BITS_PER_LONG' undeclared (first use in this function)
/lib/modules/2.6.28/build/include/linux/bitmap.h: In function  bitmap_empty':
/lib/modules/2.6.28/build/include/linux/bitmap.h:245: error:  BITS_PER_LONG' undeclared (first use in this function)
/lib/modules/2.6.28/build/include/linux/bitmap.h: In function  bitmap_full':
/lib/modules/2.6.28/build/include/linux/bitmap.h:253: error:  BITS_PER_LONG' undeclared (first use in this function)
/lib/modules/2.6.28/build/include/linux/bitmap.h: In function  bitmap_weight':
/lib/modules/2.6.28/build/include/linux/bitmap.h:261: error:  BITS_PER_LONG' undeclared (first use in this function)
/lib/modules/2.6.28/build/include/linux/bitmap.h: In function  bitmap_shift_right':
/lib/modules/2.6.28/build/include/linux/bitmap.h:269: error:  BITS_PER_LONG' undeclared (first use in this function)
/lib/modules/2.6.28/build/include/linux/bitmap.h: In function  bitmap_shift_left':
/lib/modules/2.6.28/build/include/linux/bitmap.h:278: error:  BITS_PER_LONG' undeclared (first use in this function)
In file included from /lib/modules/2.6.28/build/include/linux/gfp.h:4,
                 from /lib/modules/2.6.28/build/include/linux/kmod.h:22,
                 from /lib/modules/2.6.28/build/include/linux/module.h:13,
                 from hello.c:1:
/lib/modules/2.6.28/build/include/linux/mmzone.h: At top level:
/lib/modules/2.6.28/build/include/linux/mmzone.h:333: error: expected specifier-qualifier-list before  atomic_long_t'
In file included from /lib/modules/2.6.28/build/include/linux/notifier.h:13,
                 from /lib/modules/2.6.28/build/include/linux/memory_hotplug.h:6,
                 from /lib/modules/2.6.28/build/include/linux/mmzone.h:640,
                 from /lib/modules/2.6.28/build/include/linux/gfp.h:4,
                 from /lib/modules/2.6.28/build/include/linux/kmod.h:22,
                 from /lib/modules/2.6.28/build/include/linux/module.h:13,
                 from hello.c:1:
/lib/modules/2.6.28/build/include/linux/mutex.h:50: error: expected specifier-qualifier-list before  atomic_t'
/lib/modules/2.6.28/build/include/linux/mutex.h: In function  mutex_is_locked':
/lib/modules/2.6.28/build/include/linux/mutex.h:117: error:  struct mutex' has no member named  count'
In file included from /lib/modules/2.6.28/build/include/linux/notifier.h:14,
                 from /lib/modules/2.6.28/build/include/linux/memory_hotplug.h:6,
                 from /lib/modules/2.6.28/build/include/linux/mmzone.h:640,
                 from /lib/modules/2.6.28/build/include/linux/gfp.h:4,
                 from /lib/modules/2.6.28/build/include/linux/kmod.h:22,
                 from /lib/modules/2.6.28/build/include/linux/module.h:13,
                 from hello.c:1:
/lib/modules/2.6.28/build/include/linux/rwsem.h:22:65: error: asm/rwsem.h: No such file or directory
In file included from /lib/modules/2.6.28/build/include/linux/memory_hotplug.h:6,
                 from /lib/modules/2.6.28/build/include/linux/mmzone.h:640,
                 from /lib/modules/2.6.28/build/include/linux/gfp.h:4,
                 from /lib/modules/2.6.28/build/include/linux/kmod.h:22,
                 from /lib/modules/2.6.28/build/include/linux/module.h:13,
                 from hello.c:1:
/lib/modules/2.6.28/build/include/linux/notifier.h: At top level:
/lib/modules/2.6.28/build/include/linux/notifier.h:62: error: field  rwsem' has incomplete type
In file included from /lib/modules/2.6.28/build/include/linux/mmzone.h:640,
                 from /lib/modules/2.6.28/build/include/linux/gfp.h:4,
                 from /lib/modules/2.6.28/build/include/linux/kmod.h:22,
                 from /lib/modules/2.6.28/build/include/linux/module.h:13,
                 from hello.c:1:
/lib/modules/2.6.28/build/include/linux/memory_hotplug.h:214: error: expected declaration specifiers or  ...' before  u64'
/lib/modules/2.6.28/build/include/linux/memory_hotplug.h:214: error: expected declaration specifiers or  ...' before  u64'
/lib/modules/2.6.28/build/include/linux/memory_hotplug.h:215: error: expected declaration specifiers or  ...' before  u64'
/lib/modules/2.6.28/build/include/linux/memory_hotplug.h:215: error: expected declaration specifiers or  ...' before  u64'
/lib/modules/2.6.28/build/include/linux/memory_hotplug.h:216: error: expected  )' before  start'
In file included from /lib/modules/2.6.28/build/include/linux/gfp.h:4,
                 from /lib/modules/2.6.28/build/include/linux/kmod.h:22,
                 from /lib/modules/2.6.28/build/include/linux/module.h:13,
                 from hello.c:1:
/lib/modules/2.6.28/build/include/linux/mmzone.h: In function  populated_zone':
/lib/modules/2.6.28/build/include/linux/mmzone.h:673: error:  struct zone' has no member named  present_pages'
/lib/modules/2.6.28/build/include/linux/mmzone.h: In function  is_normal':
/lib/modules/2.6.28/build/include/linux/mmzone.h:722: error:  struct zone' has no member named  zone_pgdat'
In file included from /lib/modules/2.6.28/build/include/linux/topology.h:30,
                 from /lib/modules/2.6.28/build/include/linux/mmzone.h:763,
                 from /lib/modules/2.6.28/build/include/linux/gfp.h:4,
                 from /lib/modules/2.6.28/build/include/linux/kmod.h:22,
                 from /lib/modules/2.6.28/build/include/linux/module.h:13,
                 from hello.c:1:
/lib/modules/2.6.28/build/include/linux/cpumask.h: At top level:
/lib/modules/2.6.28/build/include/linux/cpumask.h:279: error:  BITS_PER_LONG' undeclared here (not in a function)
In file included from /lib/modules/2.6.28/build/include/linux/topology.h:33,
                 from /lib/modules/2.6.28/build/include/linux/mmzone.h:763,
                 from /lib/modules/2.6.28/build/include/linux/gfp.h:4,
                 from /lib/modules/2.6.28/build/include/linux/kmod.h:22,
                 from /lib/modules/2.6.28/build/include/linux/module.h:13,
                 from hello.c:1:
/lib/modules/2.6.28/build/include/linux/smp.h:20: error: expected specifier-qualifier-list before  u16'
In file included from /lib/modules/2.6.28/build/include/linux/mmzone.h:763,
                 from /lib/modules/2.6.28/build/include/linux/gfp.h:4,
                 from /lib/modules/2.6.28/build/include/linux/kmod.h:22,
                 from /lib/modules/2.6.28/build/include/linux/module.h:13,
                 from hello.c:1:
/lib/modules/2.6.28/build/include/linux/topology.h:34:26: error: asm/topology.h: No such file or directory
In file included from /lib/modules/2.6.28/build/include/linux/kobject.h:24,
                 from /lib/modules/2.6.28/build/include/linux/module.h:16,
                 from hello.c:1:
/lib/modules/2.6.28/build/include/linux/kref.h:22: error: expected specifier-qualifier-list before  atomic_t'
In file included from /lib/modules/2.6.28/build/include/linux/module.h:16,
                 from hello.c:1:
/lib/modules/2.6.28/build/include/linux/kobject.h:37: error: expected  =',  ,',  ;',  asm' or  __attribute__' before  uevent_seqnum'
In file included from /lib/modules/2.6.28/build/include/linux/rcupdate.h:39,
                 from /lib/modules/2.6.28/build/include/linux/tracepoint.h:18,
                 from /lib/modules/2.6.28/build/include/linux/module.h:19,
                 from hello.c:1:

Last edited by sulacco; 01-09-2009 at 01:04 PM.
 
Old 01-08-2009, 07:34 PM   #2
bgeddy
Senior Member
 
Registered: Sep 2006
Location: Liverpool - England
Distribution: slackware64 13.37 and -current, Dragonfly BSD
Posts: 1,810

Rep: Reputation: 232Reputation: 232Reputation: 232
Please use CODE /CODE tags arounf long listings as it's a pain to scroll through it all.

I find that creating a Makefile saves a lot of effort when compiling - especially kernel modules. Here's one that should work to test your hello.c program.
Code:
obj-m := hello.o 

KERNELDIR  := /lib/modules/$(shell uname -r)/build
PWD   := $(shell pwd)

default:
	$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
Just create a textfile called Makefile in the directory of hello.c and run "make" from the console.
 
Old 01-09-2009, 12:53 AM   #3
Neuzen
Member
 
Registered: Jun 2007
Distribution: Slackware, Gentoo, Debian
Posts: 36

Rep: Reputation: 16
by the way

Hi sulacco,

I have a question, where is the <linux/init.h> #include command?

Regards,
 
Old 01-09-2009, 12:34 PM   #4
sulacco
Member
 
Registered: Apr 2006
Posts: 46

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by Neuzen View Post
Hi sulacco,

I have a question, where is the <linux/init.h> #include command?

Regards,
It's right at the top. Look closer.
 
Old 01-09-2009, 12:45 PM   #5
sulacco
Member
 
Registered: Apr 2006
Posts: 46

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by bgeddy View Post
Please use CODE /CODE tags arounf long listings as it's a pain to scroll through it all.

I find that creating a Makefile saves a lot of effort when compiling - especially kernel modules. Here's one that should work to test your hello.c program.
Code:
obj-m := hello.o 

KERNELDIR  := /lib/modules/$(shell uname -r)/build
PWD   := $(shell pwd)

default:
	$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
Just create a textfile called Makefile in the directory of hello.c and run "make" from the console.

I'm using this kind of makefile, but will try your version
Code:
TARGET:= hello
WARN := -W -Wall -Wstrict-prototypes -Wmissing-prototypes
INCLUDE := -isystem /lib/modules/`uname -r`/build/include
CFLAGS := -O2 -DMODULE -D__KERNEL__ ${WARN} ${INCLUDE}
CC := gcc

${TARGET}.o: ${TARGET}.c

.PHONY: clean

clean:
        rm -rf{target}.o

Last edited by sulacco; 01-09-2009 at 12:47 PM.
 
Old 01-09-2009, 12:47 PM   #6
sulacco
Member
 
Registered: Apr 2006
Posts: 46

Original Poster
Rep: Reputation: 15
... but have a very distant understanding how it works
 
Old 01-09-2009, 12:53 PM   #7
sulacco
Member
 
Registered: Apr 2006
Posts: 46

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by bgeddy View Post
Please use CODE /CODE tags arounf long listings as it's a pain to scroll through it all.

I find that creating a Makefile saves a lot of effort when compiling - especially kernel modules. Here's one that should work to test your hello.c program.
Code:
obj-m := hello.o 

KERNELDIR  := /lib/modules/$(shell uname -r)/build
PWD   := $(shell pwd)

default:
	$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
Just create a textfile called Makefile in the directory of hello.c and run "make" from the console.
I'm running your version of makefile but it says only that:

"Nothing can be done for `hello.c`"

What it is?
 
Old 01-09-2009, 12:58 PM   #8
sulacco
Member
 
Registered: Apr 2006
Posts: 46

Original Poster
Rep: Reputation: 15
I think that the most important error string is this:

/lib/modules/2.6.28/build/include/linux/prefetch.h:14:27: error: asm/processor.h: No such file or directory

maybe I shoud to create somewhere a link?
 
Old 01-09-2009, 01:21 PM   #9
bgeddy
Senior Member
 
Registered: Sep 2006
Location: Liverpool - England
Distribution: slackware64 13.37 and -current, Dragonfly BSD
Posts: 1,810

Rep: Reputation: 232Reputation: 232Reputation: 232
Sorry I'm sure what's going on here as your code compiles fine on my system with the Makefile. Maybe something worng with your kernel source ?
 
Old 01-09-2009, 01:41 PM   #10
sulacco
Member
 
Registered: Apr 2006
Posts: 46

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by bgeddy View Post
Sorry I'm sure what's going on here as your code compiles fine on my system with the Makefile. Maybe something worng with your kernel source ?
How to understand wrong something or not with kernel source?
I've just downloaded it from kernel.org and configured, compiled, compiled
modules, installed modules, then make install.

this is the schedule which I did:

make menuconfig
make
make modules
make modules_install
make install

then I checked grub.conf and saw that make utility already changed it.

Then I restarted comp and choose kernel 2.6.28 to load.

C programms compiled successfully, but with driver program there is problem.
 
Old 01-09-2009, 02:00 PM   #11
sulacco
Member
 
Registered: Apr 2006
Posts: 46

Original Poster
Rep: Reputation: 15
here what i've got while using your version of makefile.
First it have to be such a command:
make hello.

Code:
[root@localhost ushka]# make hello
cc     hello.c   -o hello
hello.c:1:26: error: linux/module.h: No such file or directory
hello.c:15: warning: data definition has no type or storage class
hello.c:15: warning: parameter names (without types) in function declaration
hello.c:16: warning: data definition has no type or storage class
hello.c:16: warning: parameter names (without types) in function declaration
make: *** [hello] Error 1
 
Old 01-09-2009, 02:01 PM   #12
sulacco
Member
 
Registered: Apr 2006
Posts: 46

Original Poster
Rep: Reputation: 15
the current path is /home/ushka
 
Old 01-09-2009, 09:01 PM   #13
map250r
Member
 
Registered: Aug 2007
Distribution: Debian Squeeze
Posts: 46

Rep: Reputation: 15
If I google linux/types.h:198: error: expected, I get several results.
http://lkml.indiana.edu/hypermail/li...10.1/1854.html

What I searched for is part of the first line with an error.

Assuming the link I provided helps, the problem is that you compiled in the same directory that the source is in. You're allowed to, but I think it's frowned upon. What I do is to use O=../build2.6.28 as one of the args for make each time. (do mkdir ../build2.6.28 first though!)
 
Old 01-10-2009, 06:28 AM   #14
bgeddy
Senior Member
 
Registered: Sep 2006
Location: Liverpool - England
Distribution: slackware64 13.37 and -current, Dragonfly BSD
Posts: 1,810

Rep: Reputation: 232Reputation: 232Reputation: 232
Quote:
make hello
DO NOT run this ! It won't work.

Quote:
Just create a textfile called Makefile in the directory of hello.c and run "make" from the console.
This is all you need to do. Create the file and type "make".

Quote:
Assuming the link I provided helps, the problem is that you compiled in the same directory that the source is in. You're allowed to, but I think it's frowned upon. What I do is to use O=../build2.6.28 as one of the args for make each time. (do mkdir ../build2.6.28 first though!)
There's absolutely nothing wrong in compiling in the source directory. The error is due to incorrectly running make.

Just to be sure all is well try this :

Quote:
rm hello.{mod.*,o,ko}
make
 
Old 01-10-2009, 04:01 PM   #15
sulacco
Member
 
Registered: Apr 2006
Posts: 46

Original Poster
Rep: Reputation: 15
2bgeddy

if I run only:
Code:
make
here what I've got for answer:
Code:
make: Nothing to be done for `default'.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need to keep re-installing NVIDIA Dirver ? bogzab Slackware 9 06-12-2007 09:44 AM
problem with suse 9.3 nvidia dirver dred SUSE / openSUSE 11 07-12-2005 08:19 AM
intel 537ep dirver on feodra core 3 Gonto Linux - Hardware 6 05-18-2005 07:04 PM
Trouble Compiling a simple Hellow World on Solaris 9 with GCC 3.4.2 jitendra64 Solaris / OpenSolaris 4 10-11-2004 02:57 PM
video dirver for quake3 (demo) Smerk Linux - Games 10 12-19-2003 01:56 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:13 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration