Skip to content

Update MinGW build instructions and Makefile #459

@maxgerhardt

Description

@maxgerhardt

I could not get this project to compile as-is under a Windows + MSys2 MinGW environment due to multiple errors:

  • the WIN macro responsible for detection of MSys is commented out in the Makefile.common. Therefore it doesn't even try and set the Windows / MinGW specific options.

    simavr/Makefile.common

    Lines 87 to 90 in a56b550

    # FIXME uname -o doesn't work on bsd derivatives
    #WIN := ${shell uname -o}
    ifeq (${WIN}, Msys)
  • a list of dependencies within the MSYS2 system should be given. For 64-bit builds, that is
    • pacman -S mingw-w64-x86_64-toolchain
    • pacman -S mingw-w64-x86_64-libelf
    • pacman -S mingw-w64-x86_64-avr-toolchain
    • pacman -S mingw-w64-x86_64-freeglut
  • GCC, which is of the very recent version 10.3.0 from 2020 (mingw-w64-x86_64-gcc 10.3.0-2), fails to find strsep as reported in undefined reference to strsep #403. The issue was closed without giving a resolution other than "old libc, not worth my time", making compilation on Windows impossible. PR Check if environment is MinGW and implement missing strsep() #404 is partly correct here, in my case I also needed to ammend the header file to expose the function.
  • The function avr_usb_ep_read() fails to compile under the above GCC option because it thinks v might be uninitialized upon return, and that warning is turned into an error by -Werror.
  • Using WinAVR like the README.mingw says and the makefile references isn't really needed if MSys2 provides the package mingw-w64-x86_64-avr-toolchain (AVR-GCC 8.4.0). All it matters that there's avr-gcc and avr-libc. A slight adaption in the Makefile to fix the AVR include path to /mingw64/avr and AVR compiler path / prefix fixes this.
  • While building simavr via make build-simavr can be done, a normal make fails while compiling an example requiring the Unix header pty.h. Non-compatible examples should be excluded from the build. Or, https://github.com/rprichard/winpty can be substituted.
CC uart_pty.c
uart_pty.c:38:10: fatal error: pty.h: No such file or directory
   38 | #include <pty.h>
      |          ^~~~~~~
compilation terminated.
make[1]: *** [../..//Makefile.common:189: obj-x86_64-w64-mingw32/uart_pty.o] Error 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions