【发布时间】:2020-03-08 11:26:39
【问题描述】:
我有一个打印 Hello World 的 hello.c 文件,还有另一个将 Hello World 打印到 kernel 的 hello_driver.c 文件强> 日志。
我可以编译 hello_driver.c 文件并将 Hello World 打印到内核日志中但是我无法在同一个 Makefile 程序中编译这两个 .c 文件。
我已经尝试过这个 Makefile 但它不起作用:
obj-o += hello.o hello_driver.o
KVERSION = $(shell uname -r)
all:
make -C /lib/modules/$(KVERSION)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(KVERSION)/build M=$(PWD) clean
【问题讨论】:
-
请解释究竟是什么不起作用。构建错误?运行时错误?
-
如果hello.c是用户空间程序,你需要有不同的Makefile,或者至少使用一些ifdefery。
标签: linux makefile linux-kernel operating-system