Solved

how to include own C file in kernel source 2.4 ?

Posted on 2004-03-24
3
187 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
The viewer will learn how to count occurrences of each item in an array.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

752 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