C 试图加载模块,但在试图编译模块时,计算机会声明有几个结构未定义

C 试图加载模块,但在试图编译模块时,计算机会声明有几个结构未定义,c,linux,struct,makefile,C,Linux,Struct,Makefile,本模块的目的基本上与在linux命令行cat/proc/buddyinfo中键入时所做的相同 代码 现在,令人困惑的是当我打字的时候 #包括 有许多结构 pgdat is a struct that allows access to the current page data. *first_online_pgdat(void); is a function that points to the first page. *next_online_pgdat(struct pglist_da

本模块的目的基本上与在linux命令行cat/proc/buddyinfo中键入时所做的相同

代码

现在,令人困惑的是当我打字的时候

#包括

有许多结构

pgdat is a struct that allows access to the current page data.

*first_online_pgdat(void); is a function that points to the first page. 

*next_online_pgdat(struct pglist_data*pgdat); points to the next page.

struct pglist_data *pgdat; 

is basically the representation of my page.

and extern struct zone *zone is the representation of the zone type of the pages.
所有这些都包含在mmzone中,但就好像mmzone.h中的函数甚至没有被引用一样


我真的不明白发生了什么,但我希望有经验的linux程序员能提供帮助。

可能是个愚蠢的问题,但你编译过你的内核吗?我之前确实编译过,但我没有安装编译过的内核,因为这个文件在这里?它没有用内核编译,所以我决定改为使用insmod路径。我把我的内核回滚到当前版本,因为我弄得有点乱。所以我回滚了我的内核,现在我正在尝试insmod,问题是我仍然是从哪里开始的。我不能为这个文件执行make命令,因为它说应该在linux/mmzone.h中定义的所有内容都是“未定义的”。这些错误看起来更像是链接错误,而不是编译错误。您是否尝试过详细模式(
make V=1…
)来查看完整的命令?不,我甚至不知道我可以这样做。
make -C /lib/modules/5.4.0-26-generic/build M=/usr/local/share/source_code/version1/module-edits modules
make[1]: Entering directory '/usr/src/linux-headers-5.4.0-26-generic'
  Building modules, stage 2.
  MODPOST 1 modules
ERROR: "next_online_pgdat" [/usr/local/share/source_code/version1/module-edits/printbuddy.ko] undefined!

ERROR: "next_zone" [/usr/local/share/source_code/version1/module-edits/printbuddy.ko] undefined!

ERROR: "zone" [/usr/local/share/source_code/version1/module-edits/printbuddy.ko] undefined!

ERROR: "first_online_pgdat" [/usr/local/share/source_code/version1/module-edits/printbuddy.ko] undefined!
make[2]:  [scripts/Makefile.modpost:94: __modpost] Error 1
make[1]:  [Makefile:1632: modules] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-5.4.0-26-generic'
make:  [makefile:5: all] Error 2
pgdat is a struct that allows access to the current page data.

*first_online_pgdat(void); is a function that points to the first page. 

*next_online_pgdat(struct pglist_data*pgdat); points to the next page.

struct pglist_data *pgdat; 

is basically the representation of my page.

and extern struct zone *zone is the representation of the zone type of the pages.