Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Re: using libusb

Reply
Thread Tools

Re: using libusb

 
 
James Kuyper
Guest
Posts: n/a
 
      08-21-2012
On 08/21/2012 03:44 PM, mahnaz0098 wrote:
> Hello
> I need to communicate with USB port by C. I found a comppresd (.rar) file. Its name is libusb-win32-bin-1.2.6.0. I extracted it and it contains several files and folders.one header file(lusb0_usb) and some example programs to communicate via USB .
> I added lusb0_usb.h to this program (right click on Header Files in solution explorer and choose add > existing item then browse lusb0_usb.h),
> (#include <lusb0_usb.h> ). I can't debug this example program. Do I need to do another action to add this new library (lusb0_usb.h) to use in this program?
> i use visual C++ and it shows me this error:
>
> Error 1 fatal error C1083: Cannot open include file: 'lusb0_usb.h': No such file or directory c:\users\...\usb\usb.c


Your question is primarily about a particular library, and should be
directed to someone who knows something about that particular library.

However, some aspects of your question are purely C related, and I can
address those:

The thing that's brought into your code by using #include is called a
header file, not a library file. The fact that the compiler can't open
that file has nothing to do with the library. When your code gets
linked, you will have to tell the compiler the correct location where it
can find the corresponding library file, but this compilation has failed
before that question has even come up.

There's a list of locations that the compiler is supposed to search when
you use

#include <lusb0_usb.h>

That list of locations can, in principle, be quite different for each
implementation of C, but it always includes whatever location the
standard headers are stored in (even if they're not stored in a
directory). That's why you should use #include <> for standard headers.
For the particular compiler you're using, the default list of locations
apparently does not include whichever directory you've currently got
lusb0_usb.h in.

If you were to use

#include "lusb0_usb.h"

there might or might not be a different list of locations your compiler
will search for the file - that's up to your compiler. However, it's
fairly commonplace for the list to include the current directory, or the
same directory that the source code file was located in. However, if it
can't find the file in one of those locations, it will then search the
same locations it would have searched if you had written #include
<lusb0_usb.h>. Because it might cause your compiler to search additional
locations, you should generally use #include "" for headers that are not
part of the C standard.

If changing from #include <> to #include "" doesn't solve your problem,
I'd recommend reading solution explorer's documentation to find out what
locations are searched by default, and how you can control which
locations get searched. In my development environment, it's controlled
by -I command line options passed to the compiler, but you're working in
a very different environment, so the correct way to do it might be quite
different.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: using libusb Johann Klammer C Programming 0 08-21-2012 08:14 PM
libusb, use Device::USB; works only as user root? georg.heiss@gmx.de Perl Misc 0 10-11-2009 09:54 AM
no code in webform using vs.net, but in webform using notepad timmso ASP .Net 1 12-12-2003 04:30 PM
Using GetOleDbSchemaTable to get SQL Server Field Description - using pete ASP .Net 1 08-29-2003 10:50 AM
Re: MVP? Index error on nested element using System.xml but NOT using msxml??? William F. Robertson, Jr. ASP .Net 1 06-25-2003 08:08 PM



Advertisments