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

Readline support for mingw #1155

Closed
mcuee opened this issue Oct 24, 2022 · 16 comments
Closed

Readline support for mingw #1155

mcuee opened this issue Oct 24, 2022 · 16 comments
Labels
bug Something isn't working enhancement New feature or request

Comments

@mcuee
Copy link
Collaborator

mcuee commented Oct 24, 2022

I created PR #1148 to add readline for mingw32/64 github action build. Unfortunately it caused problem and had to be reverted.

Looking at the failed build log (https://github.com/avrdudes/avrdude/actions/runs/3308684165/jobs/5461248027), the issue is still the MSYS2 readline/termcap packaging issues mentioned here.

On my local machine I can fix the issue by rebuilding termcap as per the tips from MSYS2 github issue.

I'll see what I can do to correct this issue using github action. I am not good at github action scripts. Hopefully someone more experienced in github action can help as well.

@mcuee mcuee added the enhancement New feature or request label Oct 24, 2022
@mcuee
Copy link
Collaborator Author

mcuee commented Oct 24, 2022

Some trial and error here, not so successful so far.
https://github.com/mcuee/avrdude/tree/readline_mingw_1

@mcuee
Copy link
Collaborator Author

mcuee commented Oct 24, 2022

The best I can come out with is to use dynamic link for libreadline.
https://github.com/mcuee/avrdude/blob/readline_mingw_1/.github/workflows/build.yml#L317

@mcuee
Copy link
Collaborator Author

mcuee commented Oct 24, 2022

BTW, if your MSYS2 mingw installation has readline included, git main will fail the build. As of now, github action mingw build does not include readline support.

It has two issues with the default build as the default build use static link.
1) missing libtermcap.a
2) even adding libtermcap.a it will still fail due to the above MSYS2 issue.

Solution is to modify termcap and add libtermcap.a in the build.

$ ./build.sh
-- Building for: Ninja
-- The C compiler identification is GNU 12.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/msys64/mingw64/bin/cc.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Found Git: C:/msys64/usr/bin/git.exe (found version "2.37.2")
-- Found FLEX: C:/msys64/usr/bin/flex.exe (found version "2.6.4")
-- Found BISON: C:/msys64/usr/bin/bison.exe (found version "3.8.2")
-- Looking for libelf.h
-- Looking for libelf.h - found
-- Looking for libelf/libelf.h
-- Looking for libelf/libelf.h - found
-- Looking for usb.h
-- Looking for usb.h - not found
-- Looking for lusb0_usb.h
-- Looking for lusb0_usb.h - found
-- Looking for libusb.h
-- Looking for libusb.h - not found
-- Looking for libusb-1.0/libusb.h
-- Looking for libusb-1.0/libusb.h - found
-- Looking for hidapi/hidapi.h
-- Looking for hidapi/hidapi.h - found
-- Looking for ftdi_tcioflush
-- Looking for ftdi_tcioflush - found
-- Configuration summary:
-- ----------------------
-- DO HAVE    libelf
-- DO HAVE    libusb
-- DO HAVE    libusb_1_0
-- DO HAVE    libhidapi
-- DON'T HAVE libftdi
-- DO HAVE    libftdi1
-- DISABLED   doc
-- DISABLED   parport
-- DISABLED   linuxgpio
-- DISABLED   linuxspi
-- ----------------------
-- Configuring done
CMake Warning (dev) at src/CMakeLists.txt:135 (add_library):
  Policy CMP0115 is not set: Source file extensions must be explicit.  Run
  "cmake --help-policy CMP0115" for policy details.  Use the cmake_policy
  command to set the policy and suppress this warning.

  File:

    C:/work/avr/avrdude_test/avrdude_main/src/ac_cfg.h.in
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Generating done
-- Build files have been written to: C:/work/avr/avrdude_test/avrdude_main/build_mingw64_nt-10.0-22000
[65/66] Building C object src/CMakeFiles/avrdude.dir/term.c.obj
In function 'tokenize',
    inlined from 'process_line' at C:/work/avr/avrdude_test/avrdude_main/src/term.c:1212:10,
    inlined from 'term_gotline' at C:/work/avr/avrdude_test/avrdude_main/src/term.c:1289:10:
C:/work/avr/avrdude_test/avrdude_main/src/term.c:1118:17: warning: pointer 'buf' may be used after 'realloc' [-Wuse-after-free]
 1118 |       ptrdiff_t k = buf - bufp;
      |                 ^
C:/work/avr/avrdude_test/avrdude_main/src/term.c:1102:18: note: call to 'realloc' here
 1102 |       buf_tmp  = realloc(buf, bufsize);
      |                  ^~~~~~~~~~~~~~~~~~~~~
[66/66] Linking C executable src\avrdude.exe
FAILED: src/avrdude.exe
cmd.exe /C "cd . && C:\msys64\mingw64\bin\cc.exe -O2 -g -DNDEBUG  src/CMakeFiles/avrdude.dir/main.c.obj src/CMakeFiles/avrdude.dir/term.c.obj src/CMakeFiles/avrdude.dir/avrintel.c.obj src/CMakeFiles/avrdude.dir/developer_opts.c.obj src/CMakeFiles/avrdude.dir/whereami.c.obj src/CMakeFiles/avrdude.dir/windows.rc.obj -o src\avrdude.exe -Wl,--out-implib,src\libavrdude.dll.a -Wl,--major-image-version,0,--minor-image-version,0  src/libavrdude.a  -lm  C:/msys64/mingw64/lib/libelf.a  C:/msys64/mingw64/lib/libusb.a  C:/msys64/mingw64/lib/libusb-1.0.a  C:/msys64/mingw64/lib/libhid.a  C:/msys64/mingw64/lib/libhidapi.a  C:/msys64/mingw64/lib/libftdi1.a  C:/msys64/mingw64/lib/libreadline.a  -lsetupapi  -lws2_32  -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ."
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/lib/libreadline.a(display.o):(.text+0xea0): undefined reference to `tputs'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/lib/libreadline.a(display.o):(.text+0xf08): undefined reference to `tputs'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/lib/libreadline.a(display.o):(.text+0x3683): undefined reference to `tputs'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/lib/libreadline.a(display.o):(.text+0x3812): undefined reference to `tputs'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/lib/libreadline.a(display.o):(.text+0x388e): undefined reference to `tputs'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/lib/libreadline.a(display.o):(.text+0x39cf): more undefined references to `tputs' follow
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/lib/libreadline.a(terminal.o):(.text+0x29c): undefined reference to `tgetnum'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/lib/libreadline.a(terminal.o):(.text+0x2d8): undefined reference to `tgetnum'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/lib/libreadline.a(terminal.o):(.text+0x7f9): undefined reference to `tgetent'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/lib/libreadline.a(terminal.o):(.text+0x837): undefined reference to `tgetstr'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/lib/libreadline.a(terminal.o):(.text+0x896): undefined reference to `tgetflag'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/lib/libreadline.a(terminal.o):(.text+0x8e6): undefined reference to `tgetflag'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/lib/libreadline.a(terminal.o):(.text+0xa80): undefined reference to `tgetflag'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/lib/libreadline.a(terminal.o):(.text+0xceb): undefined reference to `tputs'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/lib/libreadline.a(terminal.o):(.text+0xdb9): undefined reference to `tputs'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/lib/libreadline.a(terminal.o):(.text+0xea7): undefined reference to `tputs'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/lib/libreadline.a(terminal.o):(.text+0xefd): undefined reference to `tputs'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/lib/libreadline.a(terminal.o):(.text+0xd64): undefined reference to `tputs'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/lib/libreadline.a(terminal.o):(.text+0xe23): more undefined references to `tputs' follow
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
Build failed.

$ cd build_mingw64_nt-10.0-22000/

$ cmd.exe /C "cd . && C:\msys64\mingw64\bin\cc.exe -O2 -g -DNDEBUG  src/CMakeFiles/avrdude.dir/main.c.obj src/CMakeFiles/avrdude.dir/term.c.obj src/CMakeFiles/avrdude.dir/avrintel.c.obj src/CMakeFiles/avrdude.dir/developer_opts.c.obj src/CMakeFiles/avrdude.dir/whereami.c.obj src/CMakeFiles/avrdude.dir/windows.rc.obj -o src\avrdude.exe -Wl,--out-implib,src\libavrdude.dll.a -Wl,--major-image-version,0,--minor-image-version,0  src/libavrdude.a  -lm  C:/msys64/mingw64/lib/libelf.a  C:/msys64/mingw64/lib/libusb.a  C:/msys64/mingw64/lib/libusb-1.0.a  C:/msys64/mingw64/lib/libhid.a  C:/msys64/mingw64/lib/libhidapi.a  C:/msys64/mingw64/lib/libftdi1.a  C:/msys64/mingw64/lib/libreadline.a C:/msys64/mingw64/lib/libtermcap.a -lsetupapi  -lws2_32  -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole3
2 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ."

$ cd ..

$ ldd ./build_mingw64_nt-10.0-22000/src/avrdude.exe
        ntdll.dll => /c/WINDOWS/SYSTEM32/ntdll.dll (0x7ffbb8c40000)
        KERNEL32.DLL => /c/WINDOWS/System32/KERNEL32.DLL (0x7ffbb7990000)
        KERNELBASE.dll => /c/WINDOWS/System32/KERNELBASE.dll (0x7ffbb6410000)
        msvcrt.dll => /c/WINDOWS/System32/msvcrt.dll (0x7ffbb7150000)
        SETUPAPI.dll => /c/WINDOWS/System32/SETUPAPI.dll (0x7ffbb7200000)
        USER32.dll => /c/WINDOWS/System32/USER32.dll (0x7ffbb7b80000)
        win32u.dll => /c/WINDOWS/System32/win32u.dll (0x7ffbb6a20000)
        GDI32.dll => /c/WINDOWS/System32/GDI32.dll (0x7ffbb70c0000)
        gdi32full.dll => /c/WINDOWS/System32/gdi32full.dll (0x7ffbb6790000)
        msvcp_win.dll => /c/WINDOWS/System32/msvcp_win.dll (0x7ffbb6370000)
        ucrtbase.dll => /c/WINDOWS/System32/ucrtbase.dll (0x7ffbb6110000)
        WS2_32.dll => /c/WINDOWS/System32/WS2_32.dll (0x7ffbb6ac0000)
        RPCRT4.dll => /c/WINDOWS/System32/RPCRT4.dll (0x7ffbb8ae0000)
        HID.DLL => /c/WINDOWS/SYSTEM32/HID.DLL (0x7ffbb4a30000)

@mcuee
Copy link
Collaborator Author

mcuee commented Oct 24, 2022

The other simple workaround is to use dynamic link for the dependancies.

github action artifact here.
https://github.com/avrdudes/avrdude/actions/runs/3313008302

$ rm -rf build_mingw64_shared/
$ cmake -G"MSYS Makefiles" -D CMAKE_BUILD_TYPE=RelWithDebInfo -D USE_STATIC_LIBS=OFF -B build_mingw64_shared
$ cmake --build build_mingw64_shared

$ ldd ./build_mingw64_shared/src/avrdude.exe
        ntdll.dll => /c/WINDOWS/SYSTEM32/ntdll.dll (0x7ffbb8c40000)
        KERNEL32.DLL => /c/WINDOWS/System32/KERNEL32.DLL (0x7ffbb7990000)
        KERNELBASE.dll => /c/WINDOWS/System32/KERNELBASE.dll (0x7ffbb6410000)
        msvcrt.dll => /c/WINDOWS/System32/msvcrt.dll (0x7ffbb7150000)
        SETUPAPI.dll => /c/WINDOWS/System32/SETUPAPI.dll (0x7ffbb7200000)
        WS2_32.dll => /c/WINDOWS/System32/WS2_32.dll (0x7ffbb6ac0000)
        RPCRT4.dll => /c/WINDOWS/System32/RPCRT4.dll (0x7ffbb8ae0000)
        HID.DLL => /c/WINDOWS/SYSTEM32/HID.DLL (0x7ffbb4a30000)
        libftdi1.dll => /mingw64/bin/libftdi1.dll (0x7ffb7e180000)
        libhidapi-0.dll => /mingw64/bin/libhidapi-0.dll (0x7ffb968b0000)
        libreadline8.dll => /mingw64/bin/libreadline8.dll (0x7ffb77910000)
        USER32.dll => /c/WINDOWS/System32/USER32.dll (0x7ffbb7b80000)
        libusb-1.0.dll => /mingw64/bin/libusb-1.0.dll (0x7ffb778d0000)
        win32u.dll => /c/WINDOWS/System32/win32u.dll (0x7ffbb6a20000)
        libusb-0-1-4.dll => /mingw64/bin/libusb-0-1-4.dll (0x7ffb96860000)
        GDI32.dll => /c/WINDOWS/System32/GDI32.dll (0x7ffbb70c0000)
        libtermcap-0.dll => /mingw64/bin/libtermcap-0.dll (0x6ac40000)
        gdi32full.dll => /c/WINDOWS/System32/gdi32full.dll (0x7ffbb6790000)
        msvcp_win.dll => /c/WINDOWS/System32/msvcp_win.dll (0x7ffbb6370000)
        ucrtbase.dll => /c/WINDOWS/System32/ucrtbase.dll (0x7ffbb6110000)

@mcuee
Copy link
Collaborator Author

mcuee commented Oct 28, 2022

For those who want to test readline and static linking version of avrdude git main under Windows (mingw32 version), you can try the binary mentioned here.

I did some simple test of the binary (https://github.com/arduino/avrdude-packing/files/9889835/avrdude-main-test-libusb-compat.zip) and it works well.

@mcuee
Copy link
Collaborator Author

mcuee commented Oct 30, 2022

I am closing this one as it is a specific problem with the current MSYS2 packaging of readline/termcap.

@mcuee mcuee closed this as completed Oct 30, 2022
@mcuee
Copy link
Collaborator Author

mcuee commented Nov 21, 2022

Re-open so that this gets attention as it will affect -c urclock function in terminal mode.

Out of the two issues, missing libtermcap.a is an avrdude bug. The second issue is not an avrdude issue but rather an issue with MSYS2 readline/termcap packaging issue.

  1. Missing libtermcap.a
  2. Even adding libtermcap.a it will still fail due to the MSYS2 issue.

@mcuee mcuee reopened this Nov 21, 2022
@mcuee mcuee changed the title To add readline for mingw32/64 github action build Readline support for mingw Nov 21, 2022
@mcuee mcuee added the bug Something isn't working label Nov 21, 2022
@mcuee
Copy link
Collaborator Author

mcuee commented Nov 21, 2022

One potential solution is here.

Once #1171 is merged, I will publish snapshot binaries for Linux/Windows/macOS.

@mcuee
Copy link
Collaborator Author

mcuee commented Dec 31, 2022

Snapshot release are here:
https://github.com/mcuee/avrdude-packing/releases

@mcuee
Copy link
Collaborator Author

mcuee commented Jan 5, 2023

@mariusgreuel

Is it possible for you to fix the CMake issue to include libtermcap.a in the build (static linking)? Thanks.

The other issue is MSYS2 specific issue.

@mcuee
Copy link
Collaborator Author

mcuee commented Jan 5, 2023

@mariusgreuel
Please also help to look into the following two patches Arduino-packing project. Thanks.
https://github.com/mcuee/avrdude-packing/tree/main/patches

@mcuee
Copy link
Collaborator Author

mcuee commented Jan 6, 2023

This is what I have, after rebuild libtermcap.a for MinGW.

$ git diff
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 522f505..0ce5cbe 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -125,6 +125,7 @@ if(USE_STATIC_LIBS)
     set(PREFERRED_LIBFTDI libftdi.a ftdi)
     set(PREFERRED_LIBFTDI1 libftdi1.a ftdi1)
     set(PREFERRED_LIBREADLINE libreadline.a)
+       set(PREFERRED_LIBTERMCAP libtermcap.a)
 else()
     set(PREFERRED_LIBELF elf)
     set(PREFERRED_LIBUSB usb)
@@ -227,6 +228,11 @@ elseif(MSVC)
     set(HAVE_LIBREADLINE 1)
 endif()

+find_library(HAVE_LIBTERMCAP NAMES termcap)
+if(HAVE_LIBTERMCAP)
+    set(LIB_LIBTERMCAP ${HAVE_LIBTERMCAP})
+endif()
+
 # =====================================
 # Use external libraries if requested
 # =====================================
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index c51214e..8b593f9 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -271,6 +271,7 @@ target_link_libraries(libavrdude
     ${LIB_LIBFTDI}
     ${LIB_LIBFTDI1}
     ${LIB_LIBREADLINE}
+    ${LIB_LIBTERMCAP}
     ${EXTRA_WINDOWS_LIBRARIES}
     )

$ ./build.sh
-- Building for: Ninja
-- The C compiler identification is GNU 12.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/msys64/mingw64/bin/cc.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Found Git: C:/msys64/usr/bin/git.exe (found version "2.38.0")
-- Found FLEX: C:/msys64/usr/bin/flex.exe (found version "2.6.4")
-- Found BISON: C:/msys64/usr/bin/bison.exe (found version "3.8.2")
-- Looking for libelf.h
-- Looking for libelf.h - found
-- Looking for libelf/libelf.h
-- Looking for libelf/libelf.h - found
-- Looking for usb.h
-- Looking for usb.h - not found
-- Looking for lusb0_usb.h
-- Looking for lusb0_usb.h - found
-- Looking for libusb.h
-- Looking for libusb.h - not found
-- Looking for libusb-1.0/libusb.h
-- Looking for libusb-1.0/libusb.h - found
-- Looking for hidapi/hidapi.h
-- Looking for hidapi/hidapi.h - found
-- Looking for ftdi_tcioflush
-- Looking for ftdi_tcioflush - found
-- Configuration summary:
-- ----------------------
-- DO HAVE    libelf
-- DO HAVE    libusb
-- DO HAVE    libusb_1_0
-- DO HAVE    libhidapi
-- DON'T HAVE libftdi
-- DO HAVE    libftdi1
-- DO HAVE    libreadline
-- DISABLED   doc
-- DISABLED   parport
-- DISABLED   linuxgpio
-- DISABLED   linuxspi
-- ----------------------
-- Configuring done
-- Generating done
-- Build files have been written to: C:/work/avr/avrdude_test/avrdude_main/build_mingw64_nt-10.0-19044
[65/67] Building C object src/CMakeFiles/avrdude.dir/term.c.obj
In function 'tokenize',
    inlined from 'process_line' at C:/work/avr/avrdude_test/avrdude_main/src/term.c:1294:10:
C:/work/avr/avrdude_test/avrdude_main/src/term.c:1202:17: warning: pointer 'buf' may be used after 'realloc' [-Wuse-after-free]
 1202 |       ptrdiff_t k = buf - bufp;
      |                 ^
C:/work/avr/avrdude_test/avrdude_main/src/term.c:1186:18: note: call to 'realloc' here
 1186 |       buf_tmp  = realloc(buf, bufsize);
      |                  ^~~~~~~~~~~~~~~~~~~~~
[67/67] Linking C executable src\avrdude.exe

Build succeeded.

Run

sudo cmake --build build_mingw64_nt-10.0-19044 --target install

to install.

@mcuee
Copy link
Collaborator Author

mcuee commented Jan 6, 2023

It seems to me the issue has been fixed in github action MSYS2 MinGW.

So I will create a PR for review.

@mcuee
Copy link
Collaborator Author

mcuee commented Jan 6, 2023

I will close this and create a new issue to adopt the approach of PR #1264 for MinGW.

@mcuee mcuee closed this as completed Jan 6, 2023
@mcuee
Copy link
Collaborator Author

mcuee commented Jan 16, 2023

FYI only: MSYS2 has fixed the issue with GNU Readline static linking.
msys2/MINGW-packages#8105

Still it is better to adopt the approach of PR #1264 for MinGW than to use GNU Readline.

@mcuee
Copy link
Collaborator Author

mcuee commented Jan 16, 2023

Build log.

$ git diff
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 66ef3a7..bce76b5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -125,6 +125,7 @@ if(USE_STATIC_LIBS)
     set(PREFERRED_LIBFTDI libftdi.a ftdi)
     set(PREFERRED_LIBFTDI1 libftdi1.a ftdi1)
     set(PREFERRED_LIBREADLINE libreadline.a)
+       set(PREFERRED_LIBTERMCAP libtermcap.a)
 else()
     set(PREFERRED_LIBELF elf)
     set(PREFERRED_LIBUSB usb)
@@ -133,6 +134,7 @@ else()
     set(PREFERRED_LIBFTDI ftdi)
     set(PREFERRED_LIBFTDI1 ftdi1)
     set(PREFERRED_LIBREADLINE readline)
+       set(PREFERRED_LIBTERMCAP termcap)
 endif()

 # -------------------------------------
@@ -227,6 +229,11 @@ elseif(MSVC)
     set(HAVE_LIBREADLINE 1)
 endif()

+find_library(HAVE_LIBTERMCAP NAMES termcap)
+if(HAVE_LIBTERMCAP)
+    set(LIB_LIBTERMCAP ${HAVE_LIBTERMCAP})
+endif()
+
 # =====================================
 # Use external libraries if requested
 # =====================================

$ ./build.sh
-- The C compiler identification is GNU 12.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/msys64/mingw64/bin/cc.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Found Git: C:/msys64/usr/bin/git.exe (found version "2.39.0")
-- Configuration summary:
-- ----------------------
-- DO HAVE    libelf
-- DO HAVE    libusb
-- DO HAVE    libusb_1_0
-- DO HAVE    libhidapi
-- DON'T HAVE libftdi
-- DO HAVE    libftdi1
-- DO HAVE    libreadline
-- DISABLED   doc
-- DISABLED   parport
-- DISABLED   linuxgpio
-- DISABLED   linuxspi
-- ----------------------
-- Configuring done
-- Generating done
-- Build files have been written to: C:/work/avr/avrdude_test/avrdude_main/build_mingw64_nt-10.0-19044
[60/66] Building C object src/CMakeFiles/avrdude.dir/term.c.obj
In function 'tokenize',
    inlined from 'process_line' at C:/work/avr/avrdude_test/avrdude_main/src/term.c:1294:10,
    inlined from 'terminal_mode_noninteractive' at C:/work/avr/avrdude_test/avrdude_main/src/term.c:1420:14:
C:/work/avr/avrdude_test/avrdude_main/src/term.c:1202:17: warning: pointer 'buf' may be used after 'realloc' [-Wuse-after-free]
 1202 |       ptrdiff_t k = buf - bufp;
      |                 ^
C:/work/avr/avrdude_test/avrdude_main/src/term.c:1186:18: note: call to 'realloc' here
 1186 |       buf_tmp  = realloc(buf, bufsize);
      |                  ^~~~~~~~~~~~~~~~~~~~~
[66/66] Linking C executable src\avrdude.exe

Build succeeded.

Run

sudo cmake --build build_mingw64_nt-10.0-19044 --target install

to install.


$ ldd build_mingw64_nt-10.0-19044/src/avrdude.exe
        ntdll.dll => /c/WINDOWS/SYSTEM32/ntdll.dll (0x7ffbda430000)
        KERNEL32.DLL => /c/WINDOWS/System32/KERNEL32.DLL (0x7ffbd8d70000)
        KERNELBASE.dll => /c/WINDOWS/System32/KERNELBASE.dll (0x7ffbd8040000)
        msvcrt.dll => /c/WINDOWS/System32/msvcrt.dll (0x7ffbd9470000)
        SETUPAPI.dll => /c/WINDOWS/System32/SETUPAPI.dll (0x7ffbd9510000)
        cfgmgr32.dll => /c/WINDOWS/System32/cfgmgr32.dll (0x7ffbd8420000)
        ucrtbase.dll => /c/WINDOWS/System32/ucrtbase.dll (0x7ffbd7d80000)
        RPCRT4.dll => /c/WINDOWS/System32/RPCRT4.dll (0x7ffbd9340000)
        bcrypt.dll => /c/WINDOWS/System32/bcrypt.dll (0x7ffbd8010000)
        WS2_32.dll => /c/WINDOWS/System32/WS2_32.dll (0x7ffbd8c00000)
        HID.DLL => /c/WINDOWS/SYSTEM32/HID.DLL (0x7ffbd5330000)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant