Recent

Author Topic: Import libusb0_x86.dll or any other .dll in lazarus  (Read 11879 times)

vladapvo

  • Newbie
  • Posts: 1
Import libusb0_x86.dll or any other .dll in lazarus
« on: September 29, 2011, 01:15:30 pm »
I've tried to import external dll to lazarus with {&LINKLIB libusb0_x86} but on compile says "not found". Im beginner in Lazarus but senior in VB.NET and i need only short explanation "how to import dll" in lazarus. In Lazarus wiki/help DYNAMIC LIBRARY i've found an owfull example which dont explains NOTHING,  so if there any REAL PROGRAMMER can explain this.

Best Regards

Vladimir

fabienwang

  • Sr. Member
  • ****
  • Posts: 449
  • Lazarus is the best
    • My blog
I'm using Arch Linux.
Known for: CPickSniff, OpenGrabby
Contributed to: LazPaint

ludob

  • Hero Member
  • *****
  • Posts: 1173
Re: Import libusb0_x86.dll or any other .dll in lazarus
« Reply #2 on: November 26, 2011, 02:05:20 pm »
{$LINKLIB } requires a library to link against. That is typically a file with extension .a or .lib. Hence the not found. Specify lib\gcc\libusb.a in the libusb-win32 directory.

libusb0_x86 is a dll which should be renamed to libusb0.dll when put in the windows\system32 directory. Please read libusb-win32-bin-README.txt in the bin directory.

http://wiki.freepascal.org/Lazarus/FPC_Libraries explains other ways of using external libraries.

Last but not least, a libusb unit has been created by Marko Medic : http://www.lazarus.freepascal.org/index.php/topic,11435.0.html. Here http://mcuprogramming.blogspot.com/2011/03/intro-to-delphi-lazarus-for-embeded.html you'll find a link to LIBUSB Test.zip that contains the unit and a test program. It is written for linux but it is a good start for windows.


Edit:
A delphi port can be found here: http://read.pudn.com/downloads109/sourcecode/embed/449084/PowerSwitch_DelphiSource/Demo-libUSB/LibUSB.pas__.htm
You'll need to add {$mode delphi} to the unit to get it compiled. It uses directly the dll, without a {$linklib }.
« Last Edit: November 26, 2011, 02:22:46 pm by ludob »

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Re: Import libusb0_x86.dll or any other .dll in lazarus
« Reply #3 on: November 28, 2011, 09:54:16 am »
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

 

TinyPortal © 2005-2018