导航:首页 > 源码编译 > 模块编译

模块编译

发布时间:2022-01-12 16:13:21

Ⅰ 驱动编译进内核和编译模块的区别

第一次把自己编译的驱动模块加载进开发板,就出现问题,还好没花费多长时间,下面列举出现的问题及解决方案1:出现insmod:errorinserting'hello.ko':-1Invalidmoleformat法一(网上的):是因为内核模块生成的环境与运行的环境不一致,用linux-2.6.27内核源代码生成的模块,可能就不能在linux-2.6.32.2内核的linux环境下加载,需要在linux-2.6.27内核的linux环境下加载。a.执行uname-r//查看内核版本b.一般出错信息被记录在文件/var/log/messages中,执行下面命令看错误信息#cat/var/log/messages|tail若出现类似下面:Jun422:07:54localhostkernel:hello:versionmagic'2.6.35.6-45.fc14.i686.PAE'shouldbe'2.6.35.13-92.fc14.i686.PAE'则把Makefile里的KDIR:=/lib/moles/2.6.35.6-45.fc14.i686.PAE/build1改为KDIR:=/lib/moles/2.6.35.13-92.fc14.i686.PAE/build1//改成自己内核源码路径(这里的build1是一个文件链接,链接到/usr/src/kernels/2.6.35.6-45.fc14.i686.PAE和13-92的)然并卵,我的fedora14/usr/src/kernels下并没有2.6.35.13-92.fc14.i686.PAE,只有2.6.35.13-92.fc14.i686,虽然不知道两者有什么区别,但改成2.6.35.13-92.fc14.i686还是不行,照样这个问题,还好后来在看教学视频的到启发法二:改的还是那个位置KDIR:=/opt/FriendlyARM/linux-2.6.32.2//把这里改成你编译生成kernel的那个路径all:$(MAKE)-C$(KDIR)M=$(PWD)molesARCH=armCROSS_COMPILE=arm-linux-//加这句2.[70685.298483]hello:molelicense'unspecified'taintskernel.[70685.298673]方法:在模块程序中加入:MODULE_LICENSE("GPL");3.rmmod:chdir(2.6.32.2-FriendlyARM):Nosuchfileordirectory错误解决方法:lsmod可查看模块信息即无法删除对应的模块。就是必须在/lib/moles下建立错误提示的对应的目录((2.6.32.2)即可。必须创建/lib/moles/2.6.32.2这样一个空目录,否则不能卸载ko模块.#rmmodnls_cp936rmmod:chdir(/lib/moles):Nosuchfileordirectory但是这样倒是可以卸载nls_cp936,不过会一直有这样一个提示:rmmod:mole'nls_cp936'notfound初步发现,原来这是编译kernel时使用makemoles_install生成的一个目录,但是经测试得知,rmmod:mole'nls_cp936'notfound来自于busybox,并不是来自kernel1).创建/lib/moles/2.6.32.2空目录2).使用如下源码生成rmmod命令,就可以没有任何提示的卸载ko模块了[luther.gliethttp]#include#include#include#include#include#includeintmain(intargc,char*argv[]){constchar*modname=argv[1];intret=-1;intmaxtry=10;while(maxtry-->0){ret=delete_mole(modname,O_NONBLOCK|O_EXCL);//系统调用sys_delete_moleif(retread_proc=procfile_read;////Our_Proc_File->owner=THIS_MODULE;Our_Proc_File->mode=S_IFREG|S_IRUGO;Our_Proc_File->uid=0;Our_Proc_File->gid=0;Our_Proc_File->size=37;printk("/proc/%screated\n",procfs_name);return0;}voidproc_exit(){remove_proc_entry(procfs_name,NULL);printk(KERN_INFO"/proc/%sremoved\n",procfs_name);}mole_init(proc_init);mole_exit(proc_exit);[html]viewplainifneq($(KERNELRELEASE),)obj-m:=proc.oelseKDIR:=/opt/FriendlyARM/linux-2.6.32.2#KDIR:=/lib/moles/2.6.35.13-92.fc14.i686.PAE/build1PWD:=$(shellpwd)all:$(MAKE)-C$(KDIR)M=$(PWD)molesARCH=armCROSS_COMPILE=arm-linux-clean:rm-f*.ko*.o*.mod.o*.mod.c*.symversendifmake后生成proc.ko,再在开发板上insmodproc.ko即可执行dmesg就可以看到产生的内核信息啦

Ⅱ 如何单独编译安卓系统源码指定模块

android源码目录下的build/envsetup.sh文件,描述编译的命令

- m: Makes from the top of the tree.

- mm: Builds all of the moles in the current directory.

- mmm: Builds all of the moles in the supplied directories.

要想使用这些命令,首先需要在android源码根目录执行. build/envsetup.sh 脚本设置环境

m:编译所有的模块

mm:编译当前目录下的模块,当前目录下要有Android.mk文件

mmm:编译指定路径下的模块,指定路径下要有Android.mk文件

下面举个例子说明,假设我要编译android下的\hardware\libhardware_legacy\power模块,当前目录为源码根目录,方法如下:

1、. build/envsetup.sh

2、mmm hardware/libhardware_legacy/power/

编译完后 运行 make snod

会重新将你改过的模块打入到system.img中

Ⅲ linux内核模块,怎么编译

我来说下吧 本身你这个问题问的有点歧义 不知道你问的是内核编译 还是模块编译 两个不是一个东西 尽管模块加载后 也是内核的一部分 看看其他的回答 以为是单纯的内核的编译了 模块本身在linux下面是可以分为静态和动态加载的 要是采用静态加载的话 就是从新编译内核 和内核的编译基本是一回事 但是多采用动态加载 这个也简单点
从你的下面的模版可以看出 你是想写驱动程序吧 驱动一般作为动态加载的就可以了 写好你的c文件 格式和上面的差不多 然后GCC编译 生成.o文件,不要生成可执行文件 ( 如果是玩Embedded 就下载到目标板了 minicom 的使用) 如果是就在linux机器上 直接执行 insmod lsmod rmmod 这些就好了 这里也是简单的说下了 内核的编译 写驱动程序 本身就是个比较难得事情了 要个很长的时间去学习了 慢慢积累 好运

Ⅳ 如何单独编译frameworks下的某个模块

注:mmm和mm命令必须在执行“.build/envsetup.sh”之后才能使用,并且只编译发生变化的文件。如果要编译模块的所有文件,需要-B选项,例如mm -B。

Ⅳ 如何单独编译Android源码中的模块

1.make 模块名称
需要查看Android.mk文件的LOCAL_PACKAGE_NAME变量。
2.mmm命令
用于在源码根目录编译指定模块,参数为模块的相对路径。只能在第一次编译后使用。比如要编译Phone部分源码,需要在终端中执行以下命令:
$mmm packages/apps/phone
3.mm命令
用于在模块根目录编译这个模块。只能在第一次编译后使用。例如要编译Phone部分源码,需要在终端中执行以下命令:
$cd packages/apps/phone
$mm
注:mmm和mm命令必须在执行“.build/envsetup.sh”之后才能使用,并且只编译发生变化的文件。如果要编译模块的所有文件,需要-B选项,例如mm -B。

Ⅵ 如何编译一个linux下的驱动模块

按照《linux设备驱动开发详解》一书中的步骤实现经典例子"hello,world!"的例子。
具体步骤如下:
=============================================
1.源码如下:
/*
* hello.c -- the example of printf "hello world!" in the screen of driver program
*/
#include <linux/init.h>
#include <linux/mole.h>
MODULE_LICENSE("Dual BSD/GPL");/* declare the license of the mole ,it is necessary */
static int hello_init(void)
{
printk(KERN_ALERT "Hello World enter!\n");
return 0;
}
static int hello_exit(void)
{
printk(KERN_ALERT "Hello world exit!\n");
}
mole_init(hello_init); /* load the mole */
mole_exit(hello_exit); /* unload the mole */
进入目录:
[root@Alex_linux /]#cd /work/jiakun_test/moletest
[root@Alex_linux moletest]# vi hello.c
然后拷入上面书上的源码。
2.编译代码:
1>.首先我在2.4内核的虚拟机上进行编译,编译过程如下:
[root@Alex_linux moletest]#gcc -D__KERNEL__ -I /usr/src/linux -DMODULE -Wall -O2 -c -o hello.o hello.c
其中-I选项指定内河源码,也就是内核源码树路径。编译结果:
hello.c:1:22: net/sock.h: No such file or directory
hello.c: In function `hello_init':
hello.c:6: warning: implicit declaration of function `printk'
hello.c:6: `KERN_ALERT' undeclared (first use in this function)
hello.c:6: (Each undeclared identifier is reported only once
hello.c:6: for each function it appears in.)
hello.c:6: parse error before string constant
hello.c: In function `hello_exit':
hello.c:11: `KERN_ALERT' undeclared (first use in this function)
hello.c:11: parse error before string constant
hello.c: At top level:
hello.c:13: warning: type defaults to `int' in declaration of `mole_init'
hello.c:13: warning: parameter names (without types) in function declaration
hello.c:13: warning: data definition has no type or storage class
hello.c:14: warning: type defaults to `int' in declaration of `mole_exit'
hello.c:14: warning: parameter names (without types) in function declaration
hello.c:14: warning: data definition has no type or storage class
在网上查询有网友提示没有引入kernel.h
解决:vi hello.c
在第一行加入:#include <linux/kernel.h>
再次编译仍然报KERN_ALERT没有声明
修改编译条件-I,再次编译:
[root@Alex_linux moletest]#gcc -D__KERNEL__ -I /usr/src/linux -DMODULE -Wall -O2 -c -o hello.o hello.c
[root@Alex_linux moletest]#ls
hello.c hello.o Makefile
[root@Alex_linux moletest]#
2>.接着我尝试在2.6内核的虚拟机上进行编译
编译过程如下:
[root@JiaKun moletest]# ls
hello.c makefile
[root@JiaKun moletest]# vi hello.c
[root@JiaKun moletest]# make
make -C /mylinux/kernel/2.4.18-rmk7 M=/home/alex/test/moletest moles
make: *** /mylinux/kernel/2.4.18-rmk7: No such file or directory. Stop.
make: *** [moles] Error 2
[root@JiaKun moletest]# vi makefile
[root@JiaKun moletest]# make
make -C /usr/src/kernels/2.6.18-53.el5-i686 M=/home/alex/test/moletest moles
make[1]: Entering directory `/usr/src/kernels/2.6.18-53.el5-i686'
scripts/Makefile.build:17: /home/alex/test/moletest/Makefile: No such file or directory
make[2]: *** No rule to make target `/home/alex/test/moletest/Makefile'. Stop.
make[1]: *** [_mole_/home/alex/test/moletest] Error 2
make[1]: Leaving directory `/usr/src/kernels/2.6.18-53.el5-i686'
make: *** [moles] Error 2
[root@JiaKun moletest]# mv makefile Makefile
[root@JiaKun moletest]# make
make -C /usr/src/kernels/2.6.18-53.el5-i686 M=/home/alex/test/moletest moles
make[1]: Entering directory `/usr/src/kernels/2.6.18-53.el5-i686'
CC [M] /home/alex/test/moletest/hello.o
Building moles, stage 2.
MODPOST
CC /home/alex/test/moletest/hello.mod.o
LD [M] /home/alex/test/moletest/hello.ko
make[1]: Leaving directory `/usr/src/kernels/2.6.18-53.el5-i686'
[root@JiaKun moletest]# ls
hello.c hello.ko hello.mod.c hello.mod.o hello.o Makefile Mole.symvers

Ⅶ 易语言模块的编译


当子程序编写完成,在别的窗口里是无法调用的,除非整体代码复制过去,那就太麻烦了,所以,需要编译出一个独立的EC文件(易语言模块文件)方便编写程序时调用,编译的方法很简单,执行菜单【程序】-【配置】选项,弹出配置对话框,输入模块的信息,单击确定,然后执行菜单【编译】-【编译】或者快捷键F7来调出保存文件对话框,选定路径,输入文件名,单击确定按钮,如无明显错误即可编译完成。

Ⅷ Linux动态模块怎样编译

编译模块的make file 必须是Makefile,不能是makefile. //why?

ifneq ($(KERNELRELEASE),)
obj-m := your.o
mytest-objs := file1.o file2.o file3.o
else
KDIR := /lib/moles/$(shell uname -r)/build
PWD := $(shell pwd)
default:
$(MAKE) -C $(KDIR) M=$(PWD) moles
endif

把your换成你的source name ,然后保存为Mafefile ,make 一次就可以了。

Ⅸ 请教易语言模块如何编译成程序

*.e文件是易语言的源代码文件,该文件中保存了易语言所设计的程序的所有源代码。无论是*.ec的模块文件还是*.exe的可执行文件都是通过*.e文件编译而来的.

如果编译源代码文件(也就是*.e的文件)后,生成的是*.ec的文件,那么说明这份源代码是一个易语言模块的源代码,它只能被编译为*.ec的易语言模块文件。

要生成exe的可执行文件,需要在新建易语言程序项目时选择“Windows窗口程序”类型,该类型的项目可以编译为exe文件。

另:如何建立“Windows窗口程序”项目?启动易语言后在弹出的“新建...”窗口中选择即可。

阅读全文

与模块编译相关的资料

热点内容
phpsql单引号 浏览:84
英雄联盟压缩壁纸 浏览:450
办公app需要什么服务器 浏览:626
安卓服务器怎么获得 浏览:806
空调压缩机冷媒的作用 浏览:779
淘宝app是以什么为利的 浏览:655
java提取图片文字 浏览:922
我的世界手机版指令复制命令 浏览:33
java判断字符串为数字 浏览:924
androidrpc框架 浏览:488
云服务器essd和ssd 浏览:522
家用网关的加密方式 浏览:1
怎么从ppt导出pdf文件 浏览:971
换汽车空调压缩机轴承 浏览:845
平板怎么登录安卓端 浏览:195
图像拼接计算法 浏览:255
怎么打开饥荒服务器的本地文件夹 浏览:291
usb扫描枪编程 浏览:673
博易大师手机app叫什么 浏览:663
刮眼影盘解压方法 浏览:966