Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Gustavomurta opened this issue Oct 14, 2021 · 5 comments
Open

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

Gustavomurta opened this issue Oct 14, 2021 · 5 comments

Comments

@Gustavomurta
Copy link

Gustavomurta commented Oct 14, 2021

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

@Gustavomurta Gustavomurta changed the title Clear Gousb installation on the Windows 10 - using msys64 Clear installation of Gosub on the Windows 10 - using msys64 Oct 14, 2021
@Gustavomurta
Copy link
Author

Suggestion to include this. How?

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

@zagrodzki
Copy link
Collaborator

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

@zakaria-chahboun
Copy link

@Gustavomurta Thanks sir, Thank you so mush!

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

@wdmahbubur
Copy link

@Gustavomurta I tried your solution but getting errors when install or building gousb. I attach screen shot.

Image

@Gustavomurta
Copy link
Author

Gustavomurta commented Nov 27, 2024

Hi Mahbubur Rahman,
Your error messages refer to problems with your GO program - undefined variables!
They do not refer to problems installing the GoUSB Package.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants