开发者

Compile Linux kernel module (lincan)

开发者 https://www.devze.com 2023-02-03 05:26 出处:网络
I use Ubuntu 10.10 - 2.6.35.23-generic I want to compile the lincan-module (http://sourceforge.net/projects/ocera/), but it doesn\'t work like I want... That\'s my first compilation of a kernel modul

I use Ubuntu 10.10 - 2.6.35.23-generic

I want to compile the lincan-module (http://sourceforge.net/projects/ocera/), but it doesn't work like I want... That's my first compilation of a kernel module. I did this:

First unzipped the lincan-sources to my home directory. Then excecuted "make" with this output:

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'

Then I type "make install":

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'

And it happend nothing. I find no kernel module. What did I wrong? Why is there no autoconf.h and the other files? Have you any hints for me? Thanks!


Now I created hardlinks for the missing files (aut开发者_StackOverflowoconf.h and utsrelease.h). They are in /usr/src/linux-headers-2.6.35.23-generic/include/generated/

Now it compile much more. This is the first error that appears:

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


Now I created hardlinks for the missing files (autoconf.h and utsrelease.h).

You have to install the package that contains the build environment as created when the kernel you are running was built. Source is generally pointless (what do you want with, say, 8139too.c anyway when you are going to build an external module), save for the kernel headers. I can't say where the build environment is located in Debian or its offsprings, but in openSUSE there would be a "kernel-default-devel" package for example to contain utsrelease.h and autoconf.h, as well as - via dependencies - the static header files required. Thus, look for an preexisting deb package that contains this.


Please install kernel build prerequisites given here. This would install necessary tools for building/compiling the kernel modules.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号