2016-11-28 44 views
0

我的代碼包含如何編譯C文件與系統調用

#include <linux/kernel.h> 
#include <linux/init.h> 
#include <linux/sched.h> 
#include <linux/syscalls.h> 

當我使用標準GCC,它抱怨error: linux/init.h: No such file or directory

那麼編譯這個c文件的正確方法是什麼?

+4

http://stackoverflow.com/questions/28423477/linux-init-h-no-such-file-or-direcotry – arsv

+0

你大多是編譯一個內核模塊,所以你需要準備你的編譯環境爲那個 – user3528438

+0

如果我成功編譯了內核,我應該怎麼做才能調用這個c文件? – ThomasWest

回答

0

假設你在一個Linux機器上運行,確保你已經安裝了Linux內核頭文件,因爲該文件是其中的一部分。

在我的系統上,apt-get install linux-headers可以解決問題。