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

Dynamic link to dependency libraries #955

Closed
mcuee opened this issue May 10, 2022 · 17 comments
Closed

Dynamic link to dependency libraries #955

mcuee opened this issue May 10, 2022 · 17 comments
Labels
enhancement New feature or request

Comments

@mcuee
Copy link
Collaborator

mcuee commented May 10, 2022

My main interest here is for Windows. How can I shared a version of avrdude binary which is dynamically linked to libusb-1.0.dll, libftdi1.dll and libhidapi.dll under Windows? I do not really need to build the shared library as it may take some time (at least for Windows, not an issue for Linux) as per #952, #953 and #954.

@mcuee
Copy link
Collaborator Author

mcuee commented May 10, 2022

One possibility is to let the user to select the header file name and library file name for these dependencies libraries. So the user can easily select the static library (eg: libusb-1.0.a) or the dynamic library (eg: libusb-1.0.dll.a).

@mcuee
Copy link
Collaborator Author

mcuee commented May 10, 2022

Interestingly the "classic" release tarball (generated by auto-tools) will build the avrdude binary I want -- which means that it has dynamic link to the dependancy libraries.

 /bin/sh ./libtool  --tag=CC   --mode=link gcc -Wall -Wno-pointer-sign -g -O2 -DWIN32NATIVE  -static -o avrdude.exe avrdude-main.o avrdude-whereami.o avrdude-term.o ./libavrdude.a -lusb-1.0  -lusb -lftdi1  -lhid -lsetupapi -lelf -lpthread -lm -lhidapi -lreadline -lncurses -ltermcap  -lftdi1 -lws2_32
libtool: link: gcc -Wall -Wno-pointer-sign -g -O2 -DWIN32NATIVE -o avrdude.exe avrdude-main.o avrdude-whereami.o avrdude-term.o  ./libavrdude.a -lusb-1.0 -lusb -lhid -lsetupapi -lelf -lpthread -lhidapi -lreadline -lncurses -ltermcap -lftdi1 -lws2_32

However, CMake is using static libraries. Strange thing is that it is using dynamic library for readline.

cd /C/work/avr/avrdude-7.0_cmake/avrdude-7.0/build/src && /C/msys64/mingw64/bin/gcc.exe -Wl,--whole-archive CMakeFiles/avrdude.dir/objects.a -Wl,--no-whole-archive -o avrdude.exe -Wl,--out-implib,libavrdude.dll.a -Wl,--major-image-version,0,--minor-image-version,0  libavrdude.a /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.dll.a -lsetupapi -lws2_32 -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32

@mcuee
Copy link
Collaborator Author

mcuee commented May 10, 2022

So the hacky way for CMake is to change the build command to use dynamic dependancy libs.

 cd /C/work/avr/avrdude-7.0_cmake/avrdude-7.0/build/src && /C/msys64/mingw64/bin/gcc.exe -Wl,--whole-archive CMakeFiles/avrdude.dir/objects.a -Wl,--no-whole-archive -o avrdude.exe -Wl,--out-implib,libavrdude.dll.a -Wl,--major-image-version,0,--minor-image-version,0  libavrdude.a -lelf -lusb -lusb-1.0 -lhid -lhidapi -lftdi1 /C/msys64/mingw64/lib/libreadline.a -lsetupapi -lws2_32 -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32

@mcuee
Copy link
Collaborator Author

mcuee commented May 10, 2022

Here are three versions of the avrdude 7.0 release 64bit Windows binary using MSYS2 mingw64 (CMake static, CMake dynmaic and auto-tools dynamic). The dependancies dll are also included.
https://github.com/mcuee/avrdude/releases/tag/v7.0
avrdude-7.0_bin64.zip

@mcuee
Copy link
Collaborator Author

mcuee commented May 11, 2022

The resultant shared avrdude is working fine.

PS C:\work\avr\avrdude-7.0_cmake\avrdude-7.0_bin64> dir

    Directory: C:\work\avr\avrdude-7.0_cmake\avrdude-7.0_bin64

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a---           10/5/2022  8:56 pm        2638358 avrdude_autotools.exe
-a---           10/5/2022  9:15 pm        1217601 avrdude_shared.exe
-a---           10/5/2022  9:12 pm        1428805 avrdude_static.exe
-a---           10/5/2022  9:00 pm         612260 avrdude.conf
-a---           10/5/2022  9:03 pm         858300 libavrdude.a
-a---           11/8/2021  4:28 pm         123360 libftdi1.dll
-a---            6/1/2022 12:14 am          26569 libhidapi-0.dll
-a---            4/4/2021  9:55 pm          50938 libusb-0-1-4.dll
-a---           11/4/2022 11:32 pm         214745 libusb-1.0.dll
-a---          25/12/2021  6:04 pm         139776 libusb0.dll

PS C:\work\avr\avrdude-7.0_cmake\avrdude-7.0_bin64> .\avrdude_shared.exe -p m328p -P usb -c dragon_isp -U flash:w:optiboot_atmega328.hex:i

avrdude_shared.exe: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.17s

avrdude_shared.exe: Device signature = 0x1e950f (probably m328p)
avrdude_shared.exe: NOTE: "flash" memory has been specified, an erase cycle will be performed
                    To disable this feature, specify the -D option.
avrdude_shared.exe: erasing chip
avrdude_shared.exe: reading input file "optiboot_atmega328.hex"
avrdude_shared.exe: writing flash (32768 bytes):

Writing | ################################################## | 100% 0.01s

avrdude_shared.exe: 32768 bytes of flash written
avrdude_shared.exe: verifying flash memory against optiboot_atmega328.hex:

Reading | ################################################## | 100% 0.01s

avrdude_shared.exe: 32768 bytes of flash verified

avrdude_shared.exe done.  Thank you.

@mcuee
Copy link
Collaborator Author

mcuee commented May 14, 2022

#962 is working for MSYS2 mingw32/mingw64 build -- either use static link or use dynamic link for all the dependancy libraries.

For MSVC, #962 is not really working as we need to use the external custom libraries (libelf, libusb, libftdi and hidapi) which seem to only produce static libraries as of now.

Still it will be great that users can define the option to link to static/shared lib individually (per library basis). For example, only use dynamic link for libusb-1.0, hidapi and libftdi1; and use static link to libelf and readline.

@mcuee
Copy link
Collaborator Author

mcuee commented Jun 11, 2022

#962 has been merged and the option to use static lib or dynamic lib was added. But it has not been implemented yet.

@mariusgreuel wrote in the pull request comments.

Note that the CMake files now include the option USE_STATIC_LIBS, which people can use to select either static or dynamic linking. Note, however, that I leave the implementation for somebody else in a separate PR. The current implementation will not work for non-defaults, i.e. statically linking for Linux or dynamically on Windows.

@mcuee
Copy link
Collaborator Author

mcuee commented Aug 13, 2022

For example, the default under Linux is dynamic linking.

mcuee@UbuntuSwift3:~/build/avr/avrdude/build_linux/src$ ldd avrdude
	linux-vdso.so.1 (0x00007fffd11d1000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f8844b7b000)
	libelf.so.1 => /lib/x86_64-linux-gnu/libelf.so.1 (0x00007f8844b5f000)
	libusb-0.1.so.4 => /usr/local/lib/libusb-0.1.so.4 (0x00007f8844b57000)
	libusb-1.0.so.0 => /usr/local/lib/libusb-1.0.so.0 (0x00007f8844b37000)
	libhidapi-libusb.so.0 => /usr/local/lib/libhidapi-libusb.so.0 (0x00007f8844b2c000)
	libftdi.so.1 => /lib/x86_64-linux-gnu/libftdi.so.1 (0x00007f8844b20000)
	libftdi1.so.2 => /usr/local/lib/libftdi1.so.2 (0x00007f8844b0f000)
	libreadline.so.8 => /lib/x86_64-linux-gnu/libreadline.so.8 (0x00007f8844abf000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f88448cd000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f8844d7f000)
	libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f88448b1000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f884488e000)
	libudev.so.1 => /lib/x86_64-linux-gnu/libudev.so.1 (0x00007f884485f000)
	libtinfo.so.6 => /lib/x86_64-linux-gnu/libtinfo.so.6 (0x00007f884482f000)

On the other hand, Arduino build is already using static linking.

mcuee@UbuntuSwift3:~/build/avr$ ldd ./avrdude_Linux_64bit/bin/avrdude 
	linux-vdso.so.1 (0x00007ffe933ca000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f83ce51e000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f83ce4fb000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f83ce309000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f83ce68a000)

Ref:

@mcuee
Copy link
Collaborator Author

mcuee commented Aug 13, 2022

Same for macOS.

mcuee@mcuees-Mac-mini avr % otool -L ./avrdude/build_darwin/src/avrdude
./avrdude/build_darwin/src/avrdude:
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1311.100.3)
	/opt/homebrew/opt/libusb-compat/lib/libusb-0.1.4.dylib (compatibility version 9.0.0, current version 9.4.0)
	/opt/homebrew/opt/libusb/lib/libusb-1.0.0.dylib (compatibility version 4.0.0, current version 4.0.0)
	/opt/homebrew/opt/libhid/lib/libhid.0.dylib (compatibility version 1.0.0, current version 1.0.0)
	/opt/homebrew/opt/hidapi/lib/libhidapi.0.dylib (compatibility version 0.0.0, current version 0.12.0)
	/opt/homebrew/opt/libftdi0/lib/libftdi.1.dylib (compatibility version 22.0.0, current version 22.0.0)
	/opt/homebrew/opt/libftdi/lib/libftdi1.2.dylib (compatibility version 2.0.0, current version 2.5.0)
	/usr/lib/libedit.3.dylib (compatibility version 2.0.0, current version 3.0.0)

On the othe hand, the build from Arduino alreay uses static linking for macOS.
https://github.com/arduino/avrdude-packing/releases/tag/7.0-arduino.3

mcuee@mcuees-Mac-mini avr % otool -L ./avrdude_test/avrdude_macOS_64bit/bin/avrdude 
./avrdude_test/avrdude_macOS_64bit/bin/avrdude:
	/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 1673.126.0)
	/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)
	/System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 23.0.0)
	/System/Library/Frameworks/Security.framework/Versions/A/Security (compatibility version 1.0.0, current version 59306.41.2)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.0.0)
	/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 1894.10.126)
	/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1673.126.0)

@mcuee
Copy link
Collaborator Author

mcuee commented Aug 13, 2022

Take note the Windows MSYS2 mingw32/mingw64 build will have a dynamic link to libusb0.dll if you link to libusb-win32.

Ref:

The solution for is to use libusb-compat-0.1 to replace libusb-win32.

You can of course use the MSVC build for Windows as well which as of now only works with static linking.

@mcuee
Copy link
Collaborator Author

mcuee commented Aug 13, 2022

Arduino is using the following patch on top of avrdude 7.0 release to use static linking for Linux/macOS and mingw32.
https://github.com/arduino/avrdude-packing/blob/main/patches/0005-Cmake-always-prefer-static-libraries.patch

Maybe this can be adapted to the latest git so that user can select either static linking or dynamic linking for Linux/,macOS and mingw32/64 (not for MSVC). Take note #962 has been merged, so the changes need to be on top of that.

From 3f5e03457330d3f75887d7e098d875b4d553124b Mon Sep 17 00:00:00 2001
From: Umberto Baldi <[email protected]>
Date: Tue, 3 May 2022 16:59:10 +0200
Subject: [PATCH] CMake always prefer static libraries

Co-authored-by: Martino Facchin <[email protected]>
---
 CMakeLists.txt | 22 ++++++----------------
 1 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 95c89d2..f4546b5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -110,22 +110,12 @@ endif()
 # Detect installed libraries
 # =====================================
 
-# Prefer static libraries over DLLs on Windows
-if(WIN32)
-    set(PREFERRED_LIBELF libelf.a elf)
-    set(PREFERRED_LIBUSB libusb.a usb)
-    set(PREFERRED_LIBUSB_1_0 libusb-1.0.a usb-1.0)
-    set(PREFERRED_LIBHIDAPI libhidapi.a libhidapi-libusb.a libhidapi-hidraw.a hidapi hidapi-libusb hidapi-hidraw)
-    set(PREFERRED_LIBFTDI libftdi.a ftdi)
-    set(PREFERRED_LIBFTDI1 libftdi1.a ftdi1)
-else()
-    set(PREFERRED_LIBELF elf)
-    set(PREFERRED_LIBUSB usb)
-    set(PREFERRED_LIBUSB_1_0 usb-1.0)
-    set(PREFERRED_LIBHIDAPI hidapi hidapi-libusb hidapi-hidraw)
-    set(PREFERRED_LIBFTDI ftdi)
-    set(PREFERRED_LIBFTDI1 ftdi1)
-endif()
+set(PREFERRED_LIBELF libelf.a elf)
+set(PREFERRED_LIBUSB libusb.a usb)
+set(PREFERRED_LIBUSB_1_0 libusb-1.0.a usb-1.0)
+set(PREFERRED_LIBHIDAPI libhidapi.a libhidapi-libusb.a libhidapi-hidraw.a hidapi hidapi-libusb hidapi-hidraw)
+set(PREFERRED_LIBFTDI libftdi.a ftdi)
+set(PREFERRED_LIBFTDI1 libftdi1.a ftdi1)
 
 # -------------------------------------
 # Find libelf
-- 
2.17.1

@mcuee
Copy link
Collaborator Author

mcuee commented Aug 13, 2022

Arduino is using the following patch on top of avrdude 7.0 release to use static linking for Linux/macOS and mingw32. https://github.com/arduino/avrdude-packing/blob/main/patches/0005-Cmake-always-prefer-static-libraries.patch

Maybe this can be adapted to the latest git so that user can select either static linking or dynamic linking for Linux/,macOS and mingw32/64 (not for MSVC). Take note #962 has been merged, so the changes need to be on top of that.

I think the patch may not work as it is already included in the main git tree.
Ref:
https://github.com/avrdudes/avrdude/blob/main/CMakeLists.txt#L116-L136

# =====================================
# Detect installed libraries
# =====================================

if(USE_STATIC_LIBS)
    set(PREFERRED_LIBELF libelf.a elf)
    set(PREFERRED_LIBUSB libusb.a usb)
    set(PREFERRED_LIBUSB_1_0 libusb-1.0.a usb-1.0)
    set(PREFERRED_LIBHIDAPI libhidapi.a libhidapi-libusb.a libhidapi-hidraw.a hidapi hidapi-libusb hidapi-hidraw)
    set(PREFERRED_LIBFTDI libftdi.a ftdi)
    set(PREFERRED_LIBFTDI1 libftdi1.a ftdi1)
    set(PREFERRED_LIBREADLINE libreadline.a)
else()
    set(PREFERRED_LIBELF elf)
    set(PREFERRED_LIBUSB usb)
    set(PREFERRED_LIBUSB_1_0 usb-1.0)
    set(PREFERRED_LIBHIDAPI hidapi hidapi-libusb hidapi-hidraw)
    set(PREFERRED_LIBFTDI ftdi)
    set(PREFERRED_LIBFTDI1 ftdi1)
    set(PREFERRED_LIBREADLINE readline)
endif()

And ineed it does not work.

@mcuee
Copy link
Collaborator Author

mcuee commented Oct 24, 2022

Edit:

The following commands is good to build dynamic link version. This is very good.

$  cmake -G"MSYS Makefiles" -D CMAKE_BUILD_TYPE=RelWithDebInfo -D USE_STATIC_LIBS=OFF -B build_mingw64_shared

$ cmake --build build_mingw64_shared

Build log:

$ rm -rf build_mingw64_shared/

$ cmake -G"MSYS Makefiles" -D CMAKE_BUILD_TYPE=RelWithDebInfo -D USE_STATIC_LIBS=OFF -D CMAKE_VERBOSE_MAKEFILE=ON -B build_mingw64_shared
-- 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_shared

$ cmake --build build_mingw64_shared
...
[100%] Linking C executable avrdude.exe
cd /C/work/avr/avrdude_test/avrdude_main/build_mingw64_shared/src && /C/msys64/mingw64/bin/cmake.exe -E rm -f CMakeFiles/avrdude.dir/objects.a
cd /C/work/avr/avrdude_test/avrdude_main/build_mingw64_shared/src && /C/msys64/mingw64/bin/ar.exe qc CMakeFiles/avrdude.dir/objects.a "CMakeFiles/avrdude.dir/main.c.obj" "CMakeFiles/avrdude.dir/term.c.obj" "CMakeFiles/avrdude.dir/avrintel.c.obj" "CMakeFiles/avrdude.dir/developer_opts.c.obj" "CMakeFiles/avrdude.dir/whereami.c.obj" "CMakeFiles/avrdude.dir/windows.rc.obj"
cd /C/work/avr/avrdude_test/avrdude_main/build_mingw64_shared/src && /C/msys64/mingw64/bin/cc.exe -O2 -g -DNDEBUG -Wl,--whole-archive CMakeFiles/avrdude.dir/objects.a -Wl,--no-whole-archive -o avrdude.exe -Wl,--out-implib,libavrdude.dll.a -Wl,--major-image-version,0,--minor-image-version,0  libavrdude.a -lm /C/msys64/mingw64/lib/libelf.a /C/msys64/mingw64/lib/libusb.dll.a /C/msys64/mingw64/lib/libusb-1.0.dll.a /C/msys64/mingw64/lib/libhid.a /C/msys64/mingw64/lib/libhidapi.dll.a /C/msys64/mingw64/lib/libftdi1.dll.a /C/msys64/mingw64/lib/libreadline.dll.a -lsetupapi -lws2_32 -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32
make[2]: Leaving directory '/c/work/avr/avrdude_test/avrdude_main/build_mingw64_shared'
[100%] Built target avrdude
make[1]: Leaving directory '/c/work/avr/avrdude_test/avrdude_main/build_mingw64_shared'
/C/msys64/mingw64/bin/cmake.exe -E cmake_progress_start /C/work/avr/avrdude_test/avrdude_main/build_mingw64_shared/CMakeFiles 0

$ 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)
        libusb-1.0.dll => /mingw64/bin/libusb-1.0.dll (0x7ffb77920000)
        libhidapi-0.dll => /mingw64/bin/libhidapi-0.dll (0x7ffb968b0000)
        libreadline8.dll => /mingw64/bin/libreadline8.dll (0x7ffb778d0000)
        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)
        libusb-0-1-4.dll => /mingw64/bin/libusb-0-1-4.dll (0x7ffb96860000)
        libtermcap-0.dll => /mingw64/bin/libtermcap-0.dll (0x6ac40000)

@mcuee
Copy link
Collaborator Author

mcuee commented Oct 24, 2022

#962 has been merged and the option to use static lib or dynamic lib was added. But it has not been implemented yet.

@mariusgreuel wrote in the pull request comments.

Note that the CMake files now include the option USE_STATIC_LIBS, which people can use to select either static or dynamic linking. Note, however, that I leave the implementation for somebody else in a separate PR. The current implementation will not work for non-defaults, i.e. statically linking for Linux or dynamically on Windows.

Indeed git main static link build for Linux and macOS failed. This may pose some challenges for Arduino people. Maybe @umbynos wants to take a look. I think the fix may not be too complicated but it does involve changing CMake files.

Failed build log:
https://github.com/mcuee/avrdude/actions/runs/3312632411

@mcuee
Copy link
Collaborator Author

mcuee commented Oct 25, 2022

I will close this one as dynamic link works for MinGW. For MSVC, it probably does not make sense to use dynamic link as of now.
I will create another issue for static link for Linux and macOS, which seems to be more important.

@umbynos
Copy link
Contributor

umbynos commented Oct 26, 2022

Indeed git main static link build for Linux and macOS failed. This may pose some challenges for Arduino people. Maybe @umbynos wants to take a look. I think the fix may not be too complicated but it does involve changing CMake files.

I have a PR ready for when the new version of avrdude comes out to drop the patch for the cmake and to use 65bb41f

@umbynos
Copy link
Contributor

umbynos commented Oct 26, 2022

arduino/avrdude-packing#22

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

No branches or pull requests

2 participants