[Lazarus] Editing a TDBf record

Dave Coventry dgcoventry at gmail.com
Sat Nov 29 22:54:11 CET 2008

Mark Morgan Lloyd wrote:

> ...
> When compiled for Linux I've got a simple unit UsbIf that calls Uwe 
> Zimmerman's translation of libusb.h which includes
> {$linklib usb}
> ..
> procedure usb_set_debug(level: longint);cdecl;external;
> On the Windows systems the DLL is libusb0.dll and in principle I've got 
> .h files etc. available. When I compile I get
> Error: Import library not found for usb
> ..
> Error: Undefined symbol _usb_set_debug
> It's 20 years since I've played with import libraries, and before I 
> start tinkering I need to know that I'm not heading off in the wrong 
> direction.

Having faced with the same problem in the meantime, I deleted the 
{$linklib } directive and added library and name to all function 
definitions, so your example would look like

procedure usb_set_debug(level: longint);cdecl;external libname name 

The libname constant has to be defined differently for Windows and Linux:

   libname = 'libusb0.dll';
   libname = 'libusb.so';

Another caveat with libusb-win32 is that LIBUSB_PATH_MAX constant should 
be different from the Linux one:

const LIBUSB_PATH_MAX = 512;
const LIBUSB_PATH_MAX = 4097;


More information about the Lazarus mailing list