Linux内核模块编程,多源码Makefile编写

本文介绍了在Linux内核模块编程中遇到的多源码Makefile编写问题及其解决方法。通过举例说明了单文件.c编程的两种Makefile书写方式,并详细阐述了如何在多文件.c .h模块编程中编写Makefile,实现功能模块化的编译,以应对复杂需求。
摘要由CSDN通过智能技术生成

https://mp.csdn.net/console/editor/html/107838044

在学习内核模块编程的时候遇到了一些由于Makefile书写不正确导致的问题。一个.c源文件的Makefile按照网上的大部分资料介绍那样是没有问题的,多个源文件的内核模块编程时,就出现问题了。把过程和解决方法贴出来,供大家参考,一起学习。

单文件.c的编程:

     单文件.c编写内核模块是常用的内核模块编写方法,对一些比较简单的功能比较使用。

     test.c

//test.c

#include <linux/module.h>
#include <linux/init.h>
#include <linux/sched.h>
#include <linux/kernel.h>
#include <linux/fs.h>
#include <linux/types.h>
#include <linux/buffer_head.h>
#include <linux/blkdev.h>
#include <linux/msdos_fs.h>
#include <linux/fcntl.h>
#include <linux/delay.h>
#include <linux/uio.h>
#include <asm/uaccess.h>
#include <asm/mman.h>

MODULE_LICENSE("GPL");

static int __init init_test(void)
{
    print
  • 2
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值