2011-01-10 166 views
0

我使用Ubuntu 10.10 - 2.6.35.23泛型编译Linux内核模块(lincan)

我想编译lincan模块(http://sourceforge.net/projects/ocera/),但它不不像我想要的那样工作......这是我第一次编译内核模块。我这样做:

首先解压lincan-sources到我的主目录。然后excecuted “做” 与此输出:

make -C /home/x/can/lincan-0.3.4/src SOURCES_DIR=/home/x/can/lincan-0.3.4/src default ; make -C /home/x/can/lincan-0.3.4/utils SOURCES_DIR=/home/x/can/lincan-0.3.4/utils default ; 
awk: cannot open /lib/modules/2.6.35-23-generic/build/include/linux/autoconf.h (No such file or directory) 
awk: cannot open /lib/modules/2.6.35-23-generic/build/include/linux/autoconf.h (No such file or directory) 
grep: /lib/modules/2.6.35-23-generic/build/include/linux/utsrelease.h: No such file or directory 
make[1]: Betrete Verzeichnis '/home/x/can/lincan-0.3.4/src' 
Makefile:216: /lib/modules/2.6.35-23-generic/build/Rules.make: No such file or directory 
make[1]: *** Keine Regel, um »/lib/modules/2.6.35-23-generic/build/Rules.make« zu erstellen. Schluss. 
make[1]: Verlasse Verzeichnis '/home/x/can/lincan-0.3.4/src' 
make[1]: Betrete Verzeichnis '/home/x/can/lincan-0.3.4/utils' 
cc -I../include -O2 -Wall -c -o rxtx.o rxtx.c 
rxtx.c: In function ‘main’: 
rxtx.c:49: warning: format not a string literal and no format arguments 
rxtx.c:73: warning: format not a string literal and no format arguments 
rxtx.c:51: warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result 
rxtx.c:58: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result 
rxtx.c:62: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result 
rxtx.c:67: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result 
rxtx.c:75: warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result 
rxtx.c:81: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result 
cc rxtx.o -o rxtx 
cc -I../include -O2 -Wall -c -o sendburst.o sendburst.c 
cc sendburst.o -o sendburst 
cc -I../include -O2 -Wall -c -o readburst.o readburst.c 
cc readburst.o -o readburst 
cc -I../include -O2 -Wall -c -o send.o send.c 
send.c: In function ‘main’: 
send.c:25: warning: format not a string literal and no format arguments 
send.c:27: warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result 
send.c:33: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result 
send.c:35: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result 
send.c:40: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result 
cc send.o -o send 
cc -I../include -O2 -Wall can-proxy.c -o can-proxy 
make[1]: Verlasse Verzeichnis '/home/x/can/lincan-0.3.4/utils' 

然后我输入 “make安装”:

make -C /home/x/can/lincan-0.3.4/src SOURCES_DIR=/home/x/can/lincan-0.3.4/src install ; make -C /home/x/can/lincan-0.3.4/utils SOURCES_DIR=/home/x/can/lincan-0.3.4/utils install ; 
awk: cannot open /lib/modules/2.6.35-23-generic/build/include/linux/autoconf.h (No such file or directory) 
awk: cannot open /lib/modules/2.6.35-23-generic/build/include/linux/autoconf.h (No such file or directory) 
grep: /lib/modules/2.6.35-23-generic/build/include/linux/utsrelease.h: No such file or directory 
make[1]: Betrete Verzeichnis '/home/x/can/lincan-0.3.4/src' 
Makefile:216: /lib/modules/2.6.35-23-generic/build/Rules.make: No such file or directory 
make[1]: *** Keine Regel, um »/lib/modules/2.6.35-23-generic/build/Rules.make« zu erstellen. Schluss. 
make[1]: Verlasse Verzeichnis '/home/x/can/lincan-0.3.4/src' 
make[1]: Betrete Verzeichnis '/home/x/can/lincan-0.3.4/utils' 
echo Nothing to install 
Nothing to install 
make[1]: Verlasse Verzeichnis '/home/x/can/lincan-0.3.4/utils' 

而且它的发生无关。我找不到内核模块。我错了什么?为什么没有autoconf.h和其他文件?你有什么提示吗?谢谢!


现在我创建了缺少文件(autoconf.h和utsrelease.h)的硬链接。它们位于/usr/src/linux-headers-2.6.35.23-generic/include/generated/

现在它编译得更多了。这是出现的第一个错误:

In file included from /home/x/can/lincan-0.3.4/src/../include/main.h:38, 
       from /home/x/can/lincan-0.3.4/src/proc.c:37: 
/home/x/can/lincan-0.3.4/src/../include/./can_queue.h: In function ‘canque_edge_decref’: 
/home/x/can/lincan-0.3.4/src/../include/./can_queue.h:652: error: invalid initializer 
/home/x/can/lincan-0.3.4/src/../include/./can_queue.h:652: error: invalid initializer 
/home/x/can/lincan-0.3.4/src/../include/./can_queue.h:652: error: incompatible types when assigning to type ‘int’ from type ‘atomic_t’ 
make[3]: *** [/home/x/can/lincan-0.3.4/src/proc.o] Fehler 1 
make[2]: *** [_module_/home/x/can/lincan-0.3.4/src] Fehler 2 
make[2]: Verlasse Verzeichnis '/usr/src/linux-headers-2.6.35-23-generic' 
make[1]: *** [make_this_module] Fehler 2 
+0

您可能在ubuntu站点上发布更多运气? – R0MANARMY 2011-01-10 13:33:47

回答

1

现在我创建硬链接为丢失的文件(autoconf.h和utsrelease.h)。

您必须安装含有构建环境创建为正在运行的内核生成时的包。源代码通常是毫无意义的(无论如何,当你打算构建一个外部模块时,你想要什么,比如8139too.c),除了内核头文件。我不能说构建环境位于Debian或其后代的哪个位置,但在openSUSE中将包含一个“kernel-default-devel”包,例如包含utsrelease.hautoconf.h,以及 - 通过依赖关系 - 静态头文件需要的文件。因此,寻找一个包含这个的预先存在的deb包。

+0

在Ubuntu中,它是linux-headers- *软件包:https://packages.ubuntu.com/search?suite=all&searchon=names&keywords=linux-header或者只是`sudo apt-get install linux-headers-generic` – osgx 2017-06-03 21:08:18

-1

请安装给定的内核构建先决条件here.这将安装必要的工具来构建/编译内核模块。

+0

这是不完全正确,ubuntu具有linux-header- *包中的内核模块构建所需的所有文件:https://packages.ubuntu.com/search?suite=all&searchon=names&keywords=linux-header;而从https://kernelnewbies.org/KernelBuild链接的KernelBuild用于构建新的内核。 – osgx 2017-06-03 21:04:47