Skip to content

Windows support #4

@VitalyArtemiev

Description

@VitalyArtemiev

Hello.

I am trying to get these headers (from lubusb-1.0 branch) to work under Windows (currently just trying to compile your example project test1library).
In the LibUsb unit there are the following lines:

{$LINKLIB c}

{$LINKLIB usb-1.0}

As far as I understand, there is no access to libc on windows. Other questions on similar topics suggest replacing libc with libmsvcrt. I've replaced the above code with the following:

{$ifdef windows}
  {$linklib msvcrt}
{$else}
  {$LINKLIB c}
{$endif}

{$LINKLIB usb-1.0}

Of course, this gets rid of the "Import library not found for c" error, however instead I get errors about undefined symbols (seems like every symbol defined in LibUsb unit):

test2controlsync.pas(120,52) Hint: Variable "DescrConf" does not seem to be initialized
test2controlsync.pas(136,52) Hint: Variable "DescrIntf" does not seem to be initialized
test2controlsync.pas(153,50) Hint: Variable "DescrEP" does not seem to be initialized
Error: Undefined symbol: LIBUSB_::=::\_LIBUSB_CONTROL_TRANSFER$crc40A776B7
Error: Undefined symbol: LIBUSB_::=::\_LIBUSB_INIT$PLIBUSB_CONTEXT::=::\LONGINT
Error: Undefined symbol: LIBUSB_::=::\_LIBUSB_EXIT$PLIBUSB_CONTEXT
Error: Undefined symbol: LIBUSB_::=::\_LIBUSB_SET_DEBUG$PLIBUSB_CONTEXT$LONGINT
Error: Undefined symbol: LIBUSB_::=::\_LIBUSB_GET_VERSION::=::\PLIBUSB_VERSION
Error: Undefined symbol: LIBUSB_::=::\_LIBUSB_HAS_CAPABILITY$LONGWORD::=::\LONGINT
Error: Undefined symbol: LIBUSB_::=::\_LIBUSB_ERROR_NAME$LONGINT::=::\PCCHAR

...
etc.

I don't know if this is connected to the libc/libmsvcrt issue or if this is a separate problem. I'm quite a noob when it comes to header translation, linking etc. Do you have any pointers as to which direction I need to be digging?

I am using the latest lazarus/FPC build and the latest version of libusb from https://libusb.info/
(BTW, in your readme file the link to linkusb site no longer works).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions