How to write Makefile for compiling simple pgm in rt patch 2.6.24.4
I have written a simple C pgm in RT patch 2.6.24.4 and compiling using gcc 4.1 but i am getting an error that
undefined reference to pci_find_device though i am including the header <linux/pci.h> My source code is: #include <stdio.h> > #include <linux/pci.h> > > static int vendorid=0x16a2; > static int deviceid=0x8139; > > int main(int argc , char *argv[]) > { > int i; > struct pci_dev *pdev = NULL; > > pdev = pci_find_device(vendorid,deviceid,pdev); > > return 0; > } > /tmp/cceUpWSo.o: In function `main': > /tmp/cceUpWSo.o(.text+0x1e): undefined reference to `pci_find_device' > collect2: ld returned 1 exit status i dont know why my header is not including so kindly any could tell me how to write simple makefile to compile my pgm. |
|
As smeezekittly points out, you're using a deprecated function.
From pci.h: Code:
#ifdef CONFIG_PCI_LEGACY Otherwise, I'm sure theres the "New Way" to do this, but I don't know what it is, I'm not an experienced kernel programmer. |
Hi -
A couple of points: 1. You're getting a *link* error (not a compile error). Your C compiler is finding "pci.h" just fine. But your "ld" linker isn't finding any library that contains a binary object for function "pci_find_device()". 2. If you're using "<stdio.h>" and you've got a "main()" ... then you're NOT doing kernel code. You've got a user-space program, which will refer to user-space headers and libraries. I frankly don't know if "pci_find_device()" can be called from a user space program. Or, if so, what library you might need to link in. SUGGESTION: It sounds like you want to query your PCI devices in your program. All of the information you could possibly want is available to you in the"/proc" filesystem. Why not just poke around "/proc" (from a command line). Then, when you find what you're looking for, it's trivial to parse through the same "/proc" files/directories in your program. IMHO .. PSM |
Quote:
|
Hi -
Actually, I kind of thought all my points were good :) ANOTHER SUGGESTION: The following two documents might help with what you're actually trying to accomplish: http://g2pc1.bu.edu/~qzpeng/manual/pcip.pdf http://www.xml.com/ldd/chapter/book/ch15.html <= Frankly, if you're going to get into kernel programming, I'd buy the book. The 3rd Edition of the book... 'Hope that helps .. PSM |
All times are GMT -5. The time now is 09:43 PM. |