avrdudes / avrdude

AVRDUDE is a utility to program AVR microcontrollers
GNU General Public License v2.0
734 stars 136 forks source link

VS2019 build using CMake #951

Closed mcuee closed 2 years ago

mcuee commented 2 years ago

I am trying to build avrdude by following the instruction which seems to be very different from other projects I know of (hidapi, libftdi, libuvc, etc). https://github.com/avrdudes/avrdude/wiki/Building-AVRDUDE-for-Windows-using-Visual-Studio

No issues in the first three steps. But I can not find the CMake option USE_EXTERNAL. 4) Set the CMake option USE_EXTERNAL to True by checking the Value checkbox.

Sorry that I may miss something obvious as I have not really used CMake inside VS.

Motivation: I prefer to use dynamic link with libusb, libftdi and hidapi. As a tester I routinely test libusb, libftdi and hidapi git head under different OS and different compilers, so it is much more convenient for me to use dynamic link.

mcuee commented 2 years ago

VS2019 Error messages.

Apparently it is not related to USE_EXTERNAL option, but rather compiler detection. So it is rather strange. Even if I add "-D USE_EXTERNAL=1" as the additional command line option to CMake, it still has the same issues.

1> CMake generation started for configuration: 'x64'.
1> Command line: "C:\WINDOWS\system32\cmd.exe" /c "%SYSTEMROOT%\System32\chcp.com 65001 >NUL && "C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe"  -G "Visual Studio 16 2019" -A x64  -DCMAKE_CONFIGURATION_TYPES:STRING="RelWithDebInfo" -DCMAKE_INSTALL_PREFIX:PATH="C:\work\avr\vsbuild\out\install\x64"  "C:\work\avr\vsbuild" 2>&1"
1> Working directory: C:\work\avr\vsbuild\out\build\x64
1> [CMake] -- Selecting Windows SDK version  to target Windows 10.0.19043.
1> [CMake] -- The C compiler identification is unknown
1> [CMake] -- The CXX compiler identification is unknown
1> [CMake] CMake Error at C:\work\avr\vsbuild\CMakeLists.txt:24 (project):
1> [CMake]   No CMAKE_C_COMPILER could be found.
1> [CMake] 
1> [CMake] 
1> [CMake] 
1> [CMake] CMake Error at C:\work\avr\vsbuild\CMakeLists.txt:24 (project):
1> [CMake]   No CMAKE_CXX_COMPILER could be found.
1> [CMake] 
1> [CMake] 
1> [CMake] 
1> [CMake] -- Configuring incomplete, errors occurred!
1> [CMake] See also "C:/work/avr/vsbuild/out/build/x64/CMakeFiles/CMakeOutput.log".
1> [CMake] See also "C:/work/avr/vsbuild/out/build/x64/CMakeFiles/CMakeError.log".
1> 'C:\WINDOWS\system32\cmd.exe' '/c "%SYSTEMROOT%\System32\chcp.com 65001 >NUL && "C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe"  -G "Visual Studio 16 2019" -A x64  -DCMAKE_CONFIGURATION_TYPES:STRING="RelWithDebInfo" -DCMAKE_INSTALL_PREFIX:PATH="C:\work\avr\vsbuild\out\install\x64"  "C:\work\avr\vsbuild" 2>&1"' execution failed with error: ''C:\WINDOWS\system32\cmd.exe' '/c "%SYSTEMROOT%\System32\chcp.com 65001 >NUL && "C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe"  -G "Visual Studio 16 2019" -A x64  -DCMAKE_CONFIGURATION_TYPES:STRING="RelWithDebInfo" -DCMAKE_INSTALL_PREFIX:PATH="C:\work\avr\vsbuild\out\install\x64"  "C:\work\avr\vsbuild" 2>&1"' returned with exit code: 1'.
mcuee commented 2 years ago

Looks like my VS2019 installation is broken. I will try again later.

mcuee commented 2 years ago

Now it is a bit better. Need to figure out the installation of flex and bison.

1> CMake generation started for configuration: 'x64'.
1> Command line: "C:\WINDOWS\system32\cmd.exe" /c "%SYSTEMROOT%\System32\chcp.com 65001 >NUL && "C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe"  -G "Visual Studio 16 2019" -A x64  -DCMAKE_CONFIGURATION_TYPES:STRING="RelWithDebInfo" -DCMAKE_INSTALL_PREFIX:PATH="C:\work\avr\vsbuild\out\install\x64" -D USE_EXTERNAL=1 "C:\work\avr\vsbuild" 2>&1"
1> Working directory: C:\work\avr\vsbuild\out\build\x64
1> [CMake] -- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19043.
1> [CMake] -- The C compiler identification is MSVC 19.29.30143.0
1> [CMake] -- The CXX compiler identification is MSVC 19.29.30143.0
1> [CMake] -- Detecting C compiler ABI info
1> [CMake] -- Detecting C compiler ABI info - done
1> [CMake] -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped
1> [CMake] -- Detecting C compile features
1> [CMake] -- Detecting C compile features - done
1> [CMake] -- Detecting CXX compiler ABI info
1> [CMake] -- Detecting CXX compiler ABI info - done
1> [CMake] -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped
1> [CMake] -- Detecting CXX compile features
1> [CMake] -- Detecting CXX compile features - done
1> [CMake] -- Found Git: C:/Program Files/Git/cmd/git.exe (found version "2.35.3.windows.1") 
1> [CMake] -- Could NOT find FLEX (missing: FLEX_EXECUTABLE) 
1> [CMake] CMake Error at C:\work\avr\vsbuild\CMakeLists.txt:93 (message):
1> [CMake]   This CMake project requires 'flex', which is not installed on your system.
1> [CMake] 
1> [CMake] 
1> [CMake] CMake Error at C:\work\avr\vsbuild\CMakeLists.txt:105 (message):
1> [CMake]   This CMake project requires 'bison', 'yacc', or 'byacc', which is not
1> [CMake]   installed on your system.
1> [CMake] 
1> [CMake] 
1> [CMake] -- Fetching external libraries, please wait...
1> [CMake] -- Using external library 'libelf'
1> [CMake] -- Using external library 'libusb'
1> [CMake] -- Using external library 'libhidapi'
1> [CMake] -- Using external library 'libftdi'
1> [CMake] CMake Error at src/CMakeLists.txt:23 (FLEX_TARGET):
1> [CMake]   Unknown CMake command "FLEX_TARGET".
1> [CMake] 
1> [CMake] 
1> [CMake] -- Configuring incomplete, errors occurred!
1> [CMake] See also "C:/work/avr/vsbuild/out/build/x64/CMakeFiles/CMakeOutput.log".
1> [CMake] See also "C:/work/avr/vsbuild/out/build/x64/CMakeFiles/CMakeError.log".
mcuee commented 2 years ago

After running choco install winflexbison3 it seems to be okay now.

1> CMake generation started for configuration: 'x64'.
1> Command line: "C:\WINDOWS\system32\cmd.exe" /c "%SYSTEMROOT%\System32\chcp.com 65001 >NUL && "C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe"  -G "Visual Studio 16 2019" -A x64  -DCMAKE_CONFIGURATION_TYPES:STRING="RelWithDebInfo" -DCMAKE_INSTALL_PREFIX:PATH="C:\work\avr\vsbuild\out\install\x64" -D USE_EXTERNAL=1 "C:\work\avr\vsbuild" 2>&1"
1> Working directory: C:\work\avr\vsbuild\out\build\x64
1> [CMake] -- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19043.
1> [CMake] -- Found FLEX: C:/ProgramData/chocolatey/bin/win_flex.exe (found version "2.6.4") 
1> [CMake] -- Found BISON: C:/ProgramData/chocolatey/bin/win_bison.exe (found version "3.7.4")
1> [CMake] -- Fetching external libraries, please wait...
1> [CMake] -- Using external library 'libelf'
1> [CMake] -- Using external library 'libusb'
1> [CMake] -- Using external library 'libhidapi'
1> [CMake] -- Using external library 'libftdi'
1> [CMake] -- Configuration summary:
1> [CMake] -- ----------------------
1> [CMake] -- DO HAVE    libelf
1> [CMake] -- DO HAVE    libusb
1> [CMake] -- DON'T HAVE libusb_1_0
1> [CMake] -- DO HAVE    libhidapi
1> [CMake] -- DO HAVE    libftdi
1> [CMake] -- DON'T HAVE libftdi1
1> [CMake] -- DISABLED   doc
1> [CMake] -- DISABLED   parport
1> [CMake] -- DISABLED   linuxgpio
1> [CMake] -- DISABLED   linuxspi
1> [CMake] -- ----------------------
1> [CMake] -- Configuring done
1> [CMake] -- Generating done
1> [CMake] -- Build files have been written to: C:/work/avr/vsbuild/out/build/x64
1> Extracted CMake variables.
1> Extracted source files and headers.
1> Extracted code model.
1> Extracted toolchain configurations.
1> Extracted includes paths.
1> CMake generation finished.
mcuee commented 2 years ago

But the build process failed. Something is still wrong. src\bitbang.c and src\serbb_posix.c need to be excluded.

Click for full build log ``` >------ Build All started: Project: vsbuild, Configuration: x64 ------ Microsoft (R) Build Engine version 16.11.2+f32259642 for .NET Framework Copyright (C) Microsoft Corporation. All rights reserved. Checking Build System Building Custom Rule C:/work/avr/vsbuild/out/build/x64/_deps/libelf-src/CMakeLists.txt 32.fsize.c 32.getehdr.c 32.getphdr.c 32.getshdr.c 32.newehdr.c 32.newphdr.c 32.xlatetof.c 64.xlatetof.c assert.c begin.c checksum.c cntl.c cook.c data.c end.c errmsg.c errno.c fill.c flag.c gelfehdr.c Generating Code... Compiling... gelfphdr.c gelfshdr.c gelftrans.c getarhdr.c getaroff.c getarsym.c getbase.c getdata.c getident.c getscn.c hash.c input.c kind.c memset.c ndxscn.c newdata.c newscn.c next.c nextscn.c nlist.c Generating Code... Compiling... opt.delscn.c rand.c rawdata.c rawfile.c strptr.c swap64.c update.c verdef_32_tof.c verdef_32_tom.c verdef_64_tof.c verdef_64_tom.c version.c x.elfext.c x.movscn.c x.remscn.c Generating Code... libelf.vcxproj -> C:\work\avr\vsbuild\out\build\x64\_deps\libelf-build\RelWithDebInfo\libelf.lib Building Custom Rule C:/work/avr/vsbuild/out/build/x64/_deps/libftdi-src/CMakeLists.txt ftdi.cpp C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\vector(1245,1): warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\vector(1275): message : see reference to function template instantiation 'void std::vector>::_Resize_reallocate<_Ty2>(const unsigned __int64,const _Ty2 &)' being compiled [C:\work\avr\vsbuild\out\build\x64\_deps\libftdi-build\libftdi.vcxproj] with [ _Ty2=std::_Value_init_tag ] C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\vector(1275): message : see reference to function template instantiation 'void std::vector>::_Resize_reallocate<_Ty2>(const unsigned __int64,const _Ty2 &)' being compiled [C:\work\avr\vsbuild\out\build\x64\_deps\libftdi-build\libftdi.vcxproj] with [ _Ty2=std::_Value_init_tag ] C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\vector(1290): message : see reference to function template instantiation 'void std::vector>::_Resize(const unsigned __int64,const _Ty2 &)' being compiled [C:\work\avr\vsbuild\out\build\x64\_deps\libftdi-build\libftdi.vcxproj] with [ _Ty2=std::_Value_init_tag ] C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\vector(1290): message : see reference to function template instantiation 'void std::vector>::_Resize(const unsigned __int64,const _Ty2 &)' being compiled [C:\work\avr\vsbuild\out\build\x64\_deps\libftdi-build\libftdi.vcxproj] with [ _Ty2=std::_Value_init_tag ] C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\vector(1288): message : while compiling class template member function 'void std::vector>::resize(const unsigned __int64)' [C:\work\avr\vsbuild\out\build\x64\_deps\libftdi-build\libftdi.vcxproj] C:\work\avr\vsbuild\out\build\x64\_deps\libftdi-src\src\libwinftdi.h(223): message : see reference to function template instantiation 'void std::vector>::resize(const unsigned __int64)' being compiled [C:\work\avr\vsbuild\out\build\x64\_deps\libftdi-build\libftdi.vcxproj] C:\work\avr\vsbuild\out\build\x64\_deps\libftdi-src\src\libwinftdi.h(238): message : see reference to class template instantiation 'std::vector>' being compiled [C:\work\avr\vsbuild\out\build\x64\_deps\libftdi-build\libftdi.vcxproj] libftdi.vcxproj -> C:\work\avr\vsbuild\out\build\x64\_deps\libftdi-build\RelWithDebInfo\libftdi.lib Building Custom Rule C:/work/avr/vsbuild/out/build/x64/_deps/libhidapi-src/CMakeLists.txt hid.c libhidapi.vcxproj -> C:\work\avr\vsbuild\out\build\x64\_deps\libhidapi-build\RelWithDebInfo\libhidapi.lib Building Custom Rule C:/work/avr/vsbuild/out/build/x64/_deps/libusb-src/CMakeLists.txt descriptors.c error.c registry.c usb.c Generating Code... windows.cpp C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\vector(788,1): warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\vector(747): message : see reference to function template instantiation 'std::unique_ptr> *std::vector>,std::allocator>>>::_Emplace_reallocate<_Ty>(std::unique_ptr> *const ,_Ty &&)' being compiled [C:\work\avr\vsbuild\out\build\x64\_deps\libusb-build\libusb.vcxproj] with [ _Ty=std::unique_ptr> ] C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\vector(747): message : see reference to function template instantiation 'std::unique_ptr> *std::vector>,std::allocator>>>::_Emplace_reallocate<_Ty>(std::unique_ptr> *const ,_Ty &&)' being compiled [C:\work\avr\vsbuild\out\build\x64\_deps\libusb-build\libusb.vcxproj] with [ _Ty=std::unique_ptr> ] C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\vector(761): message : see reference to function template instantiation 'void std::vector>,std::allocator>>>::emplace_back>>(std::unique_ptr> &&)' being compiled [C:\work\avr\vsbuild\out\build\x64\_deps\libusb-build\libusb.vcxproj] C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\vector(759): message : while compiling class template member function 'void std::vector>,std::allocator>>>::push_back(_Ty &&)' [C:\work\avr\vsbuild\out\build\x64\_deps\libusb-build\libusb.vcxproj] with [ _Ty=std::unique_ptr> ] C:\work\avr\vsbuild\out\build\x64\_deps\libusb-src\src\libwinusb.h(1263): message : see reference to function template instantiation 'void std::vector>,std::allocator>>>::push_back(_Ty &&)' being compiled [C:\work\avr\vsbuild\out\build\x64\_deps\libusb-build\libusb.vcxproj] with [ _Ty=std::unique_ptr> ] C:\work\avr\vsbuild\out\build\x64\_deps\libusb-src\src\libwinusb.h(1297): message : see reference to class template instantiation 'std::vector>,std::allocator>>>' being compiled [C:\work\avr\vsbuild\out\build\x64\_deps\libusb-build\libusb.vcxproj] libusb.vcxproj -> C:\work\avr\vsbuild\out\build\x64\_deps\libusb-build\RelWithDebInfo\libusb.lib [FLEX][Parser] Building scanner with win_flex 2.6.4 [BISON][Parser] Building parser with bison 3.7.4 Building Custom Rule C:/work/avr/vsbuild/src/CMakeLists.txt arduino.c avr.c avr910.c avrftdi.c avrftdi_tpi.c avrpart.c bitbang.c C:\work\avr\vsbuild\src\bitbang.c(61,17): error C2065: 'SIGALRM': undeclared identifier C:\work\avr\vsbuild\src\bitbang.c(98,20): error C2079: 'itv' uses undefined struct 'itimerval' C:\work\avr\vsbuild\src\bitbang.c(105,38): error C2065: 'SIGALRM': undeclared identifier C:\work\avr\vsbuild\src\bitbang.c(116,7): error C2224: left of '.it_value' must have struct/union type C:\work\avr\vsbuild\src\bitbang.c(117,7): error C2224: left of '.it_value' must have struct/union type C:\work\avr\vsbuild\src\bitbang.c(118,7): error C2224: left of '.it_interval' must have struct/union type C:\work\avr\vsbuild\src\bitbang.c(118,32): error C2224: left of '.it_interval' must have struct/union type C:\work\avr\vsbuild\src\bitbang.c(119,12): warning C4013: 'setitimer' undefined; assuming extern returning int C:\work\avr\vsbuild\src\bitbang.c(119,24): error C2065: 'ITIMER_REAL': undeclared identifier C:\work\avr\vsbuild\src\bitbang.c(122,7): error C2224: left of '.it_value' must have struct/union type C:\work\avr\vsbuild\src\bitbang.c(122,29): error C2224: left of '.it_value' must have struct/union type C:\work\avr\vsbuild\src\bitbang.c(123,24): error C2065: 'ITIMER_REAL': undeclared identifier buspirate.c butterfly.c config.c confwin.c crc16.c dfu.c fileio.c flip1.c flip2.c ft245r.c jtagmkI.c jtagmkII.c jtag3.c Generating Code... Compiling... linuxgpio.c linuxspi.c lists.c micronucleus.c par.c pgm.c pgm_type.c pickit2.c pindefs.c ppi.c ppiwin.c serbb_posix.c C:\work\avr\vsbuild\src\serbb_posix.c(36,1): fatal error C1083: Cannot open include file: 'sys/ioctl.h': No such file or directory serbb_win32.c ser_avrdoper.c ser_posix.c C:\work\avr\vsbuild\src\ser_posix.c(36,1): fatal error C1083: Cannot open include file: 'sys/ioctl.h': No such file or directory ser_win32.c serialupdi.c stk500.c stk500v2.c stk500generic.c Generating Code... Compiling... teensy.c updi_link.c updi_nvm.c updi_readwrite.c updi_state.c usbasp.c usb_hidapi.c usb_libusb.c usbtiny.c update.c wiring.c xbee.c lexer.c config_gram.c C:\work\avr\vsbuild\out\build\x64\config_gram.y(1548,17): warning C4013: 'strtok_r' undefined; assuming extern returning int C:\work\avr\vsbuild\out\build\x64\config_gram.y(1548,46): warning C4047: '=': 'char *' differs in levels of indirection from 'int' C:\work\avr\vsbuild\out\build\x64\config_gram.y(1625,37): warning C4047: '=': 'char *' differs in levels of indirection from 'int' Generating Code... Build All failed. ```
mcuee commented 2 years ago

Strange, removing the two files and then adding them back see to fix the issue.

>------ Build All started: Project: vsbuild, Configuration: x64 ------
  Microsoft (R) Build Engine version 16.11.2+f32259642 for .NET Framework
  Copyright (C) Microsoft Corporation. All rights reserved.

    libelf.vcxproj -> C:\work\avr\vsbuild\out\build\x64\_deps\libelf-build\RelWithDebInfo\libelf.lib
    libftdi.vcxproj -> C:\work\avr\vsbuild\out\build\x64\_deps\libftdi-build\RelWithDebInfo\libftdi.lib
    libhidapi.vcxproj -> C:\work\avr\vsbuild\out\build\x64\_deps\libhidapi-build\RelWithDebInfo\libhidapi.lib
    libusb.vcxproj -> C:\work\avr\vsbuild\out\build\x64\_deps\libusb-build\RelWithDebInfo\libusb.lib
    serbb_posix.c
    libavrdude.vcxproj -> C:\work\avr\vsbuild\out\build\x64\src\RelWithDebInfo\libavrdude.lib
    avrdude.vcxproj -> C:\work\avr\vsbuild\out\build\x64\src\RelWithDebInfo\avrdude.exe

Build All succeeded.
mcuee commented 2 years ago

Restart the whole thing again and everything is okay.

1> CMake generation started for configuration: 'x64-Debug'.
1> Command line: "C:\WINDOWS\system32\cmd.exe" /c "%SYSTEMROOT%\System32\chcp.com 65001 >NUL && "C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe"  -G "Ninja"  -DCMAKE_BUILD_TYPE:STRING="Debug" -DCMAKE_INSTALL_PREFIX:PATH="C:\work\avr\vs2019build\out\install\x64-Debug" -DUSE_EXTERNAL:BOOL="True" -DCMAKE_C_COMPILER:FILEPATH="C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe" -DCMAKE_CXX_COMPILER:FILEPATH="C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe"  -DCMAKE_MAKE_PROGRAM="C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\Ninja\ninja.exe" "C:\work\avr\vs2019build" 2>&1"
1> Working directory: C:\work\avr\vs2019build\out\build\x64-Debug
1> [CMake] -- Fetching external libraries, please wait...
1> [CMake] -- Using external library 'libelf'
1> [CMake] -- Using external library 'libusb'
1> [CMake] -- Using external library 'libhidapi'
1> [CMake] -- Using external library 'libftdi'
1> [CMake] -- Configuration summary:
1> [CMake] -- ----------------------
1> [CMake] -- DO HAVE    libelf
1> [CMake] -- DO HAVE    libusb
1> [CMake] -- DON'T HAVE libusb_1_0
1> [CMake] -- DO HAVE    libhidapi
1> [CMake] -- DO HAVE    libftdi
1> [CMake] -- DON'T HAVE libftdi1
1> [CMake] -- DISABLED   doc
1> [CMake] -- DISABLED   parport
1> [CMake] -- DISABLED   linuxgpio
1> [CMake] -- DISABLED   linuxspi
1> [CMake] -- ----------------------
1> [CMake] -- Configuring done
1> [CMake] -- Generating done
1> [CMake] -- Build files have been written to: C:/work/avr/vs2019build/out/build/x64-Debug
1> Extracted CMake variables.
1> Extracted source files and headers.
1> Extracted code model.
1> Extracted toolchain configurations.
1> Extracted includes paths.
1> CMake generation finished.

>------ Build All started: Project: vs2019build, Configuration: x64-Debug ------
  [1/131] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\32.getshdr.c.obj
  [2/131] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\cook.c.obj
  [3/131] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\assert.c.obj
  [4/131] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\cntl.c.obj
  [5/131] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\begin.c.obj
  [6/131] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\errmsg.c.obj
  [7/131] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\64.xlatetof.c.obj
  [8/131] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\32.getehdr.c.obj
  [9/131] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\32.xlatetof.c.obj
  [10/131] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\32.newehdr.c.obj
  [11/131] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\checksum.c.obj
  [12/131] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\32.getphdr.c.obj
  [13/131] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\32.fsize.c.obj
  [14/131] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\32.newphdr.c.obj
  [15/131] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\data.c.obj
  [16/131] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\getaroff.c.obj
  [17/131] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\fill.c.obj
  [18/131] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\gelfphdr.c.obj
  [19/131] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\getdata.c.obj
  [20/131] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\flag.c.obj
  [21/131] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\gelfshdr.c.obj
  [22/131] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\getarsym.c.obj
  [23/131] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\end.c.obj
  [24/131] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\getarhdr.c.obj
  [25/131] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\getbase.c.obj
  [26/131] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\errno.c.obj
  [27/131] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\memset.c.obj
  [28/131] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\gelfehdr.c.obj
  [29/131] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\gelftrans.c.obj
  [30/131] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\getident.c.obj
  [31/131] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\kind.c.obj
  [32/131] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\getscn.c.obj
  [33/131] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\newscn.c.obj
  [34/131] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\hash.c.obj
  [35/131] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\ndxscn.c.obj
  [36/131] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\newdata.c.obj
  [37/131] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\nextscn.c.obj
  [38/131] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\input.c.obj
  [39/131] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\next.c.obj
  [40/131] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\nlist.c.obj
  [41/131] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\rawdata.c.obj
  [42/131] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\opt.delscn.c.obj
  [43/131] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\rand.c.obj
  [44/131] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\strptr.c.obj
  [45/131] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\swap64.c.obj
  [46/131] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\x.movscn.c.obj
  [47/131] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\x.remscn.c.obj
  [48/131] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\rawfile.c.obj
  [49/131] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\verdef_32_tom.c.obj
  [50/131] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\version.c.obj
  [51/131] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\verdef_64_tom.c.obj
  [52/131] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\update.c.obj
  [53/131] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\verdef_32_tof.c.obj
  [54/131] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\x.elfext.c.obj
  [55/131] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\verdef_64_tof.c.obj
  [56/131] Building C object _deps\libusb-build\CMakeFiles\libusb.dir\src\usb.c.obj
  [57/131] Building C object _deps\libusb-build\CMakeFiles\libusb.dir\src\descriptors.c.obj
  [58/131] Linking C static library _deps\libelf-build\libelf.lib
  [59/131] Building CXX object _deps\libftdi-build\CMakeFiles\libftdi.dir\src\ftdi.cpp.obj
  [60/131] Linking CXX static library _deps\libftdi-build\libftdi.lib
  [61/131] Building CXX object _deps\libusb-build\CMakeFiles\libusb.dir\src\windows.cpp.obj
  [62/131] Building C object _deps\libusb-build\CMakeFiles\libusb.dir\src\error.c.obj
  [63/131] Building C object _deps\libhidapi-build\CMakeFiles\libhidapi.dir\src\hid.c.obj
  [64/131] Building C object _deps\libusb-build\CMakeFiles\libusb.dir\src\registry.c.obj
  [65/131] Linking C static library _deps\libhidapi-build\libhidapi.lib
  [66/131] Linking CXX static library _deps\libusb-build\libusb.lib
  [67/131] [FLEX][Parser] Building scanner with win_flex 2.6.4
  [68/131] [BISON][Parser] Building parser with bison 3.7.4
  [69/131] Building C object src\CMakeFiles\libavrdude.dir\crc16.c.obj
  [70/131] Building C object src\CMakeFiles\libavrdude.dir\arduino.c.obj
  [71/131] Building C object src\CMakeFiles\libavrdude.dir\config.c.obj
  [72/131] Building C object src\CMakeFiles\libavrdude.dir\dfu.c.obj
  [73/131] Building C object src\CMakeFiles\libavrdude.dir\avr910.c.obj
  [74/131] Building C object src\CMakeFiles\libavrdude.dir\buspirate.c.obj
  [75/131] Building C object src\CMakeFiles\libavrdude.dir\avr.c.obj
  [76/131] Building C object src\CMakeFiles\libavrdude.dir\avrftdi_tpi.c.obj
  [77/131] Building C object src\CMakeFiles\libavrdude.dir\avrftdi.c.obj
  [78/131] Building C object src\CMakeFiles\libavrdude.dir\avrpart.c.obj
  [79/131] Building C object src\CMakeFiles\libavrdude.dir\butterfly.c.obj
  [80/131] Building C object src\CMakeFiles\libavrdude.dir\fileio.c.obj
  [81/131] Building C object src\CMakeFiles\libavrdude.dir\flip2.c.obj
  [82/131] Building C object src\CMakeFiles\libavrdude.dir\lists.c.obj
  [83/131] Building C object src\CMakeFiles\libavrdude.dir\linuxgpio.c.obj
  [84/131] Building C object src\CMakeFiles\libavrdude.dir\flip1.c.obj
  [85/131] Building C object src\CMakeFiles\libavrdude.dir\ft245r.c.obj
  [86/131] Building C object src\CMakeFiles\libavrdude.dir\linuxspi.c.obj
  [87/131] Building C object src\CMakeFiles\libavrdude.dir\jtagmkI.c.obj
  [88/131] Building C object src\CMakeFiles\libavrdude.dir\jtag3.c.obj
  [89/131] Building C object src\CMakeFiles\libavrdude.dir\serbb_posix.c.obj
  [90/131] Building C object src\CMakeFiles\libavrdude.dir\pindefs.c.obj
  [91/131] Building C object src\CMakeFiles\libavrdude.dir\micronucleus.c.obj
  [92/131] Building C object src\CMakeFiles\libavrdude.dir\ppi.c.obj
  [93/131] Building C object src\CMakeFiles\libavrdude.dir\ser_posix.c.obj
  [94/131] Building C object src\CMakeFiles\libavrdude.dir\jtagmkII.c.obj
  [95/131] Building C object src\CMakeFiles\libavrdude.dir\pgm_type.c.obj
  [96/131] Building C object src\CMakeFiles\libavrdude.dir\par.c.obj
  [97/131] Building C object src\CMakeFiles\libavrdude.dir\pgm.c.obj
  [98/131] Building C object src\CMakeFiles\libavrdude.dir\ser_avrdoper.c.obj
  [99/131] Building C object src\CMakeFiles\libavrdude.dir\ppiwin.c.obj
  [100/131] Building C object src\CMakeFiles\libavrdude.dir\bitbang.c.obj
  [101/131] Building C object src\CMakeFiles\libavrdude.dir\stk500.c.obj
  [102/131] Building C object src\CMakeFiles\libavrdude.dir\serialupdi.c.obj
  [103/131] Building C object src\CMakeFiles\libavrdude.dir\confwin.c.obj
  [104/131] Building C object src\CMakeFiles\libavrdude.dir\stk500v2.c.obj
  [105/131] Building C object src\CMakeFiles\libavrdude.dir\stk500generic.c.obj
  [106/131] Building C object src\CMakeFiles\libavrdude.dir\updi_link.c.obj
  [107/131] Building C object src\CMakeFiles\libavrdude.dir\teensy.c.obj
  [108/131] Building C object src\CMakeFiles\libavrdude.dir\updi_nvm.c.obj
  [109/131] Building C object src\CMakeFiles\libavrdude.dir\updi_readwrite.c.obj
  [110/131] Building C object src\CMakeFiles\libavrdude.dir\updi_state.c.obj
  [111/131] Building C object src\CMakeFiles\libavrdude.dir\usb_libusb.c.obj
  [112/131] Building C object src\CMakeFiles\libavrdude.dir\update.c.obj
  [113/131] Building C object src\CMakeFiles\libavrdude.dir\usb_hidapi.c.obj
  [114/131] Building C object src\CMakeFiles\libavrdude.dir\usbtiny.c.obj
  [115/131] Building C object src\CMakeFiles\libavrdude.dir\wiring.c.obj
  [116/131] Building C object src\CMakeFiles\libavrdude.dir\usbasp.c.obj
  [117/131] Building C object src\CMakeFiles\libavrdude.dir\xbee.c.obj
  [118/131] Building C object src\CMakeFiles\libavrdude.dir\__\lexer.c.obj
  [119/131] Building C object src\CMakeFiles\libavrdude.dir\__\config_gram.c.obj
  [120/131] Building C object src\CMakeFiles\avrdude.dir\main.c.obj
  [121/131] Building C object src\CMakeFiles\libavrdude.dir\serbb_win32.c.obj
  [122/131] Building RC object src\CMakeFiles\avrdude.dir\windows.rc.res
  Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384

  Copyright (C) Microsoft Corporation.  All rights reserved.

  [123/131] Building C object src\CMakeFiles\avrdude.dir\term.c.obj
  [124/131] Building C object src\CMakeFiles\libavrdude.dir\pickit2.c.obj
  [125/131] Building C object src\CMakeFiles\libavrdude.dir\ser_win32.c.obj
  [126/131] Building CXX object src\CMakeFiles\avrdude.dir\msvc\usleep.cpp.obj
  [127/131] Linking CXX static library src\libavrdude.lib
  [128/131] Building C object src\CMakeFiles\avrdude.dir\msvc\gettimeofday.c.obj
  [129/131] Building C object src\CMakeFiles\avrdude.dir\msvc\getopt.c.obj
  [130/131] Building C object src\CMakeFiles\avrdude.dir\whereami.c.obj
  [131/131] Linking CXX executable src\avrdude.exe

Build All succeeded.
mcuee commented 2 years ago

But once the option to build sharedlib, the build will fail. Looks like the issue is the same as MSYS2 MinGW32/64 build. https://github.com/avrdudes/avrdude/issues/952#issuecomment-1120810691