【发布时间】:2017-04-05 15:43:02
【问题描述】:
大家好,我正在尝试在 ubuntu 12.04.1 中进行系统调用。我在编译 hello.c 文件时遇到问题
#include <linux/kernel.h>
asmlinkage long sys_hello(void) {
printk("hello world\n");
return 0;
}
我认为问题出在我的 Makefile 中,但我仍然是编写 Makefile 的初学者。
hello.o: hello.c
gcc -c -o hello.o hello.c
obj-y := hello.o
我知道我必须添加 obj-y := hello.o 部分,以便它可以编译并包含在内核中。当我运行 make 我得到这个错误:
error: expected '=', ',', ';', 'asm' or '__attribute__' before 'long'
我不完全确定该怎么做,我被困住了。我将不胜感激任何帮助。
【问题讨论】:
-
你尝试加入
<linux/linkage.h>吗? -
现在我收到一个致命错误:linux/linkage.h: No such file or directory
标签: c makefile linux-kernel ubuntu-12.04 asmx