Welcome to Linux Forums! With a comprehensive Linux Forum, information on various types of Linux software and many Linux Reviews articles, we have all the knowledge you need a click away, or accessible via our knowledgeable members.
Write an article for LinuxForums Today! Win Great Prizes!
Find the answer to your Linux question:
New to Linux Forums? Register here for free!
    Linux Forums > GNU Linux Zone > The Linux Kernel > Device driver + static link library?

Forgot Password?
 The Linux Kernel   Compiling, theory, programming or other discussion about the linux kernel

Site Navigation
Linux Articles
Linux Forums
Linux Downloads
Linux Hosting
Free Magazines
Job Board
IRC Chat
RSS Feeds
Linux Forum Topics
Linux Forums
Your Distro
Linux Resources
GNU Linux Zone
The Community
Reply
 
Thread Tools Display Modes
Old 01-17-2008   #1 (permalink)
Just Joined!
 
Join Date: Jan 2008
Posts: 6
Device driver + static link library?

Hi,

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,
Ben
evilquesadilla is offline  



Reply With Quote
Old 01-18-2008   #2 (permalink)
Linux Enthusiast
 
gerard4143's Avatar
 
Join Date: Dec 2007
Location: Canada, Prince Edward Island
Posts: 632
Try this it might help

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

http://tldp.org/LDP/lkmpg/2.6/html/x351.html
gerard4143 is online now   Reply With Quote
Old 01-18-2008   #3 (permalink)
Just Joined!
 
Join Date: Jan 2008
Posts: 6
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.
evilquesadilla is offline   Reply With Quote
Old 01-18-2008   #4 (permalink)
Just Joined!
 
Join Date: Jan 2008
Posts: 6
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.
evilquesadilla is offline   Reply With Quote
Old 07-25-2008   #5 (permalink)
Just Joined!
 
Join Date: Jul 2008
Posts: 1
Kernel module static linking without source of the static object

Hey
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?!
gripened is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Free Magazines
A Newbie's Getting Started Guide to Linux
Learn the basics of the Linux operating systems. Get to know what it is all about, and familiarize yourself with the practical side. Basically, if you're a complete Linux newbie and looking for a quick and easy guide to get you started this is it.
subscribe
Run Your Own Web Server Using Linux & Apache - Free 191 Page Preview
Learn about everything you'll need to build and maintain your Linux servers, and to deploy Web applications to them.
subscribe
Open Source Security Myths Dispelled
Dispel the five major myths surrounding Open Source Security and gain the tools necessary to make a truly informed decision for your IT organization
subscribe
InformationWeek
InformationWeek is the only newsweekly you'll need to stay on top of the latest developments in information technology.
subscribe



All times are GMT. The time now is 03:18 AM.






© 2000 - - All Rights Reserved - Property of  MAS Media

Content Relevant URLs by vBSEO 3.3.1