Skip to content

How to use libusb under MinGW-w64: /ld.exe: cannot find -lusb? #695

@theshawnz

Description

@theshawnz

The instructions for adding this library to your Visual Studio Code (VSCode) project can be quite skinny. Some people mention "add -lusb" or "add -libusb-1.0" to your tasks.json to make it work; well this may not be specific enough for some.

for reference:

Windows 10, MinGW64 and VSCode.

Try removing both of those commands above and adding the following to your arguments section where I have both mingw 32 and 64 installed on the same machine within my MinGw folder):

            "-LI",
            "<path to MinGW Lib files>\\libusb-1.0.a"

your compiler command looking something like this: gcc -Wall -o ${fileDirname}\${fileBasenameNoExtension}.exe ${file} -LI C:\MinGW\mingw64\lib\libusb-1.0.a

I was able to compile the included examples testlibusb.c, listdevs.c, etc after doing so.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions