LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Trouble Compiling Kernel Module... (https://www.linuxquestions.org/questions/linux-general-1/trouble-compiling-kernel-module-380980/)

Elric of Grans 11-07-2005 11:50 PM

Trouble Compiling Kernel Module...
 
G'Day,

I am experiencing a strange problem with recompiling an external kernel module. I last compiled a month ago, and in that time the module source, kernel version and (crosscompiler) toolchain all remain unchanged: all that has changed is that I have upgraded to Ubuntu Breezy (hence all other utilities have been updated). Because all of the aspects which should directly impact this are unchanged, I am at a loss to explain why it no longer works.

My problem is this: when I compile my module, everything starts as normal, and it compiles, like so...

Code:

$ make
make -C /usr/src/linux/ M=/home/matthew/src/c/modules/omap-owire-dev modules
make[1]: Entering directory `/usr/src/arm-linux-2.6.13-rc4'
  CC [M]  /home/matthew/src/c/modules/omap-owire-dev/omap_owire.o
  Building modules, stage 2.
  MODPOST
make[1]: Leaving directory `/usr/src/arm-linux-2.6.13-rc4'

This is where it ends: for some reason it does not perform the linking process, and as such the omap_owire.ko file is never created; omap_owire.o, .omap_owire.o.cmd, and .tmp_versions/omap_owire.mod are all created.

I am able to recompile the kernel itself without any difficulties, as I can with regular applications, so I cannot explain this one. Any suggestions would be most appreciated!

Elric of Grans 11-10-2005 04:59 PM

I still have not been able to get this to work (according the kernel documentation, the Makefile is correct, so I have no idea why it does not), so I have been trying to compile it without the Makefile. This is what I have got so far:
Code:

$ make -C /usr/src/linux M=/home/matthew/src/c/modules/omap-owire-dev modules
omap-owire.o is created, along with .omap_owire.o.cmd and .tmp_versions/omap_owire.mod.
Code:

$ cd /usr/src/linux
$ ./scripts/mod/modpost -i Module.symvers vmlinux /home/matthew/src/c/modules/omap-owire-dev/omap_owire.o

omap_owire.mod.c is now created.
Code:

$ arm-linux-gcc -Wp,-MD,/home/matthew/src/c/modules/omap-owire-dev/omap_owire.mod.d -nostdinc \
-isystem/usr/local/arm/4.0.1/bin/../lib/gcc/arm-linux/4.0.1/include -D__KERNEL__ -Iinclude -DMODULE  -c -o \
/home/matthew/src/c/modules/omap-owire-dev/omap_owire.mod.o /home/matthew/src/c/modules/omap-owire-dev/omap_owire.mod.c

I now also have omap_owire.mod.o and omap_owire.mod.d. From here, it should be simple to finish (or so I thought).
Code:

$ arm-linux-gcc -r -o omap_owire.ko omap_owire.o omap_owire.mod.o
/usr/local/arm/4.0.1/bin/../lib/gcc/arm-linux/4.0.1/../../../../arm-linux/bin/ld: cannot find -lgcc_s
collect2: ld returned 1 exit status

If I look in lib/, I can see libgcc_s.so -> libgcc_s.so.1, and if I try to compile anything else and explicitly add -lgcc_s to the arguments, it all works fine. I have tried all sorts of things (eg -Ldirectory), but cannot seem to get rid of this last error. I also cannot explain why I have the original problem, but that is another issue. Any suggestions for either problem would be greatly appreciated!

exman 05-31-2006 12:57 AM

Hi,
i don't know if you are still having this problem but i ran into the same while porting a driver from Kernel 2.4 to 2.6.
You have to add a line like this in the makefile:
Code:

obj-m:=omap_owire.o
This tells the kbuild process compile and link your module.
exman


All times are GMT -5. The time now is 07:02 PM.