码迷,mamicode.com
首页 > 其他好文 > 详细

cross compile the libusb and examples

时间:2014-12-02 19:21:57      阅读:339      评论:0      收藏:0      [点我收藏+]

标签:linux libusb arm

[Author: Bo Shen <voice.shen@gmail.com>]


Assume you have the cross toolchain installed on your Linux host, here I use ubuntu 12.04 with arm-linux-gnueabihf-gcc installed. (if not, here is the command)

--->8---

For the SoC support hard float point

$ sudo apt-get install gcc-arm-linux-gnueabihf

For the SoC only support soft float point

$ sudo apt-get install gcc-arm-linux-gnueabihf

---8<---

Then set the environment

--->8---

$ export ARCH=arm

$ export CROSS_COMPILE=arm-linux-gnueabi-

---8<---


The following steps are real to build the libusb.


1. Get the source code

    $ git clone git://git.libusb.org/libusb.git


2. configure the source

2.1 Edit the autogen.sh file, remove following lines

--->8---

./configure --enable-maintainer-mode --enable-debug-log \
       --enable-examples-build "$@"

---8<---

2.2 Then run the autogen.sh script

$ ./autogen.sh

2.3 Configure the libusb

$ ./configure --host=arm-linux-gnueabihf- --prefix=/tmp/_install --enable-examples-build

NOTE: the --enable-examples-build is used to generate the Makefile.

2.4 Make

$ make


3. Build the examples

$ cd examples

$ arm-linux-gnueabihf-gcc -I/tmp/_install/include/libusb-1.0 -L/tmp/_install/lib/ -lusb-1.0 -o listdevs listdevs.c

If you meet the error: "can not find the libusb.h", please edit the listdevs.c, change the following lines:

from #include <libusb.h> to #include "libusb.h"

cross compile the libusb and examples

标签:linux libusb arm

原文地址:http://blog.csdn.net/voice_shen/article/details/41681299

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!