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

    Device driver + static link library?


    To compile a loadable module, as far as I know you add something like this to the make file:

    obj-m := my_module1.o my_module2.o

    But what if I want to link with a static library? Is there a way to do this? Seems like simply adding 3rd_party_library.a to obj-m I get something like

    target '3rd_party_library.a' doesn't match the target pattern

    If I were to write the makefile from scratch I'd try something like

    ld -r -o my_module.ko my_module1.o my_module2.o 3rd_party_library.a

    But within the framework of the existing directory structure and multi-level make files and all that I don't know how to do it.

    Thank you,

  2. #2
    Linux Enthusiast gerard4143's Avatar
    Join Date
    Dec 2007
    Canada, Prince Edward Island

    Try this it might help

    This web site shows the proper way to compile multi modules...Hope this helps

  3. #3
    Thank you for your help. However, that page didn't mention anything about static libraries. I could extract the objects out of the static library (since static libraries are basically archived object files), however then make will attempt to recompile the object files, which I do not have the source to (since it's 3rd party static library).

    The linker ld knows how to handle .a (static library) files. I just need to find a way to let make know that the .a file should be passed to the linker, but should be ignored by the compile commands.

    I'll check out the rest of the site you posted and see if I can find anything.

    Thank you.

  4. $spacer_open
  5. #4
    Ok, I found it.

    It's as described in the document that gerard4143 provided, except it wasn't spelled out exactly.

    obj-m := mymodule.o
    mymodule-objs := my_module1.o my_module2.o 3rd_party_library.a

    Make file knows how to handle .a files, I just had to find the right way to include it.

  6. #5

    Kernel module static linking without source of the static object

    Need help concerning the same issue...
    How do we include a .o or .a file so that the make process just links with this file instead of trying to compile it?!

Posting Permissions

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