Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C Programming (http://www.velocityreviews.com/forums/f42-c-programming.html)
-   -   Re: using libusb (http://www.velocityreviews.com/forums/t951196-re-using-libusb.html)

James Kuyper 08-21-2012 08:13 PM

Re: using libusb
 
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.



All times are GMT. The time now is 12:07 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.