[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
'usb_set_debug';
The libname constant has to be defined differently for Windows and Linux:
const
{$IFDEF MSWINDOWS}
libname = 'libusb0.dll';
{$ELSE}
libname = 'libusb.so';
{$ENDIF}
Another caveat with libusb-win32 is that LIBUSB_PATH_MAX constant should
be different from the Linux one:
{$IFDEF MSWINDOWS}
const LIBUSB_PATH_MAX = 512;
{$ENDIF}
{$IFDEF LINUX}
const LIBUSB_PATH_MAX = 4097;
{$ENDIF}
Regards,
Sergei
More information about the Lazarus
mailing list