pok3r-custom / pok3rtool

Command line tool and library for keyboards using qmk-pok3r
BSD 3-Clause "New" or "Revised" License
41 stars 7 forks source link

Can't compile on MSYS2, but can on WSL2 #8

Closed YuyQuan closed 2 years ago

YuyQuan commented 3 years ago

I have a hunch it has to do with libusb-compat-devel not being available for MSYS2 as far as I've tried. See https://github.com/pok3r-custom/pok3rtool/issues/7

This is the error I receive when trying to make:

Quan@quantop MSYS ~/pok3rtool-build
# make
[  2%] Building CXX object libchaos/chaos/CMakeFiles/chaos-static.dir/chaos.cpp.o
[  5%] Building CXX object libchaos/chaos/CMakeFiles/chaos-static.dir/base/zclock.cpp.o
[  5%] Building CXX object libchaos/chaos/CMakeFiles/chaos-static.dir/base/zerror.cpp.o
/home/Quan/pok3rtool/libchaos/chaos/base/zerror.cpp: In function ‘int LibChaos::ZError::getSocketErrorCode()’:
/home/Quan/pok3rtool/libchaos/chaos/base/zerror.cpp:866:12: error: ‘WSAGetLastError’ was not declared in this scope; did you mean ‘DdeGetLastError’?
  866 |     return WSAGetLastError();
      |            ^~~~~~~~~~~~~~~
      |            DdeGetLastError
/home/Quan/pok3rtool/libchaos/chaos/base/zerror.cpp: In function ‘LibChaos::ZString LibChaos::ZError::getSocketError()’:
/home/Quan/pok3rtool/libchaos/chaos/base/zerror.cpp:874:17: error: ‘WSAGetLastError’ was not declared in this scope; did you mean ‘DdeGetLastError’?
  874 |     DWORD err = WSAGetLastError();
      |                 ^~~~~~~~~~~~~~~
      |                 DdeGetLastError
make[2]: *** [libchaos/chaos/CMakeFiles/chaos-static.dir/build.make:104: libchaos/chaos/CMakeFiles/chaos-static.dir/base/zerror.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:1012: libchaos/chaos/CMakeFiles/chaos-static.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

Note: will compile for WSL2, but since WSL2 does not have libusb support (https://github.com/microsoft/WSL/issues/689), no devices are ever listed.

YuyQuan commented 2 years ago

Update: some week after writing this issue, I did get pok3rtool to compile and working on MSYS2. I did not update the post because, truthfully, I stayed up way too late trying many different things and couldn't recall what made it work the next morning. If I had to guess on the solution: it could be installing some dependency in the development package variant, or slightly modifying libchaos to not complain, or it may have had something to do with what libchaos mishandling the MSYS2 platform (is it making api calls to windows or linux?).

After switching to a new machine (and wanting to update my vortex core keymap), I had to retrace my steps and resolve this. I could not reproduce the solution (I could not get pok3rtool to compile). Luckily, it's moot. We are now able to connect USB device in WSL2: https://devblogs.microsoft.com/commandline/connecting-usb-devices-to-wsl/

I can confirm that I was able to follow the blog post and flash my vortex core, albeit a bit annoying to have to run a command (and in the future, remember) to attach the USB device to WSL, set the keyboard into bootloader, (I think attach again), and flash.

P.S. The blog mentions a requirement of Windows 11. As of current, I'm running Windows 10 and got it to work. One user commented that you'll need WSL kernel version >= 5.10.60.1 which can be accomplished with a manual download. I was able to run wsl --update and get up to said kernel version on Windows 10 Enterprise (ver 2004).