Solved

how to include own C file in kernel source 2.4 ?

Posted on 2004-03-24
3
188 Views
Last Modified: 2013-11-18
i am writing a function that is stored in another C file and want to include it in kernel file in net directory. what should i do?
Is that require me to insert a include that C file if not then Is that require me to define that function prototype in that file in which i am includeing?
the problem is that i include it in a kernel file but it gives error while compiling kernel net/network.o(.text+0x1d40a): undefined reference to `fun' where fun is the function that is written in my own C file that i include in kernel source.
0
Comment
Question by:pancoder
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 12

Expert Comment

by:stefan73
ID: 10675600
Hi pancoder,
Check the include files for the net part of the kernel. There is for sure some "master include file" which is used by all .c sources. Modify this, include your own header file from there.

Cheers,

Stefan
0
 
LVL 44

Accepted Solution

by:
Karl Heinz Kremer earned 50 total points
ID: 10682870
You need two things in order to add your own function to any program: A header file and an implementation file. If you duplicate the declaration of your function(s), you can get by without the header file. In your case, the problem shows up during the link phase, which means that you don't heave any problems with header files or declarations. You need to add your object file (the Makefile will know how to create the object file from your source file) to the list of files that get linked into network.o
On order to do this, add your file.o to the definition of obj-y in the Makefile in the network directory.
0
 

Expert Comment

by:namus
ID: 10694965
you need to modify the make file of the directory in which ur placing ur C code file. then include the header in that source file. then u need to compile the kernel. So that the code becomes part of the kernel code.
to compile the kernel... follow the simple steps mentioned at http://www.freeos.com/articles/2589/    (though ther r many places u can find it... its jus a reference i found out of a quick search).
0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
Suggested Courses

622 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question