google/gousb

Clear installation of Gosub on the Windows 10 - using msys64

Gustavomurta opened this issue · 3 comments

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

    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 (It might take a while):
    Example:
    C:\Users\jgust\go>go get -v github.com/google/gousb
    github.com/google/gousb
    C:\Users\jgust\go>

  • Test the Gousb installation by compiling and running the example lsusb
    https://github.com/google/gousb/tree/master/lsusb

Suggestion to include this. How?

Updated Gousb instructions for Raspberry Pi :
#45 (comment)

I'd suggest you prepare a pull request with a file that outlines pretty much what you wrote above (a Markdown file, .md, for example "install-windows.md") and link to it from the README.md.

I just finished preparing an installation procedure in a Windows environment of Github Actions, so I have some clarifications for the above:

  • it would make sense to start with "install msys2" and point to the installer
  • the prefix seems to not matter (in particular, my environment puts it under D:\a\_temp\msys64 and it still works just fine, as long as you put the correct bin directory in the path. The important bit seems to be that when go invokes pkg-config, it needs to come from the mingw64 dir, so that the paths it produces point to the mingw64 file tree.
  • pacman -S mingw-w64-x86_64-pkg-config mingw-w64-x86_64-gcc mingw-w64-x86_64-libusb in a single step is sufficient

@Gustavomurta Thanks sir, Thank you so mush!

You can write these instructions on GitBook with some tutorials on gousb too if you want