LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 667|回复: 6

关于内核编译的问题,求助!

[复制链接]
发表于 2004-12-23 16:53:20 | 显示全部楼层 |阅读模式
在redhat版本编译内核成功的程序,redhat在2.4和2.6都可以编译成功,到suse和mandrake就出问题了,无论2.4还是2.6。比如简单的例子: hello.c
#define MODULE
#include <linux/module.h>                                                         
int init_module(void)      { printk("<1>Hello, world\n"); return 0; }
void cleanup_module(void)  { printk("<1>Goodbye cruel world\n"); }
然后gcc -c hello.c
出错好多
如果有哪位大哥使用mandrake或suse,能否帮我看看这个问题,我真的不想装多一个系统。
发表于 2004-12-23 17:33:49 | 显示全部楼层
Can you post your error message first?
发表于 2004-12-23 18:37:30 | 显示全部楼层
#define __KERNEL__
发表于 2004-12-24 09:32:28 | 显示全部楼层
倒,又是一个不会问问题的人!
 楼主| 发表于 2004-12-29 12:09:21 | 显示全部楼层
gcc -c hello.c
In file included from /usr/include/linux/sched.h:12,
                 from /usr/include/linux/module.h:9,
                 from hello.c:2:
/usr/include/linux/jiffies.h:16: error: parse error before "jiffies_64"
/usr/include/linux/jiffies.h:20: error: parse error before "get_jiffies_64"
In file included from /usr/include/linux/cpumask.h:77,
                 from /usr/include/linux/sched.h:15,
                 from /usr/include/linux/module.h:9,
                 from hello.c:2:
/usr/include/linux/bitmap.h: In function `bitmap_zero':
/usr/include/linux/bitmap.h:110: error: `BITS_PER_LONG' undeclared (first use in this function)
/usr/include/linux/bitmap.h:110: error: (Each undeclared identifier is reportedonly once
/usr/include/linux/bitmap.h:110: error: for each function it appears in.)
/usr/include/linux/bitmap.h: In function `bitmap_fill':
/usr/include/linux/bitmap.h:125: error: `BITS_PER_LONG' undeclared (first use in this function)
/usr/include/linux/bitmap.h: In function `bitmap_copy':
/usr/include/linux/bitmap.h:131: error: `BITS_PER_LONG' undeclared (first use in this function)
/usr/include/linux/bitmap.h: In function `bitmap_and':
/usr/include/linux/bitmap.h:142: error: `BITS_PER_LONG' undeclared (first use in this function)
/usr/include/linux/bitmap.h: In function `bitmap_or':
/usr/include/linux/bitmap.h:151: error: `BITS_PER_LONG' undeclared (first use in this function)
/usr/include/linux/bitmap.h: In function `bitmap_xor':
/usr/include/linux/bitmap.h:160: error: `BITS_PER_LONG' undeclared (first use in this function)
/usr/include/linux/bitmap.h: In function `bitmap_andnot':
/usr/include/linux/bitmap.h:169: error: `BITS_PER_LONG' undeclared (first use in this function)
/usr/include/linux/bitmap.h: In function `bitmap_complement':
/usr/include/linux/bitmap.h:178: error: `BITS_PER_LONG' undeclared (first use in this function)
/usr/include/linux/bitmap.h: In function `bitmap_equal':
/usr/include/linux/bitmap.h:187: error: `BITS_PER_LONG' undeclared (first use in this function)
/usr/include/linux/bitmap.h: In function `bitmap_intersects':
/usr/include/linux/bitmap.h:196: error: `BITS_PER_LONG' undeclared (first use in this function)
/usr/include/linux/bitmap.h: In function `bitmap_subset':
/usr/include/linux/bitmap.h:205: error: `BITS_PER_LONG' undeclared (first use in this function)
/usr/include/linux/bitmap.h: In function `bitmap_empty':
/usr/include/linux/bitmap.h:213: error: `BITS_PER_LONG' undeclared (first use in this function)
/usr/include/linux/bitmap.h: In function `bitmap_full':
/usr/include/linux/bitmap.h:221: error: `BITS_PER_LONG' undeclared (first use in this function)
/usr/include/linux/bitmap.h: In function `bitmap_shift_right':
/usr/include/linux/bitmap.h:235: error: `BITS_PER_LONG' undeclared (first use in this function)
/usr/include/linux/bitmap.h: In function `bitmap_shift_left':
/usr/include/linux/bitmap.h:244: error: `BITS_PER_LONG' undeclared (first use in this function)
In file included from /usr/include/linux/sched.h:15,
                 from /usr/include/linux/module.h:9,
                 from hello.c:2:
/usr/include/linux/cpumask.h: At top level:
/usr/include/linux/cpumask.h:80: error: parse error before "DECLARE_BITMAP"
/usr/include/linux/cpumask.h:81: error: parse error before "_unused_cpumask_arg_"
/usr/include/linux/cpumask.h:84: error: parse error before '*' token
/usr/include/linux/cpumask.h: In function `__cpu_set':
/usr/include/linux/cpumask.h:86: error: `cpu' undeclared (first use in this function)
/usr/include/linux/cpumask.h:86: error: `dstp' undeclared (first use in this function)
/usr/include/linux/cpumask.h: At top level:
/usr/include/linux/cpumask.h:90: error: parse error before '*' token
/usr/include/linux/cpumask.h: In function `__cpu_clear':
/usr/include/linux/cpumask.h:92: error: `cpu' undeclared (first use in this function)
/usr/include/linux/cpumask.h:92: error: `dstp' undeclared (first use in this function)
/usr/include/linux/cpumask.h: At top level:
/usr/include/linux/cpumask.h:96: error: parse error before '*' token
/usr/include/linux/cpumask.h: In function `__cpus_setall':
/usr/include/linux/cpumask.h:98: error: `dstp' undeclared (first use in this function)
/usr/include/linux/cpumask.h:98: error: `nbits' undeclared (first use in this function)
/usr/include/linux/cpumask.h: At top level:
/usr/include/linux/cpumask.h:102: error: parse error before '*' token
/usr/include/linux/cpumask.h: In function `__cpus_clear':
/usr/include/linux/cpumask.h:104: error: `dstp' undeclared (first use in this function)
/usr/include/linux/cpumask.h:104: error: `nbits' undeclared (first use in this function)
/usr/include/linux/cpumask.h: At top level:
/usr/include/linux/cpumask.h:111: error: parse error before "cpumask_t"
/usr/include/linux/cpumask.h: In function `__cpu_test_and_set':
/usr/include/linux/cpumask.h:113: error: `cpu' undeclared (first use in this function)
/usr/include/linux/cpumask.h:113: error: `addr' undeclared (first use in this function)
/usr/include/linux/cpumask.h: At top level:
/usr/include/linux/cpumask.h:117: error: parse error before '*' token
/usr/include/linux/cpumask.h: In function `__cpus_and':
/usr/include/linux/cpumask.h:120: error: `dstp' undeclared (first use in this function)
/usr/include/linux/cpumask.h:120: error: `src1p' undeclared (first use in this function)
/usr/include/linux/cpumask.h:120: error: `src2p' undeclared (first use in this function)
/usr/include/linux/cpumask.h:120: error: `nbits' undeclared (first use in this function)
/usr/include/linux/cpumask.h: At top level:
/usr/include/linux/cpumask.h:124: error: parse error before '*' token
/usr/include/linux/cpumask.h: In function `__cpus_or':
/usr/include/linux/cpumask.h:127: error: `dstp' undeclared (first use in this function)
/usr/include/linux/cpumask.h:127: error: `src1p' undeclared (first use in this function)
/usr/include/linux/cpumask.h:127: error: `src2p' undeclared (first use in this function)
/usr/include/linux/cpumask.h:127: error: `nbits' undeclared (first use in this function)
/usr/include/linux/cpumask.h: At top level:
/usr/include/linux/cpumask.h:131: error: parse error before '*' token
/usr/include/linux/cpumask.h: In function `__cpus_xor':
/usr/include/linux/cpumask.h:134: error: `dstp' undeclared (first use in this function)
/usr/include/linux/cpumask.h:134: error: `src1p' undeclared (first use in this function)
/usr/include/linux/cpumask.h:134: error: `src2p' undeclared (first use in this function)
/usr/include/linux/cpumask.h:134: error: `nbits' undeclared (first use in this function)
/usr/include/linux/cpumask.h: At top level:
/usr/include/linux/cpumask.h:139: error: parse error before '*' token
/usr/include/linux/cpumask.h: In function `__cpus_andnot':
/usr/include/linux/cpumask.h:142: error: `dstp' undeclared (first use in this function)
/usr/include/linux/cpumask.h:142: error: `src1p' undeclared (first use in this function)
/usr/include/linux/cpumask.h:142: error: `src2p' undeclared (first use in this function)
/usr/include/linux/cpumask.h:142: error: `nbits' undeclared (first use in this function)
/usr/include/linux/cpumask.h: At top level:
/usr/include/linux/cpumask.h:146: error: parse error before '*' token
/usr/include/linux/cpumask.h: In function `__cpus_complement':
/usr/include/linux/cpumask.h:149: error: `dstp' undeclared (first use in this function)
/usr/include/linux/cpumask.h:149: error: `srcp' undeclared (first use in this function)
/usr/include/linux/cpumask.h:149: error: `nbits' undeclared (first use in this function)
/usr/include/linux/cpumask.h: At top level:
/usr/include/linux/cpumask.h:153: error: parse error before '*' token
/usr/include/linux/cpumask.h: In function `__cpus_equal':
/usr/include/linux/cpumask.h:156: error: `src1p' undeclared (first use in this function)
/usr/include/linux/cpumask.h:156: error: `src2p' undeclared (first use in this function)
/usr/include/linux/cpumask.h:156: error: `nbits' undeclared (first use in this function)
/usr/include/linux/cpumask.h: At top level:
/usr/include/linux/cpumask.h:160: error: parse error before '*' token
/usr/include/linux/cpumask.h: In function `__cpus_intersects':
/usr/include/linux/cpumask.h:163: error: `src1p' undeclared (first use in this function)
/usr/include/linux/cpumask.h:163: error: `src2p' undeclared (first use in this function)
/usr/include/linux/cpumask.h:163: error: `nbits' undeclared (first use in this function)
/usr/include/linux/cpumask.h: At top level:
/usr/include/linux/cpumask.h:167: error: parse error before '*' token
/usr/include/linux/cpumask.h: In function `__cpus_subset':
/usr/include/linux/cpumask.h:170: error: `src1p' undeclared (first use in this function)
/usr/include/linux/cpumask.h:170: error: `src2p' undeclared (first use in this function)
/usr/include/linux/cpumask.h:170: error: `nbits' undeclared (first use in this function)
/usr/include/linux/cpumask.h: At top level:
/usr/include/linux/cpumask.h:174: error: parse error before '*' token
/usr/include/linux/cpumask.h: In function `__cpus_empty':
/usr/include/linux/cpumask.h:176: error: `srcp' undeclared (first use in this function)
/usr/include/linux/cpumask.h:176: error: `nbits' undeclared (first use in this function)
/usr/include/linux/cpumask.h: At top level:
/usr/include/linux/cpumask.h:180: error: parse error before '*' token
/usr/include/linux/cpumask.h: In function `__cpus_full':
/usr/include/linux/cpumask.h:182: error: `srcp' undeclared (first use in this function)
/usr/include/linux/cpumask.h:182: error: `nbits' undeclared (first use in this function)
/usr/include/linux/cpumask.h: At top level:
/usr/include/linux/cpumask.h:186: error: parse error before '*' token
/usr/include/linux/cpumask.h: In function `__cpus_weight':
/usr/include/linux/cpumask.h:188: error: `srcp' undeclared (first use in this function)
/usr/include/linux/cpumask.h:188: error: `nbits' undeclared (first use in this function)
/usr/include/linux/cpumask.h: At top level:
/usr/include/linux/cpumask.h:193: error: parse error before '*' token
/usr/include/linux/cpumask.h: In function `__cpus_shift_right':
/usr/include/linux/cpumask.h:196: error: `dstp' undeclared (first use in this function)
/usr/include/linux/cpumask.h:196: error: `srcp' undeclared (first use in this function)
/usr/include/linux/cpumask.h:196: error: `n' undeclared (first use in this function)
/usr/include/linux/cpumask.h:196: error: `nbits' undeclared (first use in this function)
/usr/include/linux/cpumask.h: At top level:
/usr/include/linux/cpumask.h:201: error: parse error before '*' token
/usr/include/linux/cpumask.h: In function `__cpus_shift_left':
/usr/include/linux/cpumask.h:204: error: `dstp' undeclared (first use in this function)
/usr/include/linux/cpumask.h:204: error: `srcp' undeclared (first use in this function)
/usr/include/linux/cpumask.h:204: error: `n' undeclared (first use in this function)
/usr/include/linux/cpumask.h:204: error: `nbits' undeclared (first use in this function)
/usr/include/linux/cpumask.h: At top level:
/usr/include/linux/cpumask.h:208: error: parse error before '*' token
/usr/include/linux/cpumask.h: In function `__first_cpu':
/usr/include/linux/cpumask.h:210: error: `srcp' undeclared (first use in this function)
/usr/include/linux/cpumask.h:210: error: `nbits' undeclared (first use in this function)
/usr/include/linux/cpumask.h: At top level:
/usr/include/linux/cpumask.h:214: error: parse error before '*' token
/usr/include/linux/cpumask.h: In function `__next_cpu':
/usr/include/linux/cpumask.h:216: error: `srcp' undeclared (first use in this function)
/usr/include/linux/cpumask.h:216: error: `nbits' undeclared (first use in this function)
/usr/include/linux/cpumask.h:216: error: `n' undeclared (first use in this function)
/usr/include/linux/cpumask.h: At top level:
/usr/include/linux/cpumask.h:265: error: parse error before '*' token
/usr/include/linux/cpumask.h: In function `__cpumask_scnprintf':
/usr/include/linux/cpumask.h:267: error: `buf' undeclared (first use in this function)
/usr/include/linux/cpumask.h:267: error: `len' undeclared (first use in this function)
/usr/include/linux/cpumask.h:267: error: `srcp' undeclared (first use in this function)
/usr/include/linux/cpumask.h:267: error: `nbits' undeclared (first use in this function)
/usr/include/linux/cpumask.h: At top level:
/usr/include/linux/cpumask.h:273: error: parse error before "cpumask_t"
/usr/include/linux/cpumask.h: In function `__cpumask_parse':
/usr/include/linux/cpumask.h:275: error: `buf' undeclared (first use in this function)
/usr/include/linux/cpumask.h:275: error: `len' undeclared (first use in this function)
/usr/include/linux/cpumask.h:275: error: `dstp' undeclared (first use in this function)
/usr/include/linux/cpumask.h:275: error: `nbits' undeclared (first use in this function)
/usr/include/linux/cpumask.h: At top level:
/usr/include/linux/cpumask.h:343: error: parse error before "cpu_possible_map"
/usr/include/linux/cpumask.h:344: error: parse error before "cpu_online_map"
/usr/include/linux/cpumask.h:345: error: parse error before "cpu_present_map"
In file included from /usr/include/linux/sched.h:21,
                 from /usr/include/linux/module.h:9,
                 from hello.c:2:
/usr/include/asm/mmu.h:13: error: field `sem' has incomplete type
In file included from /usr/include/linux/signal.h:4,
                 from /usr/include/linux/sched.h:25,
                 from /usr/include/linux/module.h:9,
                 from hello.c:2:
/usr/include/linux/list.h:699:2: warning: #warning "don't include kernel headers in userspace"
In file included from /usr/include/asm/siginfo.h:4,
                 from /usr/include/linux/signal.h:7,
                 from /usr/include/linux/sched.h:25,
                 from /usr/include/linux/module.h:9,
                 from hello.c:2:
/usr/include/asm-generic/siginfo.h:58: error: size of array `_pad' is too large
In file included from /usr/include/linux/sched.h:27,
                 from /usr/include/linux/module.h:9,
                 from hello.c:2:
/usr/include/linux/fs_struct.h:9: error: parse error before "rwlock_t"
/usr/include/linux/fs_struct.h:13: error: parse error before '}' token
In file included from /usr/include/linux/sched.h:29,
                 from /usr/include/linux/module.h:9,
                 from hello.c:2:
/usr/include/linux/completion.h:15: error: parse error before "wait_queue_head_t"
/usr/include/linux/completion.h: In function `init_completion':
/usr/include/linux/completion.h:26: error: dereferencing pointer to incomplete type
/usr/include/linux/completion.h:27: error: dereferencing pointer to incomplete type
In file included from /usr/include/linux/sched.h:30,
                 from /usr/include/linux/module.h:9,
                 from hello.c:2:
/usr/include/linux/pid.h: At top level:
/usr/include/linux/pid.h:18: error: field `task_list' has incomplete type
/usr/include/linux/pid.h:19: error: field `hash_chain' has incomplete type
/usr/include/linux/pid.h:24: error: field `pid_chain' has incomplete type
In file included from /usr/include/linux/module.h:9,
                 from hello.c:2:
/usr/include/linux/sched.h:93: error: parse error before "process_counts"
In file included from /usr/include/linux/sched.h:102,
                 from /usr/include/linux/module.h:9,
                 from hello.c:2:
/usr/include/linux/timer.h:11: error: field `entry' has incomplete type
In file included from hello.c:2:
/usr/include/linux/module.h:553: error: parse error before "MOD_INC_USE_COUNT"
/usr/include/linux/module.h:565: error: parse error before "MOD_DEC_USE_COUNT"
 楼主| 发表于 2004-12-29 12:10:33 | 显示全部楼层
不是我不想贴,太多了。我以为有人也在用suse或mandrake,所以没贴...
 楼主| 发表于 2004-12-29 12:14:59 | 显示全部楼层
Post by doubleelec
#define __KERNEL__

as you say. it works. but there's still error.
gcc -c hello.c

In file included from /usr/include/linux/list.h:7,
                 from /usr/include/linux/wait.h:14,
                 from /usr/include/asm/semaphore.h:41,
                 from /usr/include/linux/sched.h:18,
                 from /usr/include/linux/module.h:9,
                 from hello.c:3:
/usr/include/linux/prefetch.h: In function `prefetch_range':
/usr/include/linux/prefetch.h:64: error: `CONFIG_X86_L1_CACHE_SHIFT' undeclared(first use in this function)
/usr/include/linux/prefetch.h:64: error: (Each undeclared identifier is reported only once
/usr/include/linux/prefetch.h:64: error: for each function it appears in.)
In file included from /usr/include/linux/module.h:22,
                 from hello.c:3:
/usr/include/asm/module.h:56:2: #error unknown processor family



maybe i should recompile my kernel
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表