当前位置: 技术问答>linux和unix
hello,world模块编译错误
来源: 互联网 发布时间:2016-08-20
本文导语: ------Makefile----------------- obj-m := hello.o KERNELDIR := /lib/modules/$(shell uname -r)/build PWD := $(shell pwd) default: make -C $(KERNELDIR) M= $(PWD) modules ------------------------------------------------- 错误: [root@localhost home]# make make -C /li...
------Makefile-----------------
obj-m := hello.o
KERNELDIR := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
default:
make -C $(KERNELDIR) M= $(PWD) modules
-------------------------------------------------
错误:
[root@localhost home]# make
make -C /lib/modules/2.6.30.10-105.2.23.fc11.i686.PAE/build M= /home modules
make[1]: Entering directory `/usr/src/kernels/2.6.30.10-105.2.23.fc11.i686.PAE'
make[1]: Nothing to be done for `/home'.
CHK include/linux/version.h
CHK include/linux/utsrelease.h
SYMLINK include/asm -> include/asm-x86
make[2]: *** 没有规则可以创建目标“missing-syscalls”。 停止。
make[1]: *** [prepare0] 错误 2
make[1]: Leaving directory `/usr/src/kernels/2.6.30.10-105.2.23.fc11.
新手入门,请大家帮忙!谢谢!
obj-m := hello.o
KERNELDIR := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
default:
make -C $(KERNELDIR) M= $(PWD) modules
-------------------------------------------------
错误:
[root@localhost home]# make
make -C /lib/modules/2.6.30.10-105.2.23.fc11.i686.PAE/build M= /home modules
make[1]: Entering directory `/usr/src/kernels/2.6.30.10-105.2.23.fc11.i686.PAE'
make[1]: Nothing to be done for `/home'.
CHK include/linux/version.h
CHK include/linux/utsrelease.h
SYMLINK include/asm -> include/asm-x86
make[2]: *** 没有规则可以创建目标“missing-syscalls”。 停止。
make[1]: *** [prepare0] 错误 2
make[1]: Leaving directory `/usr/src/kernels/2.6.30.10-105.2.23.fc11.
新手入门,请大家帮忙!谢谢!
|
obj-m := -DEXPORT_SYMTAB
obj-m := hello.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
把这段代码写到Makefile,编译一下试试
obj-m := hello.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
把这段代码写到Makefile,编译一下试试
|
你的内核是什么版本?
PS : 用下面的 Makefile 试试!
ifeq ($(DEBUG),y)
DEBFLAGS = -O -g -DSCULL_DEBUG # "-O" is needed to expand inlines
else
DEBFLAGS = -O2
endif
CFLAGS += $(DEBFLAGS)
CFLAGS += -I..
ifneq ($(KERNELRELEASE),)
# call from kernel build system
obj-m := hello.o
else
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
default:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
endif
clean:
rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions
depend .depend dep:
$(CC) $(CFLAGS) -M *.c > .depend
ifeq (.depend,$(wildcard .depend))
include .depend
endif
PS : 用下面的 Makefile 试试!
ifeq ($(DEBUG),y)
DEBFLAGS = -O -g -DSCULL_DEBUG # "-O" is needed to expand inlines
else
DEBFLAGS = -O2
endif
CFLAGS += $(DEBFLAGS)
CFLAGS += -I..
ifneq ($(KERNELRELEASE),)
# call from kernel build system
obj-m := hello.o
else
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
default:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
endif
clean:
rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions
depend .depend dep:
$(CC) $(CFLAGS) -M *.c > .depend
ifeq (.depend,$(wildcard .depend))
include .depend
endif
|
有内核树吗?
|
把你的那个license去掉,当前目录下的那个除了Makefile和hello.c以外的都删除。
用
KERNELDIR := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
obj-m := -DEXPORT_SYMTAB
obj-m := hello.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
Makefile试试,我就不信不行,要是再不行你就换一个环境。这个make和.c没问题。