I'm going to try to add 'Var' in the declaration of my procedure. myusb_open is a procedure and not a fonction I have do an error of cut and paste..
I have always use 'cdecl' to declare external function but I'm not a pascal expert. If you need more details to help me don't hesitate to ask me. I thanks you. I'm sorry,but what does 'cdecl' mean? in fact i know nothing about how to import functions from external compiled library. ? 2009-05-26?? 14:15 +0200?Mattias Gaertner??? > On Tue, 26 May 2009 13:58:14 +0200 > S?bastien FLOURETTE <[email protected]> wrote: > > > Hi, > > > > I need again help !! > > > > I have create a simple library in C compiled with GCC in mylibusb.o > > > > The code is : > > #include <usb.h> > > > > > > myusb_open(usb_dev_handle *udev) > > { > > struct usb_bus *bus; > > struct usb_device *dev; > > char buff[64]; > > int i; > > > > //Initialisation du bus USB > > usb_init(); > > usb_find_busses(); > > usb_find_devices(); > > > > for (bus = usb_busses; bus; bus = bus->next) > > { > > for (dev = bus->devices; dev; dev = dev->next) > > { > > if ((dev->descriptor.idVendor == 0x04D8) && > > (dev->descriptor.idProduct == 0x1985)) > > { > > udev = usb_open(dev); > > } > > > > } > > > > } > > } > > > > > > myusb_close(usb_dev_handle *udev) > > { > > usb_close(udev); > > } > > > > > > myusb_write(usb_dev_handle *udev) > > { > > usb_bulk_write(udev, 0x01, 0x01, 64, 1000); > > } > > > > > > I link this myusblib.o with my lazarus program : > > > > > > unit usb_api; > > > > > > > > interface > > > > > > function myusb_open(udev : thandle);cdecl; > > procedure myusb_close(udev : thandle) ; cdecl; > > procedure myusb_write(udev : thandle); cdecl; > > Maybe you forgot the 'var': > function myusb_open(var udev : thandle);cdecl; > ? > > I don't know your C macros (who knows?), but are you sure myusb_open is > a function (or maybe a procedure)? > > > > implementation > > > > {$link myusblib.o} > > {$linklib usb} > > {$linklib c} > > {$linklib gcc} > > > > > > uses CTypes; > > > > function myusb_open; cdecl; external; > > procedure myusb_close; cdecl; external; > > procedure myusb_write; cdecl; external; > > end. > > > > > > > > and when I do > > > > var > > myhost : thandle; > > > > begin > > myusb_open(myhost); > > myusb_write(myhost); > > myusb_close(myhost); > > end; > > > > I have no communication with my usb board. My libusb.o work with the > > same program in C. > > > > Have you got an idea on my problem or can you tell me if you have > > another solutions. > > > > Is it possible to create a library Dll for windows and MAC OS and How > > can I do it with the libusb library? > > > Mattias > > _______________________________________________ > Lazarus mailing list > [email protected] > http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
_______________________________________________ Lazarus mailing list [email protected] http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
