错误:预期' asm'不久

时间:2016-11-22 04:35:13

标签: c makefile linux-kernel ubuntu-12.04 asmx

嘿伙计们,我试图在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'

我不完全确定要做什么,而且我被卡住了。我非常感谢任何帮助。

1 个答案:

答案 0 :(得分:0)

您需要内核源代码。会在那里:https://www.kernel.org/

指南,如果您没有:http://tldp.org/LDP/lkmpg/2.6/html/lkmpg.html