Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Including a 3rd party library in a kernel module.

    I have a very basic makefile to compile a kernel module.

    I am specifying the objects as follows:

    obj-m := mymodule.o
    mymodule-objs := obj1.o obj2.o

    Another post I saw on this forum suggested simply tacking on the .a file to the my module-objs line:

    mymodule-objs := obj1.o obj2.o dalibrary.a

    However, when I run make I get an error indicating that there is no rule to make "dalibrary.a".

    I have also attempted to add -L<dir> -ldalibrary.a just after $(EXTRA_CFLAGS) in the following stanza to no avail:

    depend .depend dep:
    $(CC) $(EXTRA_CFLAGS) -M *.c > .depend

    So... how do I include a pre-compiled 3rd party library in my kernel module Makefile?

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    In the rules to create the .ko module, you would include the .a file with a -l rootname option, where rootname refers to librootname.a. Do note that you need to be sure that the static library librootname.a is a kernel library. If it has user-space code in it, you will not be successful in linking it to the kernel module.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts