linking static library to generate LKM

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi All,

I want to know how to link object files (.o) to a static library (.a)
and generate Loadable Kernel Module. Any pointers to examples 
demonstrating this should be of great help.

Here is what I do now.

I have three source files say x.c, y.c and z.c

I compile x.c to generate static library libx.a using the following 
command.

# ar -r libx.a x.c

Now I compile y.c and z.c to generate x.o and y.o

# cc -DMODULE -D__KERNEL__ -I/usr/src/linux/include -O2 -c -o y.o y.c 
# cc -DMODULE -D__KERNEL__ -I/usr/src/linux/include -O2 -c -o z.o z.c

Now as the final linking step I do this

# ld -r -o lkm.o y.o z.o -lx -L.

But when I try to load lkm.o I get unresolved symbol errors for the 
functions which are in x.c. I guess there is something wrong with 
linking procedure I use to generate the lkm.o

Please help me fix this.

Thanks,
-Jinu


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux