Skip to content

Clear installation of Gosub on the Windows 10 - using msys64 #100

@Gustavomurta

Description

@Gustavomurta

After countless attempts and days of research and testing, I managed to do a correct installation of Gosusb on Windows 10. If you skip the procedure, you might get lost. You can use other procedures, but this one was tested by me.

The installation procedure on Windows is very simplified. And for the beginner, it can induce errors that will make the installation of Gousb impossible.

https://github.com/google/gousb#notes-for-installation-on-windows

To help the beginner, I decided to open this problem. If there is another alternative for me to help, please let me know. I have no experience with Github. I will include a summary of the procedure. If you accept my help, I will be able to inform you in detail.

  • Install Libusb-1.0 Library, using msys2

    How to use libusb under MinGW-w64: /ld.exe: cannot find -lusb? libusb/libusb#695 (comment)
    Make sure the msys64 installation folder is: C:\msys64
    Do not install elsewhere as it will have problems using the packages.

  • Add the mingw64 folder to the Windows 10 environment variables.
    example:
    Path >>> C:\msys64\mingw64\bin

    Reference:
    https://www.architectryan.com/2018/03/17/add-to-the-path-on-windows-10/

  • Install the gcc compiler, using msys2 - run command (at MSYS prompt)
    $ pacman -S mingw-w64-x86_64-gcc

  • Install the pkg-config, using msys2 - run command (at MSYS prompt)
    $ pacman -S mingw-w64-x86_64-pkg-config

  • Test the Libusb installation with these commands. Make sure the folders are correct (very important).
    Examples:
    C:\Users\jgust>pkg-config --cflags libusb-1.0
    -IC:/msys64/mingw64/include/libusb-1.0

    C:\Users\jgust>pkg-config --libs libusb-1.0
    -LC:/msys64/mingw64/lib -lusb-1.0

  • Install the Gousb package, with this command and no message of errors:
    go get -v github.com/google/gousb (This procedure no longer works)

Use this procedure:
https://go.dev/ref/mod#go-install

go install github.com/google/gousb@latest

Example:
C:\Users\jgust\go>go install github.com/google/gousb@latest
package github.com/google/gousb is not a main package

C:\Users\jgust\go\programas\gousb\lsusb>go mod init main.go
go: creating new go.mod: module main.go
go: to add module requirements and sums:
go mod tidy

C:\Users\jgust\go\programas\gousb\lsusb>go mod tidy
go: finding module for package github.com/google/gousb
go: finding module for package github.com/google/gousb/usbid
go: found github.com/google/gousb in github.com/google/gousb v1.1.3
go: found github.com/google/gousb/usbid in github.com/google/gousb v1.1.3

C:\Users\jgust\go\programas\gousb\lsusb>go build main.go

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions