清风幕竹 2016-08-12 06:10 采纳率: 0%
浏览 3042

c++builder编译时出现以下错误,怎么解决?

c++builder编译时出现以下错误,怎么解决?做一个读取USB设备数据的程序,刚刚接触,不了解,希望神人解答,多谢!!
//函数功能:枚举USB设备
int USBAsp_enum(void)
{
struct usb_bus *bus;
struct usb_device *dev = 0;
g_num = 0;
usb_init();
usb_find_busses();
usb_find_devices();
for(bus=usb_get_busses());
bus;
bus=bus->next)
{
for(dev=bus->devices; dev; dev=dev->next)
{
if((dev->descriptor.idVendor == USBDEV_VENDOR) && (dev->descriptor.idProduct == USBDEV_PRODUCT))
{
if (g_num < DEVICE_MINOR)
{
g_list[g_num].udev = dev; //int i=dev->config->bNumInterfaces;
g_num ++;
}
}
}
}
return g_num;
}
//函数功能:打开USB

bool USBAsp_open(void)
{
struct usb_bus *bus;
struct usb_device *dev = 0;
if(usbhandle!=NULL)
{
usb_close(usbhandle);
usbhandle=NULL;
}
usb_init();
usb_find_busses();
usb_find_devices();
for(bus=usb_get_busses();
bus;
bus=bus->next)
{
for(dev=bus->devices; dev; dev=dev->next)
{
if((dev->descriptor.idVendor == USBDEV_VENDOR) && (dev->descriptor.idProduct == USBDEV_PRODUCT))
break;
}
if(dev)
break;
}
if(!dev)
{
usbhandle=NULL;
return false;
}
usbhandle = usb_open(dev);
if(!usbhandle)
{
ShowMessage("不能打开USB!");
usbhandle=NULL;
return false;
}
usb_set_configuration(usbhandle, 1); //写数据前的初始化
usb_claim_interface(usbhandle, 0);
InitializeCriticalSection(&m_CommunicationSyn);
UsbRead = new Usb_Port(false); //挂起线程
IsRun=true;
return true;
}
//函数功能:向USB写入数据
void __fastcall USBAsp_Write(unsigned char chStr[], unsigned int StrLen)
{ if(usbhandle)
{
usb_bulk_write(usbhandle,EP_Out,chStr,StrLen,150);
}
}//开个线程 读取数据
int RecvLength=usb_bulk_read(usbhandle,EP_In,RxBuff,2048,150);

出现以下错误

[C++ Error] Unit1.cpp(7): E2451 Undefined symbol 'g_num'
[C++ Error] Unit1.cpp(8): E2268 Call to undefined function 'usb_init'
[C++ Error] Unit1.cpp(9): E2268 Call to undefined function 'usb_find_busses'
[C++ Error] Unit1.cpp(10): E2268 Call to undefined function 'usb_find_devices'
[C++ Error] Unit1.cpp(11): E2268 Call to undefined function 'usb_get_busses'
[C++ Error] Unit1.cpp(11): E2034 Cannot convert 'int' to 'usb_bus *'
[C++ Error] Unit1.cpp(11): E2378 For statement missing ;
[C++ Error] Unit1.cpp(13): E2315 'next' is not a member of 'usb_bus', because the type is not yet defined
[C++ Error] Unit1.cpp(13): E2379 Statement missing ;
[C++ Warning] Unit1.cpp(28): W8070 Function should return a value
[C++ Warning] Unit1.cpp(28): W8004 'dev' is assigned a value that is never used
[C++ Error] Unit1.cpp(35): E2451 Undefined symbol 'usbhandle'
[C++ Error] Unit1.cpp(35): E2451 Undefined symbol 'NULL'
[C++ Error] Unit1.cpp(37): E2268 Call to undefined function 'usb_close'
[C++ Error] Unit1.cpp(40): E2268 Call to undefined function 'usb_init'
[C++ Error] Unit1.cpp(41): E2268 Call to undefined function 'usb_find_busses'
[C++ Error] Unit1.cpp(42): E2268 Call to undefined function 'usb_find_devices'
[C++ Error] Unit1.cpp(43): E2268 Call to undefined function 'usb_get_busses'
[C++ Error] Unit1.cpp(45): E2315 'next' is not a member of 'usb_bus', because the type is not yet defined
[C++ Error] Unit1.cpp(47): E2315 'devices' is not a member of 'usb_bus', because the type is not yet defined
[C++ Error] Unit1.cpp(47): E2315 'next' is not a member of 'usb_device', because the type is not yet defined
[C++ Error] Unit1.cpp(49): E2315 'descriptor' is not a member of 'usb_device', because the type is not yet defined
[C++ Error] Unit1.cpp(49): E2451 Undefined symbol 'USBDEV_VENDOR'
[C++ Error] Unit1.cpp(49): E2315 'descriptor' is not a member of 'usb_device', because the type is not yet defined
[C++ Error] Unit1.cpp(49): E2451 Undefined symbol 'USBDEV_PRODUCT'
[C++ Error] Unit1.cpp(60): E2268 Call to undefined function 'usb_open'
[C++ Error] Unit1.cpp(63): E2268 Call to undefined function 'ShowMessage'
[C++ Error] Unit1.cpp(63): E2228 Too many error or warning messages

  • 写回答

2条回答 默认 最新

  • threenewbee 2016-08-12 15:35
    关注

    g_num在哪里定义的,是不是缺少头文件?

    评论

报告相同问题?

悬赏问题

  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 有没有帮写代码做实验仿真的
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥30 vmware exsi重置后登不上
  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?