Florin-Popescu / avarice-unofficial

AVaRICE with support for newer devices
GNU General Public License v2.0
13 stars 8 forks source link

MinGW Build.sh not working #10

Closed maxgerhardt closed 1 year ago

maxgerhardt commented 1 year ago

I'm trying to compile this repository for Windows using MSys2/MinGW64, which should work according to older releases like Support for ATmega4809, but I can't get this to work for the newest version.

First of all I had to adapt the build.sh to fix issues with parameter order and github links that required SSH authentication instead of just using HTTPS.

#!/bin/bash

case $(uname -o | cut -d '/' -f2) in
        "Msys")
                wget https://github.com/Florin-Popescu/libusb-compat-0.1/releases/download/v0.1.7/libusb-compat-0.1_msys_x86_64.zip -O libusb-compat-0.1_msys_x86_64.zip
                unzip -o libusb-compat-0.1_msys_x86_64.zip
                cp -r libusb-compat-0.1_msys2_x86_64/* /

                #These libraries are not available pre-built under msys2
                git clone https://github.com/libusb/libusb.git
                cd ./libusb
                ./bootstrap.sh
                ./configure
                make -j$NUMBER_OF_PROCESSORS
                make install
                cd ..

                git clone https://github.com/libusb/hidapi.git
                cd ./hidapi
                ./bootstrap
                ./configure
                make all -j$NUMBER_OF_PROCESSORS
                make install
                cd ..

                SUDO=
                ;;
        "Linux")
                NUMBER_OF_PROCESSORS=$(nproc)
                SUDO=sudo
                ;;
esac

./Bootstrap
./configure

make all -j$NUMBER_OF_PROCESSORS

Even then, this won't compile due to missing termios.h in MinGW.

g++ -DHAVE_CONFIG_H -I.  -Wall -Wextra -DENABLE_TARGET_PROGRAMMING=0   -g -O2  -MT jtag2rw.o -MD -MP -MF .deps/jtag2rw.Tpo -c -o jtag2rw.o jtag2rw.cc
In file included from devdescr.cc:29:
jtag.h:29:10: fatal error: termios.h: No such file or directory
   29 | #include <termios.h>
      |          ^~~~~~~~~~~
maxgerhardt commented 1 year ago

Oh I see my error now. It's supposed to be build in "MSYS2/MSYS", not "MSYS2/MinGW64". Retrying.

maxgerhardt commented 1 year ago

Using the build.sh above in the MSYS2/MSYS environment results in a compiled binary that cannot be executed

$ avarice_installed/usr/bin/avarice.exe  --help
C:/msys64/home/Max/avarice_florin/avarice_installed/usr/bin/avarice.exe: error while loading shared libraries: ?: cannot open shared object file: No such file or directory

and that's although all .dll's are found

$ ldd avarice_installed/usr/bin/avarice.exe
        ntdll.dll => /c/Windows/SYSTEM32/ntdll.dll (0x7ffda8210000)
        KERNEL32.DLL => /c/Windows/System32/KERNEL32.DLL (0x7ffda7fe0000)
        KERNELBASE.dll => /c/Windows/System32/KERNELBASE.dll (0x7ffda5e20000)
        msys-hidapi-0.dll => /usr/bin/msys-hidapi-0.dll (0x522210000)
        msys-2.0.dll => /usr/bin/msys-2.0.dll (0x180040000)
        msys-usb-0-1-4.dll => /usr/bin/msys-usb-0-1-4.dll (0x5705a0000)
        msys-gcc_s-seh-1.dll => /usr/bin/msys-gcc_s-seh-1.dll (0x5e8160000)
        msys-stdc++-6.dll => /usr/bin/msys-stdc++-6.dll (0x526840000)
maxgerhardt commented 1 year ago

Aha, I just had to copy /mingw64/bin/libusb-1.0.dll into the binary directory for it to be ablet to find the missing librariy.