mcuee / libusb-win32

libusb-win32 project official github repo
179 stars 49 forks source link

Libusb vs2019 #40

Closed dontech closed 1 year ago

dontech commented 1 year ago

These are the first updates to support vs2019 and the EWDK

After this pull, then next will update the build system so we can actually do releases.

The EWDK used is not the latest, so we can still support win7->win11

@tormodvolden and @mcuee please review.

mcuee commented 1 year ago

I am using VS2022 with latest updates. I have an issue building the driver as it says that 'Windows7' is not a supported OS Version. Maybe I need to use another VS2019 installation tomorrow.

Rebuild started...
1>------ Rebuild All started: Project: install-filter-win, Configuration: Debug x64 ------
2>------ Rebuild All started: Project: install-filter, Configuration: Debug x64 ------
3>------ Rebuild All started: Project: testlibusb-win, Configuration: Debug x64 ------
4>------ Rebuild All started: Project: libusb-dll, Configuration: Debug x64 ------
5>------ Rebuild All started: Project: libusb0, Configuration: Debug x64 ------
5>C:\Program Files (x86)\Windows Kits\10\build\10.0.22621.0\WindowsDriver.common.targets(238,5): error :  'Windows7' is not a supported OS Version
5>Done building project "libusb0.vcxproj" -- FAILED.
2>error.c
3>testlibusb_win.c
4>descriptors.c
1>error.c
2>install.c
4>error.c
1>install.c
3>LINK : fatal error LNK1104: cannot open file '..\x64\Debug\libusb0.lib'
3>Done building project "testlibusb-win.vcxproj" -- FAILED.
4>install.c
2>install_filter.c
1>install_filter_win.c
4>registry.c
2>registry.c
1>registry.c
4>usb.c
2>Generating Code...
1>Generating Code...
4>windows.c
2>install-filter.vcxproj -> C:\work\libusb\libusb-win32\libusbwin32_vs2019\libusb\projects\vs2019\x64\Debug\install-filter.exe
1>install-filter-win.vcxproj -> C:\work\libusb\libusb-win32\libusbwin32_vs2019\libusb\projects\vs2019\x64\Debug\install-filter-win.exe
4>Generating Code...
4>   Creating library C:\work\libusb\libusb-win32\libusbwin32_vs2019\libusb\projects\vs2019\x64\Debug\libusb0.lib and object C:\work\libusb\libusb-win32\libusbwin32_vs2019\libusb\projects\vs2019\x64\Debug\libusb0.exp
4>libusb-dll.vcxproj -> C:\work\libusb\libusb-win32\libusbwin32_vs2019\libusb\projects\vs2019\x64\Debug\libusb0.dll
6>------ Rebuild All started: Project: testlibusb, Configuration: Debug x64 ------
6>testlibusb.c
6>testlibusb.vcxproj -> C:\work\libusb\libusb-win32\libusbwin32_vs2019\libusb\projects\vs2019\x64\Debug\testlibusb.exe
========== Rebuild All: 4 succeeded, 2 failed, 0 skipped ==========
========== Rebuild started at 10:15 pm and took 04.114 seconds ==========
mcuee commented 1 year ago

ARM64 build is a bit strange.

Looks like I need to install the Spectre-mitigated libraries. Then the configuration of the test program is not right.

Rebuild started...
1>------ Skipped Rebuild All: Project: install-filter-win, Configuration: Debug Win32 ------
1>Project not selected to build for this solution configuration 
2>------ Skipped Rebuild All: Project: install-filter, Configuration: Debug Win32 ------
2>Project not selected to build for this solution configuration 
3>------ Skipped Rebuild All: Project: testlibusb-win, Configuration: Debug Win32 ------
3>Project not selected to build for this solution configuration 
4>------ Rebuild All started: Project: libusb-dll, Configuration: Debug ARM64 ------
5>------ Rebuild All started: Project: libusb0, Configuration: Debug ARM64 ------
5>Building 'libusb0' with toolset 'WindowsKernelModeDriver10.0' and the 'Desktop' target platform.
5>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(504,5): error MSB8040: Spectre-mitigated libraries are required for this project. Install them from the Visual Studio installer (Individual components tab) for any toolsets and architectures being used. Learn more: https://aka.ms/Ofhn4c
5>Done building project "libusb0.vcxproj" -- FAILED.
4>descriptors.c
4>error.c
4>install.c
4>registry.c
4>usb.c
4>windows.c
4>Generating Code...
4>   Creating library C:\work\libusb\libusb-win32\libusbwin32_vs2019\libusb\projects\vs2019\ARM64\Debug\libusb0.lib and object C:\work\libusb\libusb-win32\libusbwin32_vs2019\libusb\projects\vs2019\ARM64\Debug\libusb0.exp
4>libusb-dll.vcxproj -> C:\work\libusb\libusb-win32\libusbwin32_vs2019\libusb\projects\vs2019\ARM64\Debug\libusb0.dll
6>------ Skipped Rebuild All: Project: testlibusb, Configuration: Debug Win32 ------
6>Project not selected to build for this solution configuration 
========== Rebuild All: 1 succeeded, 1 failed, 4 skipped ==========
========== Rebuild started at 10:20 pm and took 02.681 seconds ==========
mcuee commented 1 year ago

Win32 build. Maybe I need to upgrade my WDK installation, or I should try the EWDK instead. https://learn.microsoft.com/en-us/windows-hardware/drivers/download-the-wdk

Rebuild started...
1>------ Rebuild All started: Project: install-filter-win, Configuration: Debug Win32 ------
2>------ Rebuild All started: Project: install-filter, Configuration: Debug Win32 ------
3>------ Rebuild All started: Project: testlibusb-win, Configuration: Debug Win32 ------
4>------ Rebuild All started: Project: libusb-dll, Configuration: Debug Win32 ------
5>------ Rebuild All started: Project: libusb0, Configuration: Debug Win32 ------
5>C:\Program Files (x86)\Windows Kits\10\build\10.0.22621.0\WindowsDriver.common.targets(235,5): error :  'Win32' is not a valid architecture for Kernel mode drivers or UMDF drivers
5>Done building project "libusb0.vcxproj" -- FAILED.
2>error.c
1>error.c
3>testlibusb_win.c
4>descriptors.c
4>error.c
1>install.c
2>install.c
4>install.c
1>install_filter_win.c
2>install_filter.c
3>LINK : fatal error LNK1104: cannot open file '..\Debug\libusb0.lib'
3>Done building project "testlibusb-win.vcxproj" -- FAILED.
2>registry.c
4>registry.c
1>registry.c
4>usb.c
2>Generating Code...
1>Generating Code...
4>windows.c
2>install-filter.vcxproj -> C:\work\libusb\libusb-win32\libusbwin32_vs2019\libusb\projects\vs2019\Debug\install-filter.exe
1>install-filter-win.vcxproj -> C:\work\libusb\libusb-win32\libusbwin32_vs2019\libusb\projects\vs2019\Debug\install-filter-win.exe
4>Generating Code...
4>   Creating library C:\work\libusb\libusb-win32\libusbwin32_vs2019\libusb\projects\vs2019\Debug\libusb0.lib and object C:\work\libusb\libusb-win32\libusbwin32_vs2019\libusb\projects\vs2019\Debug\libusb0.exp
4>libusb-dll.vcxproj -> C:\work\libusb\libusb-win32\libusbwin32_vs2019\libusb\projects\vs2019\Debug\libusb0.dll
6>------ Rebuild All started: Project: testlibusb, Configuration: Debug Win32 ------
6>testlibusb.c
6>testlibusb.vcxproj -> C:\work\libusb\libusb-win32\libusbwin32_vs2019\libusb\projects\vs2019\Debug\testlibusb.exe
========== Rebuild All: 4 succeeded, 2 failed, 0 skipped ==========
========== Rebuild started at 10:23 pm and took 04.788 seconds ==========
dontech commented 1 year ago

I am using VS2022 with latest updates. I have an issue building the driver as it says that 'Windows7' is not a supported OS Version. Maybe I need to use another VS2019 installation tomorrow.

You have to use vs2019, or win7 and win8 are dropped

dontech commented 1 year ago

ARM64 build is a bit strange.

I fixed that in the latest commit

mcuee commented 1 year ago

There is an minor issue building testlibusb-win under VS2019 and Windows SDK 10.0.22000.0.

Severity    Code    Description Project File    Line    Suppression State
Error   CVT1100 duplicate resource.  type:MANIFEST, name:1, language:0x0409 testlibusb-win  C:\work\libusb\libusbwin32_vs2019\libusb\projects\vs2019\testlibusb-win\CVTRES  1   
Error   LNK1123 failure during conversion to COFF: file invalid or corrupt  testlibusb-win  C:\work\libusb\libusbwin32_vs2019\libusb\projects\vs2019\testlibusb-win\LINK    1   
mcuee commented 1 year ago

@dontech

What is the WDK version are you using? Is it this one? WDK for Windows 10, version 2004

Please also mention the EWDK mention used to build for Windows 7 to Windows 11.

mcuee commented 1 year ago

Build log after installation of the above WDK version and VS2019 Community Edition (latest updates).

Rebuild started...
1>------ Rebuild All started: Project: libusb-dll, Configuration: Debug x64 ------
2>------ Rebuild All started: Project: libusb0, Configuration: Debug x64 ------
3>------ Rebuild All started: Project: install-filter, Configuration: Debug x64 ------
4>------ Rebuild All started: Project: install-filter-win, Configuration: Debug x64 ------
1>descriptors.c
2>Building 'libusb0' with toolset 'WindowsKernelModeDriver10.0' and the 'Desktop' target platform.
2>abort_endpoint.c
3>error.c
2>claim_interface.c
1>error.c
4>error.c
2>clear_feature.c
3>install.c
2>dispatch.c
1>install.c
4>install.c
2>driver_debug.c
2>driver_registry.c
3>install_filter.c
1>registry.c
2>get_configuration.c
4>install_filter_win.c
2>get_descriptor.c
3>registry.c
2>get_interface.c
1>usb.c
4>registry.c
2>get_status.c
3>Generating Code...
2>ioctl.c
1>windows.c
2>libusb_driver.c
4>Generating Code...
2>pnp.c
2>power.c
1>Generating Code...
2>release_interface.c
3>install-filter.vcxproj -> C:\work\libusb\libusbwin32_vs2019\libusb\projects\vs2019\x64\Debug\install-filter.exe
2>reset_device.c
2>reset_endpoint.c
1>   Creating library C:\work\libusb\libusbwin32_vs2019\libusb\projects\vs2019\x64\Debug\libusb0.lib and object C:\work\libusb\libusbwin32_vs2019\libusb\projects\vs2019\x64\Debug\libusb0.exp
4>install-filter-win.vcxproj -> C:\work\libusb\libusbwin32_vs2019\libusb\projects\vs2019\x64\Debug\install-filter-win.exe
2>set_configuration.c
1>libusb-dll.vcxproj -> C:\work\libusb\libusbwin32_vs2019\libusb\projects\vs2019\x64\Debug\libusb0.dll
5>------ Rebuild All started: Project: testlibusb, Configuration: Debug x64 ------
6>------ Rebuild All started: Project: testlibusb-win, Configuration: Debug x64 ------
2>set_descriptor.c
2>set_feature.c
5>testlibusb.c
6>testlibusb_win.c
2>Generating Code...
2>Compiling...
2>set_interface.c
2>transfer.c
2>vendor_request.c
2>error.c
5>testlibusb.vcxproj -> C:\work\libusb\libusbwin32_vs2019\libusb\projects\vs2019\x64\Debug\testlibusb.exe
2>Generating Code...
6>LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt
6>CVTRES : fatal error CVT1100: duplicate resource.  type:MANIFEST, name:1, language:0x0409
6>Done building project "testlibusb-win.vcxproj" -- FAILED.
2>libusb0.vcxproj -> C:\work\libusb\libusbwin32_vs2019\libusb\projects\vs2019\x64\Debug\libusb0.sys
========== Rebuild All: 5 succeeded, 1 failed, 0 skipped ==========
mcuee commented 1 year ago

Similar for ARM64.

Build started...
1>------ Build started: Project: libusb-dll, Configuration: Debug ARM64 ------
2>------ Build started: Project: libusb0, Configuration: Debug ARM64 ------
3>------ Build started: Project: install-filter, Configuration: Debug ARM64 ------
4>------ Build started: Project: install-filter-win, Configuration: Debug ARM64 ------
2>Building 'libusb0' with toolset 'WindowsKernelModeDriver10.0' and the 'Desktop' target platform.
3>error.c
1>descriptors.c
4>error.c
2>abort_endpoint.c
2>claim_interface.c
1>error.c
3>install.c
4>install.c
2>clear_feature.c
2>dispatch.c
1>install.c
4>install_filter_win.c
3>install_filter.c
2>driver_debug.c
2>driver_registry.c
3>registry.c
1>registry.c
4>registry.c
2>get_configuration.c
2>get_descriptor.c
3>Generating Code...
1>usb.c
4>Generating Code...
2>get_interface.c
2>get_status.c
1>windows.c
2>ioctl.c
2>libusb_driver.c
1>Generating Code...
3>install-filter.vcxproj -> C:\work\libusb\libusbwin32_vs2019\libusb\projects\vs2019\ARM64\Debug\install-filter.exe
4>install-filter-win.vcxproj -> C:\work\libusb\libusbwin32_vs2019\libusb\projects\vs2019\ARM64\Debug\install-filter-win.exe
2>pnp.c
2>power.c
1>   Creating library C:\work\libusb\libusbwin32_vs2019\libusb\projects\vs2019\ARM64\Debug\libusb0.lib and object C:\work\libusb\libusbwin32_vs2019\libusb\projects\vs2019\ARM64\Debug\libusb0.exp
2>release_interface.c
2>reset_device.c
1>libusb-dll.vcxproj -> C:\work\libusb\libusbwin32_vs2019\libusb\projects\vs2019\ARM64\Debug\libusb0.dll
5>------ Build started: Project: testlibusb, Configuration: Debug ARM64 ------
6>------ Build started: Project: testlibusb-win, Configuration: Debug ARM64 ------
2>reset_endpoint.c
6>testlibusb_win.c
5>testlibusb.c
2>set_configuration.c
2>set_descriptor.c
2>set_feature.c
2>Compiling...
2>set_interface.c
5>testlibusb.vcxproj -> C:\work\libusb\libusbwin32_vs2019\libusb\projects\vs2019\ARM64\Debug\testlibusb.exe
6>CVTRES : fatal error CVT1100: duplicate resource.  type:MANIFEST, name:1, language:0x0409
6>LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt
6>Done building project "testlibusb-win.vcxproj" -- FAILED.
2>transfer.c
2>vendor_request.c
2>error.c
2>Generating code
2>Finished generating code
2>libusb0.vcxproj -> C:\work\libusb\libusbwin32_vs2019\libusb\projects\vs2019\ARM64\Debug\libusb0.sys
========== Build: 5 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
mcuee commented 1 year ago

@dontech

Other than the minor building issue, I am fine with the changes. Thanks.

mcuee commented 1 year ago

There is an minor issue building testlibusb-win under VS2019 and Windows SDK 10.0.22000.0.

Severity  Code    Description Project File    Line    Suppression State
Error CVT1100 duplicate resource.  type:MANIFEST, name:1, language:0x0409 testlibusb-win  C:\work\libusb\libusbwin32_vs2019\libusb\projects\vs2019\testlibusb-win\CVTRES  1   
Error LNK1123 failure during conversion to COFF: file invalid or corrupt  testlibusb-win  C:\work\libusb\libusbwin32_vs2019\libusb\projects\vs2019\testlibusb-win\LINK    1   

The following patch fixed the issue for me but I am not so sure if it is correct or not.

C:\work\libusb\libusbwin32_vs2019 [libusb-vs2019 ≡ +17 ~1 -0 !]> git diff
diff --git a/libusb/src/libusb-win32_version.rc b/libusb/src/libusb-win32_version.rc
index b265a00..8e589ee 100644
--- a/libusb/src/libusb-win32_version.rc
+++ b/libusb/src/libusb-win32_version.rc
@@ -20,7 +20,7 @@
 #include "libusb-win32_version.h"

 #define RT_MANIFEST 24
-#define ID_MANIFEST 1
+#define ID_MANIFEST 2

 VS_VERSION_INFO VERSIONINFO
 FILEVERSION    RC_VERSION
mcuee commented 1 year ago

@tormodvolden

Please help to take a look if you got some time. Thanks.

dontech commented 1 year ago

issue

OK i will push

mcuee commented 1 year ago

@dontech

Can you create a new snapshot release as this is a good change for the users to test out? Thanks.

dontech commented 1 year ago

@dontech

Can you create a new snapshot release as this is a good change for the users to test out? Thanks.

@mcuee Yes, as soon as i can build everything (and sign it) with EWDK, i will submit a new test release