Peter,
Thank you for your assistance!
I followed your recommendation and went ahead and upgraded libusb to the latest version. I am now able to compile and link against libusb. Yay!
I do have a few follow up questions …
I created a libusb-1.0.9.tar.bz2.md5 file since I didn’t see one on the download page. This got rid of the LTIB warning.
I created a libusb.spec.patch file containing the contents of the libusb.spec patch text you provided in the dist/lfs-5.1/libusb directory. I saved a copy of the existing libusb.spec file as libusb.spec.0.1.8
and then applied the patch. I was wondering if all of that was necessary? I could have just edited the libusb.spec directly, or just applied the patch and discarded the libusb.spec.patch file. Is there a ‘proper’ way to do this kind of thing? I’d rather do
things right the first time.
Here is the (copied from helloworld) contents of the usbtest Makefile:
CXXFLAGS = -I../rootfs/usr/include -Wall
LDFLAGS = -L../rootfs/usr/lib -lusb-1.0
progs = usbtest
prefix = /usr/local
DESTDIR =
ifdef SYSROOT
CXXFLAGS += -I$(SYSROOT)/$(prefix)/include
LDFLAGS += -L$(SYSROOT)/$(prefix)/lib
endif
all : $(progs)
install : $(DESTDIR)/$(prefix)/bin
cp -a $(progs) $(DESTDIR)/$(prefix)/bin/
distclean clean :
rm -f $(progs)
$(DESTDIR)/$(prefix)/bin:
mkdir -p $@
I was wondering if this was the proper way to set things up in the Makefile? It seems ‘odd’ to be including/linking with files in rootfs/usr/xxx. It seems like the libusb files should be where the rest of the
headers and libs are. That said, the ifdef SYSROOT block looks like it would accomplish the same result with a change to prefix from /usr/local to just /usr. Is that what I should be using in this case? Again, just looking to do things right the first time.
Many, many thanks for the help.
Regards,
Dale
From: Peter Barada [mailto:address@hidden
Sent: Thursday, March 28, 2013 5:49 PM
To: address@hidden; Chermak, Dale
Subject: Re: [Ltib] Troubles Adding libusb(x)
On 03/28/2013 06:13 PM, Chermak, Dale wrote:
Greetings.
Full disclosure: I am new to using LTIB and not an expert developing for Linux having done primarily Windows development over the years.
I have a DM3730 Torpedo + Wireless SOM from LogicPD that uses LTIB. I have managed to get the Ubuntu 10.04 LTS development environment setup, build a custom target image and add my own hellotorpedo-1.0 package to the image. All good so
far. Now I am trying to get to work on the actual project which involves communicating with a USB device. Years ago, some summer interns wrote an application for the OLPC that used libusb to communicate with a similar USB device. I figured I would just use
libusb for this current project, leveraging whatever code I could salvage from the OLPC project. I created a simple project, usbtest, to get started. Launching make from the LTIB shell resulted in the following (first) error:
usbtest.cpp:3:20: error: libusb.h: No such file or directory
Sure enough, a not even a find / -iname ‘libusb.h’ got any hits. Firing up ./ltib -c I noticed that the libusb package has --- instead of [ ] or [ * ], so no way for me to add or remove it I guess?
Searching around I discovered some posts on the Ubuntu forums that mentioned doing an apt-get for libusb-1.0-X-dev instead of libusb-dev to use libusb for development, which I guess is another way of getting the headers. So perhaps the
libusb package does not include the headers? It also appears to be the ‘old’ version which does not support asynchronous I/O.
At this point, I have gone ahead and downloaded the libusbx (a supposedly more active fork of libusb) tarball. It has what I guess is a fairly standard ./configure, make and make install workflow. I ran ./configure --host=arm-linux and
that seemed to work. I ran make, and things compiled and linked successfully. But I am not sure what to do next. Running make install does what I suspected and tries to install things in Ubuntu, but I want it installed in my LTIB environment so I can have
the shared archive pulled into target image and be able to compile and link my usbtest project against it. I took a look at the libusb.spec and I suspect using a libusbx.spec file is the proper way to do this, but I am not sure what all the steps are, particularly
getting the headers and shared archive available for the usbtest project. How should I proceed?
Sorry for the lengthy description but I wanted to make sure I had enough detail.
Dale, the "---" indicates that libusb is already incorporated in your build from LTIB (its selected by "PKG_USBTILS && CAP_HAS_MMU" which are both enabled for the LogicPD
OMAP35x/DM37x platform).
Digging into the generated rootfs, there's no libusb.h installed by version 0.1.8 distributed as part of LTIB. I think (but don't know if) you might have better luck upgrading the libusb package to the latest version rather than trying to install libusbx instead.
If you download
http://sourceforge.net/projects/libusb/files/libusb-1.0/libusb-1.0.9/libusb-1.0.9.tar.bz2 and copy it to /opt/ltib/pkgs, and modify your dist/lfs-5.1/libusb/libusb.spec with the following patch:
Index: libusb.spec
===================================================================
--- libusb.spec (revision 33943)
+++ libusb.spec (working copy)
@@ -2,13 +2,13 @@
Summary : A library which allows userspace access to USB devices
Name : libusb
-Version : 0.1.8
+Version : 1.0.9
Release : 1
License : LGPL
Vendor : Freescale
Packager : Stuart Hughes
Group : System Environment/Libraries
-Source : %{name}-%{version}.tar.gz
+Source : %{name}-%{version}.tar.bz2
BuildRoot : %{_tmppath}/%{name}
Prefix : %{pfx}
@@ -17,7 +17,7 @@
%Prep
%setup
-libtoolize --copy --force
+# libtoolize --copy --force
%Build
# note: I tried version 0.1.10a buy this requires a c++ compiler
Then "./ltib -p libusb" _should_ install into your rootfs "rootfs/usr/include/libusb-1.0/libusb.h" that you could include in your application. This version of libusb installs:
address@hidden:~/work/logic/eps_svn/software/products/linux/LTIB/trunk/ltib-3.0$ rpm2cpio < rpm/RPMS/arm/libusb-1.0.9-1.arm.rpm
| cpio -t
./opt/freescale/rootfs/arm/usr
./opt/freescale/rootfs/arm/usr/include
./opt/freescale/rootfs/arm/usr/include/libusb-1.0
./opt/freescale/rootfs/arm/usr/include/libusb-1.0/libusb.h
./opt/freescale/rootfs/arm/usr/lib
./opt/freescale/rootfs/arm/usr/lib/libusb-1.0.a
./opt/freescale/rootfs/arm/usr/lib/libusb-1.0.so
./opt/freescale/rootfs/arm/usr/lib/libusb-1.0.so.0
./opt/freescale/rootfs/arm/usr/lib/libusb-1.0.so.0.1.0
./opt/freescale/rootfs/arm/usr/lib/pkgconfig
./opt/freescale/rootfs/arm/usr/lib/pkgconfig/libusb-1.0.pc
893 blocks
where "./opt/freescale/rootfs/arm/" is removed from the path when the RPM is ultimately installed - the rest is relative to the LTIB rootfs/ directory where all the packages are installed and the rootfs/ directory is what is used to populate your rootfs that
you load onto the target.
Note that I've only complied tested this, not run it on actual hardware so your "results may vary". Hope this helps - keep the list posted on your progress.
--
Peter Barada
address@hidden