• (2 Pages)
  • +
  • 1
  • 2

Introduction to using LibUSB-1.0 Rate Topic: ****- 2 Votes

#16 Guest_subeer*


Reputation:

Posted 14 February 2011 - 07:24 AM

i tried specifying library in the command line code as in
g++ -Wall -W -I/home/user/libusb info.cpp -o info

even in the #include i specified the path of the library (libusb.h)
still i am getting the errors as 'undefined reference to libusb_init '...and so on for almost all the functions
While running the program you gave as an example in the main post (the very first one)
Was This Post Helpful? 0

#17 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6091
  • View blog
  • Posts: 23,606
  • Joined: 23-August 08

Posted 14 February 2011 - 09:08 AM

Did you miss post #6???
Was This Post Helpful? 0
  • +
  • -

#18 Guest_subeer*


Reputation:

Posted 17 February 2011 - 03:08 AM

View PostJackOfAllTrades, on 14 February 2011 - 09:08 AM, said:

Did you miss post #6???

Thanks finally i got it running.It worked also i had to clearly define the library path.
Was This Post Helpful? 0

#19 henaoelkin  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 16-May 12

Posted 16 May 2012 - 11:54 AM

Hi

I'm using your examples in DEV C++ and I get linker errors like this:



[Linker error] undefined reference to `libusb_set_debug@8' 


can you help me to use the library correctly?

Thanks
Was This Post Helpful? 0
  • +
  • -

#20 arr_baobao  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 28-June 12

Posted 28 June 2012 - 06:31 PM

can anyone please helps me to link the libusb to my project in visual studio? i can't link it.
thanks
Was This Post Helpful? 0
  • +
  • -

#21 stubbz  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 12-July 12

Posted 12 July 2012 - 11:39 AM

I was wondering if you could perhaps go into some detail as to how an isoch transfer would be structured. It seems difficult to find anything libusb specific, meaning that I will need to understand usb protocol much more in order to know what needs to be done.
Was This Post Helpful? 0
  • +
  • -

#22 TantrumTantra  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 11-May 12

Posted 15 July 2012 - 09:41 PM

Hi,
Great Article. But after I compile and link it and run the program it seems to be stuck at writing data? Any ideas why. The device is a 2gb pendrive.Anything I am doing wrong. Alos what device did you use?
Was This Post Helpful? 0
  • +
  • -

#23 Anarion  Icon User is offline

  • The Persian Coder
  • member icon

Reputation: 287
  • View blog
  • Posts: 1,467
  • Joined: 16-May 09

Posted 21 July 2012 - 02:03 PM

View Posthenaoelkin, on 16 May 2012 - 11:24 PM, said:

Hi

I'm using your examples in DEV C++ and I get linker errors like this:



[Linker error] undefined reference to `libusb_set_debug@8' 


can you help me to use the library correctly?

Thanks

Well, first things first. This does not solve the error but you should use a more up-to-date environment. DEV C++ uses a very old version of MinGW. When the compiler is old, it doesn't support the current language standards well and problems begin to rise here and there.
A Linker error is caused when your compiled application is not linked with the library correctly, so it can't find the definitions although it has access to declarations and other stuff of the header file included. You have to setup the library path in your compiler/IDE. I can't tell you where to set it exactly I'm afraid, because I use a linux environment :mellow:
Was This Post Helpful? 0
  • +
  • -

#24 Anarion  Icon User is offline

  • The Persian Coder
  • member icon

Reputation: 287
  • View blog
  • Posts: 1,467
  • Joined: 16-May 09

Posted 21 July 2012 - 02:09 PM

View Postarr_baobao, on 29 June 2012 - 06:01 AM, said:

can anyone please helps me to link the libusb to my project in visual studio? i can't link it.
thanks

I don't have Visual Studio currently on my system, but I searched on google and it seems you can link by going to "Project properties -> Configuration properties -> Linker".
Was This Post Helpful? 0
  • +
  • -

#25 Anarion  Icon User is offline

  • The Persian Coder
  • member icon

Reputation: 287
  • View blog
  • Posts: 1,467
  • Joined: 16-May 09

Posted 21 July 2012 - 02:16 PM

View Poststubbz, on 12 July 2012 - 11:09 PM, said:

I was wondering if you could perhaps go into some detail as to how an isoch transfer would be structured. It seems difficult to find anything libusb specific, meaning that I will need to understand usb protocol much more in order to know what needs to be done.

Well, things are a bit harsh with Libusb, there are not some well articles describing how to use it or a tutorial (at least I couldn't find at the time of writing this article). All I found was 2 or 3 source code files and I learned from them.

But, good news is, there is a fork for Libusb, named Libusbx. This works nicer on Windows OS as I read on it's website. There are a couple more project as well for these kind of stuff. I will try to see how things go with that library and I should be writing a new tutorial by the next 2 months.

Here's the project's homepage: Libusbx

This post has been edited by Anarion: 22 July 2012 - 02:06 PM

Was This Post Helpful? 0
  • +
  • -

#26 Anarion  Icon User is offline

  • The Persian Coder
  • member icon

Reputation: 287
  • View blog
  • Posts: 1,467
  • Joined: 16-May 09

Posted 21 July 2012 - 02:23 PM

View PostTantrumTantra, on 16 July 2012 - 09:11 AM, said:

Hi,
Great Article. But after I compile and link it and run the program it seems to be stuck at writing data? Any ideas why. The device is a 2gb pendrive.Anything I am doing wrong. Alos what device did you use?

You can't just read data from a stream and send them to your USB pendrive. Because you have to send this data in a way that your pendrive unserstands. The data I sent to my pendrive in the example was useless and it only meant to show as an example.

You should check this out: Libusb FAQ. This explains exactly what you are after ;)
Was This Post Helpful? 0
  • +
  • -

#27 sh4rif  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 25-February 13

Posted 25 February 2013 - 12:20 PM

Hello Sir,

I am running Ubuntu 12.04 and I tried the above code but unfortunatly that doest not work. it displays an error message which says the followin

[code]
8 Device in list
Cannot open device
Segmentation fault (core dumped)
[code]

how can i solve the problem please help

thanks
Usman
Was This Post Helpful? 0
  • +
  • -

#28 LeonardoSaud  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 03-April 13

Posted 03 April 2013 - 10:32 AM

Hello!

I tried running your code in my Fedora 14, but the follow error message appeared:

Quote

10 Devices in list.
libusb couldn't open USB device /dev/bus/usb/002/003: Permission denied.
libusb requires write access to USB device nodes.

Cannot open device
Segmentation fault (core dumped)

To resolve the problem in bold, I followed those steps:

Quote

1. Got the access error on /dev/bus/usb/002/009

2. Look at the device vendor and product id (I use sudo, you could just become root):

$ sudo udevadm -a -n /dev/bus/usb/002/009

Mine says SUBSYSTEM=="usb", ATTR{idVendor}=="0abc" and ATTR{idProduct}=="0001"

3. Create a file in /etc/udev/rules.d containing:

SUBSYSTEM=="usb", ACTION=="add", ATTR{idVendor}=="0abc", ATTR{idProduct}=="0001", GROUP="usb"

Make sure the rule is well written, udev is _very_ picky.

4. Reload the udev rules (not sure if that is necessary but that cannot hurt):

$ sudo udevadm control --reload-rules

5. Place yourself in the usb group:

$ sudo usermod -a -G usb yourusername

6. Confirm:

$ greb usb /etc/group

Not sure if you need to logout and back in for this to take effect.

7. Plug your device and enjoy.

Of course, you could create a special group, say usbscanner and use this instead of the generic usb.

Hope that helps, any correction is welcome.

Link: http://forum.mandriv...ic.php?t=120634

But, when I do the step 5, the following error appears:

Quote

# sudo usermod -g usb engenharia
usermod: group 'usb' doesn't exists.

Coud you help me resolve this problem? Should I create a usb group or is there another group which I could use?
Was This Post Helpful? 0
  • +
  • -

#29 LeonardoSaud  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 03-April 13

Posted 03 April 2013 - 12:10 PM

Forget my last post. I connected like root and resolved the problem. How can I see the data written in a pendrive, for example?
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2