On Sun, Feb 27, 2005 at 11:36:40AM -0800, cfk wrote: > This is a linux programming question and not exactly a gnuradio question, but > please bear with me a bit as it is filling out a hole in my understanding. > > I am trying to bridge the gap in my understanding in programming in > userspace, > and I'll use usb as an example by expressing what I know and asking for help > in understanding what I dont know. > > I am looking at the program usrp_prims.cc and trying to understand the usb > includes. It #includes usb.h which I can find in /usr/include. I can go > to /usr/lib and find libusb.a which I can run ar and nm on. > > Ar tells me this library contains usb.o (amongst other things), and nm tells > me this library contains usb_find_busses (amongst other things). > > So, I go looking for usb.c using 'find / -iname usb.c' and find three > usb.c's, > all in the kernel source for FC (/usr/src/linux-2.6.10-1.14_FC2_arch). > > None of these usb.c files contain the userspace stuff I am looking for. They > all contain the kernelspace side of the usb stack. > > So, where do I go to find the appropriate C source code for a library > in /usr/lib that is included by an include from /usr/include in Fedora Core?
Hi Charles, All good questions. libusb.a and usb.h are parts of the libusb package (http://libusb.sourceforge.net). Under RPM based systems like Fedora or Mandrake you can find out which package installed a particular file (assuming it came from an RPM) using: $ rpm -qf /usr/include/usb.h libusb0.1_4-devel-0.1.8-2mdk This says that /usr/include/usb.h was installed by libusb0.1_4-devel-0.1.8-2mdk package. (This was on a Mandrake 10.1 system. Your specific answer will vary.) By default the source packages of most RPM's are not installed. You can install them either off the net or off your distribution CDs. The specifics vary, but you'll be looking for a "Source RPM" that will be named "libusb0.1_4-devel-0.1.8-2mdk.src.rpm" or something close. Once you find and download the source RPM install it: # rpm -Uhv libusb0.1_4-devel-0.1.8-2mdk.src.rpm This will install the source files, build instructions, patches, etc that compose the RPM under something like /usr/src/RPM (the exact path might be different on FC3). If you go to the SPECS directory under /usr/src/RPM you should find a file named something like libusb.spec. If you cd into the SPECS directory and running as root execute: # rpm -bp libusb.spec This executes the "prep" stage of the rpm build process. This will unpack the source tarballs and apply all patches. The resuling patched code ends up in /usr/src/RPM/BUILD/libusb-x.y.z At this point you have the exact source code that went into the binary rpm. Of course if the file in question didn't come from an RPM, you probably built and installed it locally and have the source sitting around somewhere. You can also get the source from the "upstream" source, in this case libusb.sourceforge.net. If yours came from an RPM you're better off with the steps above, since you'll get exactly the code that went into making the binary RPM. The rpm -qi <package> command will usually give you the location of the upstream source. E.g., $ rpm -qi libusb0.1_4-devel-0.1.8-2mdk Name : libusb0.1_4-devel Relocations: (not relocatable) Version : 0.1.8 Vendor: Mandrakesoft Release : 2mdk Build Date: Thu 15 Jul 2004 12:34:54 PM PDT Install Date: Wed 22 Dec 2004 12:59:35 PM PST Build Host: n4.mandrakesoft.com Group : Development/C Source RPM: libusb-0.1.8-2mdk.src.rpm Size : 138975 License: LGPL Signature : DSA/SHA1, Tue 05 Oct 2004 08:56:13 AM PDT, Key ID e7898ae070771ff3 Packager : Christiaan Welvaart <[EMAIL PROTECTED]> URL : http://libusb.sf.net/ Summary : Libusb is a library which allows userspace access to USB devices Description : This package includes the header files and shared libraries necessary for developing programs which will access USB devices using the libusb library. If you are going to develop programs which will access USB devices, you should install this package. Eric _______________________________________________ Discuss-gnuradio mailing list [email protected] http://lists.gnu.org/mailman/listinfo/discuss-gnuradio
