小编Cod*_*Art的帖子

如何将 C 编译输出文件(Linux 内核模块)放在与源文件不同的目录中(使用 Makefile)

我已经查看了这些以及这些其他解决方案,但无法编写正确的 Makefile 来产生我想要的结果。

所以,我有这个simple.c文件。它模拟linux内核模块的加载和删除。地点:/path/to/dir/simple.c

#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>

/* This function is called when the module is loaded. */
int simple_init(void)
{
       printk(KERN_INFO "Loading Module\n");

       return 0;
}

/* This function is called when the module is removed. */
void simple_exit(void) {
    printk(KERN_INFO "Removing Module\n");
}

/* Macros for registering module entry and exit points. */
module_init( simple_init );
module_exit( simple_exit );

MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Simple Module");
MODULE_AUTHOR("SGG");
Run Code Online (Sandbox Code Playgroud)

我也将它Makefile放在与simple.c, …

c linux makefile compilation

5
推荐指数
1
解决办法
346
查看次数

标签 统计

c ×1

compilation ×1

linux ×1

makefile ×1