libusb-1.0 with STLinux (sh4 platform)

August 11, 2009

[Warning: This post is a backup recovery from my previous Wordpress blog. All content was automatically converted accessing a MySQL database using a Python script (details). Mostly are in Portuguese but if you are interest I can translate to English. If you found any problem dont’t hesitate to contact me in comments.]

STLinux Distribution comes with libusb-0.1 to access USB interface in user-space, it works but the new version implements new features (i.e asynchronous interface). Note that libusb-1.0 is not backwards compatible with libusb-0.1 although you can have both libusb versions present on the same system without conflict.

Select one mirror near to you and set your cross compiler to produce an object SH4-compatible. I'm using some building guidelines to organize my files.

  CC=sh4-linux-gcc ./configure --host=sh4-linux --prefix=$(cd ../install && pwd)
  make
  make install

I prefer use a different folder to especific libs so I've copied the contents of install/ to target rootfs directory

  • Headers (libusb.h and libusbi.h) in /usr/local/include
  • Shared libs (libusb-1.0.so.0.0.0) in /usr/local/lib/

And made a symbolic link to system lib folder.

  ln -s /usr/local/lib/libusb-1.0.so.0.0.0 /usr/lib/libusb-1.0.so.0

Finally, check some code using new library. My test code was lsusb.c from examples/ in libusb-1.0.2 directory.

  sh4-linux-gcc lsusb.c -o lsusb -lusb-1.0