writing a trivial kernel module - help
Hi, I am trying to learn how to write a kernel module.
I am following the excellent guide from The Linux Documentation Project called The Linux Kernel Module Programming Guide v.2.6.4. My machine is running Ubuntu Lucid Lynx (10.04) Code:
uname -r I am trying to run the following trivial kernel module Code:
/* Code:
obj−m += hello−1.o I got the following error from make Code:
uname: extra operand `−r' so I changed the Makefile to Code:
obj−m += hello-1.o Code:
make −C /lib/modules/2.6.32-22-generic/build M=/home/sonny/km modules lib/modules/2.6.32-22-generic links to (what I think are) the right places. Any help would be much appreciated. Thanks a lot! |
Quote:
Either way, that'll be why it's not recognising "−C" as an option - you need to make sure it's "-C". John G |
make is not magical
kaching, I had not looked at this issue closely until now.
I believe the problem may be a confusion about what make is and what it does. Make is a scripting language for automating the process of software development or any other process which requires some sequence of one or more commands to the command shell. I use it for compiler writing and other software generation using flex and bison because it automates calling flex and bison, followed by compiling and linking the programs written by flex and bison. You don't need to use make to compile and link kernel modules. If you have not written a makefile before, it may be easier if you become familiar with using make independently of learning how to build kernel modules. Please refer to the man page about make and perhaps other material to get a solid feel for using make before trying to use a makefile to build your kernel module. You can do this either before or after you build your kernel module, but doing both at the same time adds an extra layer of difficulty to your ostensible goal of building the module. I will follow up on this later, I need to go to another duty right now. |
Hi, JohnGraham -
Good eyes! The OP hasn't posted back, but I believe you found the problem. Specifically, "uname -r" and "make -C" need a MINUS SIGN. For us 7-bit ASCII guys, that means exactly one character: 0x2d (ASCII 45). But in Unicode, it can mean any of "hyphen-minus" (the character we need), hyphen, figure-dash, em-dash, etc etc (one of which I believe the OP accidentally used). Anything besides "hyphen-minus" (0x2d) will result in exactly the errors shown above. Here's a link: http://www.decodeunicode.org/en/u+2212/properties kaching - Please post back what you found. And please mark the problem "solved", if you fixed it! |
@JohnGraham, thanks a lot you were right on the money! You indeed solved my problem (and to the rest following this thread, I apologize for not updating the thread as solved before.
@ArthurSittler thanks for the advice with make. Although I think that the Makefile in this case was easy enough for a novice programmer as myself to follow. I am still hitting other walls writing this kernel module, but that's for another thread... At least I got it to compile... Thanks again! [SOLVED] - Yippee! |
All times are GMT -5. The time now is 07:12 PM. |