Dev-cpp

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Post Reply
yariash

Dev-cpp

Post by yariash » Sat Dec 04, 2010 8:26 pm

Is this possible to make a c++ project with libusb?

When I compile hiddata commandline as single file (hidtool.c) I link libraries libsetupapi.a and libhid.a and it compliles without any problem.
But when I create a empty project and add hidtool.c to it, it seems that it cant find these libraries because some linker errors happen. I was trying to link them either by Tools -> Compiler Options ->Add these commands to linker command line or by Project Options->Additional Command Line Options but it doesnt work.

Is there any solution to that problem?

Code: Select all

Objects/MingW/hiddata.o(.text+0x86):hiddata.c: undefined reference to `_Z15HidD_GetHidGuidP5_GUID@4'
Objects/MingW/hiddata.o(.text+0x20c):hiddata.c: undefined reference to `_Z18HidD_GetAttributesPvP15HIDD_ATTRIBUTES@8'
Objects/MingW/hiddata.o(.text+0x261):hiddata.c: undefined reference to `_Z26HidD_GetManufacturerStringPvS_m@12'
Objects/MingW/hiddata.o(.text+0x2b7):hiddata.c: undefined reference to `_Z21HidD_GetProductStringPvS_m@12'
Objects/MingW/hiddata.o(.text+0x369):hiddata.c: undefined reference to `_Z15HidD_SetFeaturePvS_m@12'
Objects/MingW/hiddata.o(.text+0x3b7):hiddata.c: undefined reference to `_Z15HidD_GetFeaturePvS_m@12'

maxi
Rank 3
Rank 3
Posts: 122
Joined: Fri Jul 24, 2009 6:13 pm

Re: Dev-cpp

Post by maxi » Sun Dec 05, 2010 5:25 pm

yariash wrote:Is this possible to make a c++ project with libusb?


I have done so with MSVC++ like this

Code: Select all

extern "C"
{
#include "opendevice.h"
}

usb_dev_handle *m_Handle = NULL;

Where opendevice.h & .c are taken directly from the v-usb custom class example. The device is initialized like so

Code: Select all

   static char vendor[]  = "Usb Vendor Name";
   static char product[] = "Usb Device Name";
   usb_init();
   m_Init = ( usbOpenDevice( &m_Handle,
      USB_VENDOR_ID, vendor,
      USB_DEVICE_ID, product,
      NULL, NULL, NULL ) == 0 );


It's been a while since I did this so I may have missed something but hopefully you get the idea.

Post Reply