LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Have a trouble with compiling simple dirver. (https://www.linuxquestions.org/questions/programming-9/have-a-trouble-with-compiling-simple-dirver-695958/)

sulacco 01-08-2009 05:40 PM

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:


bgeddy 01-08-2009 07:34 PM

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.

Neuzen 01-09-2009 12:53 AM

by the way
 
Hi sulacco,

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

Regards,

sulacco 01-09-2009 12:34 PM

Quote:

Originally Posted by Neuzen (Post 3401970)
Hi sulacco,

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

Regards,

It's right at the top. Look closer. :)

sulacco 01-09-2009 12:45 PM

Quote:

Originally Posted by bgeddy (Post 3401756)
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


sulacco 01-09-2009 12:47 PM

... but have a very distant understanding how it works

sulacco 01-09-2009 12:53 PM

Quote:

Originally Posted by bgeddy (Post 3401756)
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?

sulacco 01-09-2009 12:58 PM

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?

bgeddy 01-09-2009 01:21 PM

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 ?

sulacco 01-09-2009 01:41 PM

Quote:

Originally Posted by bgeddy (Post 3402675)
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.

sulacco 01-09-2009 02:00 PM

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


sulacco 01-09-2009 02:01 PM

the current path is /home/ushka

map250r 01-09-2009 09:01 PM

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!)

bgeddy 01-10-2009 06:28 AM

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

sulacco 01-10-2009 04:01 PM

2bgeddy

if I run only:
Code:

make
here what I've got for answer:
Code:

make: Nothing to be done for `default'.

sulacco 01-10-2009 05:04 PM

Quote:

Originally Posted by map250r (Post 3403110)
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!)

I feel you are very close at it. Can you explain more. How do I know if
i compiled in the same directory that sources are?
I feel something wrong with symlink too. That is the major part of
errors in compilation of my driver.
Though you link didn't help, cause `make mrproper` dont work.
there are no such option in makefile mrproper i think

bgeddy 01-11-2009 08:48 AM

Ok - this is very odd. I have an even simpler Makefile which will require some command line arguments to make. You should change directory to the directory of hello.c and create a file called, for example, hello.sh. Then make it executable with
Code:

chmod +x hello.sh
Then run it with
Code:

./hello.sh
Be aware that if you already have a subdirectory temp/ off the hello.c directory then it will be erased. This will create a new directory temp/ off the hello.c directory, create a Makefile and run it. It should produce a module hello.ko which should be listed at the end of the make run. Here is the hello.sh to create :

Code:

#!/bin/bash
rm -rf temp/
mkdir temp
cp hello.c temp/
cd temp
cat > Makefile << EOF
obj-m := hello.o

EOF
make -C /lib/modules/$(uname -r)/build  M=$(pwd) modules
ls -al hello*
exit 0


jiml8 01-11-2009 02:16 PM

Quote:

Originally Posted by sulacco (Post 3403900)
2bgeddy

if I run only:
Code:

make
here what I've got for answer:
Code:

make: Nothing to be done for `default'.

Delete all .o files in the directory, then run make again. The makefile you have been given is correct and is what you want to use for a kernel driver. There is no problem compiling into the same directory. The message basically was just telling you that make thinks your executable is up to date.

bgeddy 01-11-2009 04:53 PM

Quote:

Delete all .o files in the directory, then run make again.
I have already told the OP to do this - here was my message :
Quote:

Just to be sure all is well try this :

Quote:
rm hello.{mod.*,o,ko}
make
I hope he/she hasn't been ignoring my advice as this would explain the confusion.

sulacco 01-12-2009 09:24 PM

Quote:

Originally Posted by bgeddy (Post 3404903)
I have already told the OP to do this - here was my message :


I hope he/she hasn't been ignoring my advice as this would explain the confusion.

tnx. I'm not ignoring just there so many details while trying to compile in linux world...

sulacco 01-12-2009 09:35 PM

there are no files .o, mod.*, *.ko and still when I try to send command
`make` there is answer:
make: Nothing to be done for `default'.

sulacco 01-12-2009 11:01 PM

Quote:

Originally Posted by bgeddy (Post 3404471)
Ok - this is very odd. I have an even simpler Makefile which will require some command line arguments to make. You should change directory to the directory of hello.c and create a file called, for example, hello.sh. Then make it executable with
Code:

chmod +x hello.sh
Then run it with
Code:

./hello.sh
Be aware that if you already have a subdirectory temp/ off the hello.c directory then it will be erased. This will create a new directory temp/ off the hello.c directory, create a Makefile and run it. It should produce a module hello.ko which should be listed at the end of the make run. Here is the hello.sh to create :

Code:

#!/bin/bash
rm -rf temp/
mkdir temp
cp hello.c temp/
cd temp
cat > Makefile << EOF
obj-m := hello.o

EOF
make -C /lib/modules/$(uname -r)/build  M=$(pwd) modules
ls -al hello*
exit 0


UNBELIEVABLE!!! This is your last advice is REAL GOLDEN!!.
Thank you very much it worked now! It compiled and created bunch of
files with .ko, .o and so on!!!

sulacco 01-13-2009 10:11 PM

2bgeddy
can you explain pleas what it does?

Code:

#!/bin/bash
rm -rf temp/
mkdir temp
cp hello.c temp/
cd temp
cat > Makefile << EOF
obj-m := hello.o

EOF
make -C /lib/modules/$(uname -r)/build  M=$(pwd) modules
ls -al hello*
exit 0

next commands escape my understanding:
Code:

cat > Makefile << EOF
obj-m := hello.o
EOF
make -C /lib/modules/$(uname -r)/build  M=$(pwd) modules

Those four lines, I just don't get it.

bgeddy 01-14-2009 07:54 AM

Quote:

cat > Makefile << EOF
obj-m := hello.o
EOF
This is what's known as a "here document". It creates a file called "Makefile" with one line "obj-m: hello.o"
Quote:

make -C /lib/modules/$(uname -r)/build M=$(pwd) modules
This runs make with the target "modules" for the module in the current directory "$(pwd)" and the kernel source at "/lib/modules/$(uname -r)/build". Make changes directory to this before running the make.

sulacco 01-15-2009 02:06 PM

I'm very sorry, but driver again refused to compile!!!

Code:

CC [M]  /home/ushka/temp/hello.o
In file included from /usr/src/linux-2.6.28/arch/x86/include/asm/processor.h:19,
                from include/linux/prefetch.h:15,
                from include/linux/list.h:7,
                from include/linux/module.h:10,
                from /home/ushka/temp/hello.c:4:
/usr/src/linux-2.6.28/arch/x86/include/asm/page.h: In function ‘native_pte_flags’:
/usr/src/linux-2.6.28/arch/x86/include/asm/page.h:152: error: ‘phys_addr_t’ undeclared (first use in this function)
/usr/src/linux-2.6.28/arch/x86/include/asm/page.h:152: error: (Each undeclared identifier is reported only once
/usr/src/linux-2.6.28/arch/x86/include/asm/page.h:152: error: for each function it appears in.)
make[1]: *** [/home/ushka/temp/hello.o] Error 1
make: *** [_module_/home/ushka/temp] Error 2
make: Leaving directory `/usr/src/linux-2.6.28'
-rw-r--r-- 1 root root 916 2009-01-15 17:57 hello.c


sulacco 01-15-2009 03:44 PM

Interesting thing when I have tried to compile kernel: linux-2.6.28 with make utility
the same error in page.h was up. Funny thing linux!!!

bgeddy 01-16-2009 09:48 AM

Quote:

Interesting thing when I have tried to compile kernel: linux-2.6.28 with make utility
the same error in page.h was up. Funny thing linux!!!
Do you mean you haven't been able to successfully compile a kernel ? If this is the case then you really should have mentioned it earlier.

Installing and building a kernel source tree is the FIRST THING you should do when wanting to compile you own modules ! If the build process for the kernel fails then you will have problems with your modules.

Quote:

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.
I took this to mean that you had successfully built a kernel from source. It would seem not.

You must concentrate on successfully building a kernel first eliminating any build errors before continuing. I just wish you would have made this clear at the outset.

Actually this is getting highly confusing as :-
Quote:

UNBELIEVABLE!!! This is your last advice is REAL GOLDEN!!.
Thank you very much it worked now! It compiled and created bunch of
files with .ko, .o and so on!!!
reads like the device driver build worked. Are you saying it worked and now doesn't or it never worked at all ? If the process resulted in a .ko (module) file then it worked. This latest post implies that it didn't.

Before continuing I suggest you study The Linux Kernel in a Nutshell and Linx Device Drivers third edition and in future please give out relevant information at the outset - it would save a lot of time all round.


All times are GMT -5. The time now is 04:14 PM.