2017-10-21 79 views
2

我想在Ubuntu 12.04.1中進行系統調用。我試圖在Ubuntu 12.04.1中進行系統調用。我遇到了一個錯誤編譯我的hello.c文件

#include <linux/kernel.h> 
asmlinkage long sys_hello(void) { 
    printk("hello world\n"); 
    return 0; 
} 

它顯示了錯誤:

error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘long’ asmlinkage long sys_hello(void)

+3

「問題」與問題描述有點相似... – fvu

+0

您有「問題」。你有什麼問題?任何特定的錯誤消息?你的代碼是否會喚起離開者的邪惡哀傷? –

+0

error:expected'=',',',';','asm'或'__attribute__'before'long' asmlinkage long sys_hello(void) ^ ~~~ @RobertColumbia –

回答

0

我假設你正在試圖建立一個內核模塊,我得到一個錯誤,我的編譯文件hello.c。您需要在內核構建系統中執行此操作。您無法將其編譯爲常規應用程序或共享對象。最簡單的方法可能是將模塊修補到Ubuntu內核樹中,並使用these instructions進行構建。

0

I'm trying to make a system call in Ubuntu 12.04.1.

假設你的意思是你想創建系統調用:內核模塊不能添加系統調用。所有的系統調用都必須編譯到內核中。

相關問題