• «
  • 1
  • 2
  • »
  • Pages: 2/2     Go
主题 : 交叉编译提示找不到usb.h 复制链接 | 浏览器收藏 | 打印
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
10楼  发表于: 2009-08-21 14:26
把-l /home/libusb-arm/usr/local/include/usb.h
换成
-l /home/libusb-arm/usr/local/include

-I 后面跟的是目录名,表示把该目录加入到编译器搜索头文件的路径中
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."
级别: 新手上路
UID: 7382
精华: 0
发帖: 18
金钱: 180 两
威望: 115 点
综合积分: 36 分
注册时间: 2009-07-13
最后登录: 2010-03-12
11楼  发表于: 2009-08-21 15:55
版主帮帮忙
级别: 侠客
UID: 4545
精华: 3
发帖: 88
金钱: 810 两
威望: 614 点
综合积分: 236 分
注册时间: 2009-03-19
最后登录: 2020-06-17
12楼  发表于: 2009-08-21 16:14
还没编好吗?
按你的路径,你这样编译
arm-linux-gcc usb_modeswitch.c -o usb_modeswitch -I /home/libusb-arm/usr/local/include/ -L /home/libusb-arm/usr/lib/ -lusb
级别: 新手上路
UID: 7382
精华: 0
发帖: 18
金钱: 180 两
威望: 115 点
综合积分: 36 分
注册时间: 2009-07-13
最后登录: 2010-03-12
13楼  发表于: 2009-08-21 16:29
引用第12楼长风于2009-08-21 16:14发表的 :
还没编好吗?
按你的路径,你这样编译
arm-linux-gcc usb_modeswitch.c -o usb_modeswitch -I /home/libusb-arm/usr/local/include/ -L /home/libusb-arm/usr/lib/ -lusb

 
还是不行

[root@localhost usb_modeswitch-1.0.2]# ls
COPYING README usb_modeswitch.conf
Makefile usb_modeswitch.c usb_modeswitch.h

[root@localhost usb_modeswitch-1.0.2]# arm-linux-gcc usb_modeswitch.c -o usb_modeswitch -I /home/libusb-arm/usr/local/include/ -L /home/libusb-arm/usr/lib/ -lusb
/usr/local/arm/4.3.2/bin/../lib/gcc/arm-none-linux-gnueabi/4.3.2/../../../../arm-none-linux-gnueabi/bin/ld: cannot find -lusb
collect2: ld returned 1 exit status
 
 -lusb 换成-l usb结果相同
[ 此帖被yyh572103在2009-08-21 16:51重新编辑 ]
级别: 新手上路
UID: 7382
精华: 0
发帖: 18
金钱: 180 两
威望: 115 点
综合积分: 36 分
注册时间: 2009-07-13
最后登录: 2010-03-12
14楼  发表于: 2009-08-21 16:38
引用第10楼kasim于2009-08-21 14:26发表的 :
把-l /home/libusb-arm/usr/local/include/usb.h
换成
-l /home/libusb-arm/usr/local/include

-I 后面跟的是目录名,表示把该目录加入到编译器搜索头文件的路径中

 
也有错误
如下
[root@localhost usb_modeswitch-1.0.2]# arm-linux-gcc -I /home/libusb-arm/usr/local/include/ -o usb_modeswitch usb_modeswitch.c
/tmp/ccqlVYSx.o: In function `main':
usb_modeswitch.c:(.text+0x11b8): undefined reference to `usb_init'
usb_modeswitch.c:(.text+0x11d0): undefined reference to `usb_set_debug'
usb_modeswitch.c:(.text+0x11d4): undefined reference to `usb_find_busses'
usb_modeswitch.c:(.text+0x11d8): undefined reference to `usb_find_devices'
usb_modeswitch.c:(.text+0x1558): undefined reference to `usb_open'
usb_modeswitch.c:(.text+0x1a4c): undefined reference to `usb_close'
/tmp/ccqlVYSx.o: In function `deviceDescription':
usb_modeswitch.c:(.text+0x1c68): undefined reference to `usb_get_string_simple'
usb_modeswitch.c:(.text+0x1d38): undefined reference to `usb_get_string_simple'
usb_modeswitch.c:(.text+0x1e08): undefined reference to `usb_get_string_simple'
/tmp/ccqlVYSx.o: In function `deviceInquire':
usb_modeswitch.c:(.text+0x1f3c): undefined reference to `usb_claim_interface'
usb_modeswitch.c:(.text+0x1f98): undefined reference to `usb_bulk_write'
usb_modeswitch.c:(.text+0x1ffc): undefined reference to `usb_bulk_read'
usb_modeswitch.c:(.text+0x2058): undefined reference to `usb_bulk_read'
usb_modeswitch.c:(.text+0x2198): undefined reference to `usb_release_interface'
/tmp/ccqlVYSx.o: In function `resetUSB':
usb_modeswitch.c:(.text+0x2248): undefined reference to `usb_reset'
/tmp/ccqlVYSx.o: In function `switchSendMessage':
usb_modeswitch.c:(.text+0x23a8): undefined reference to `usb_claim_interface'
usb_modeswitch.c:(.text+0x24c8): undefined reference to `usb_clear_halt'
usb_modeswitch.c:(.text+0x24f8): undefined reference to `usb_release_interface'
/tmp/ccqlVYSx.o: In function `switchConfiguration':
usb_modeswitch.c:(.text+0x25ec): undefined reference to `usb_set_configuration'
/tmp/ccqlVYSx.o: In function `switchAltSetting':
usb_modeswitch.c:(.text+0x26c0): undefined reference to `usb_claim_interface'
usb_modeswitch.c:(.text+0x26e4): undefined reference to `usb_set_altinterface'
usb_modeswitch.c:(.text+0x2708): undefined reference to `usb_release_interface'
/tmp/ccqlVYSx.o: In function `switchHuaweiMode':
usb_modeswitch.c:(.text+0x27ec): undefined reference to `usb_control_msg'
/tmp/ccqlVYSx.o: In function `switchSierraMode':
usb_modeswitch.c:(.text+0x28c0): undefined reference to `usb_control_msg'
/tmp/ccqlVYSx.o: In function `switchSonyMode':
usb_modeswitch.c:(.text+0x29bc): undefined reference to `usb_control_msg'
usb_modeswitch.c:(.text+0x2a18): undefined reference to `usb_close'
usb_modeswitch.c:(.text+0x2a40): undefined reference to `usb_find_busses'
usb_modeswitch.c:(.text+0x2a44): undefined reference to `usb_find_devices'
usb_modeswitch.c:(.text+0x2b48): undefined reference to `usb_open'
usb_modeswitch.c:(.text+0x2c0c): undefined reference to `usb_control_msg'
/tmp/ccqlVYSx.o: In function `detachDriver':
usb_modeswitch.c:(.text+0x2d14): undefined reference to `usb_get_driver_np'
usb_modeswitch.c:(.text+0x2dd0): undefined reference to `usb_detach_kernel_driver_np'
/tmp/ccqlVYSx.o: In function `checkSuccess':
usb_modeswitch.c:(.text+0x2ebc): undefined reference to `usb_open'
usb_modeswitch.c:(.text+0x2ee4): undefined reference to `usb_claim_interface'
usb_modeswitch.c:(.text+0x2f48): undefined reference to `usb_release_interface'
usb_modeswitch.c:(.text+0x2f7c): undefined reference to `usb_find_devices'
/tmp/ccqlVYSx.o: In function `write_bulk':
usb_modeswitch.c:(.text+0x30c8): undefined reference to `usb_bulk_write'
/tmp/ccqlVYSx.o: In function `read_bulk':
usb_modeswitch.c:(.text+0x31a0): undefined reference to `usb_bulk_read'
usb_modeswitch.c:(.text+0x31cc): undefined reference to `usb_bulk_read'
/tmp/ccqlVYSx.o: In function `release_usb_device':
usb_modeswitch.c:(.text+0x32a8): undefined reference to `usb_release_interface'
usb_modeswitch.c:(.text+0x32b8): undefined reference to `usb_close'
/tmp/ccqlVYSx.o: In function `search_devices':
usb_modeswitch.c:(.text+0x3340): undefined reference to `usb_get_busses'
collect2: ld returned 1 exit status
是不是我libusb没编译好?
级别: 新手上路
UID: 7382
精华: 0
发帖: 18
金钱: 180 两
威望: 115 点
综合积分: 36 分
注册时间: 2009-07-13
最后登录: 2010-03-12
15楼  发表于: 2009-08-21 16:43
libusb结构如下

[root@localhost local]# pwd
/home/libusb-arm/usr/local
[root@localhost local]# ls
bin include lib
[root@localhost local]# ls bin/
libusb-config
[root@localhost local]# ls include/
usb.h usbpp.h
[root@localhost local]# ls lib/
libusb-0.1.so.4 libusb.la libusbpp.a libusb.so
libusb-0.1.so.4.4.4 libusbpp-0.1.so.4 libusbpp.la pkgconfig
libusb.a libusbpp-0.1.so.4.4.4 libusbpp.so

不知道有没什么不对的,我把/home/linusb_arm加到$PATH里了
[ 此帖被yyh572103在2009-08-21 16:50重新编辑 ]
级别: 侠客
UID: 4545
精华: 3
发帖: 88
金钱: 810 两
威望: 614 点
综合积分: 236 分
注册时间: 2009-03-19
最后登录: 2020-06-17
16楼  发表于: 2009-08-21 17:05
哦,不好意思,漏掉一个local
arm-linux-gcc usb_modeswitch.c -o usb_modeswitch -I /home/libusb-arm/usr/local/include/ -L /home/libusb-arm/usr/local/lib/ -lusb
级别: 新手上路
UID: 7382
精华: 0
发帖: 18
金钱: 180 两
威望: 115 点
综合积分: 36 分
注册时间: 2009-07-13
最后登录: 2010-03-12
17楼  发表于: 2009-08-22 13:36
成功了,谢谢你们
  • «
  • 1
  • 2
  • »
  • Pages: 2/2     Go