Search code examples
c++visual-studiobuildvisual-studio-2019

visual studio 2019 - libusb - batch build fails


I'm building https://github.com/libusb/libusb on Windows 10.

I opened the .sln in VS 2019.

When I do a Batch Build and select all non-ARM targets, I get linking errors

Build started...
------ Build started: Project: dpfp, Configuration: Debug-MT Win32 ------
dpfp.obj : error LNK2019: unresolved external symbol _libusb_init_context@12 referenced in function _main
dpfp.obj : error LNK2019: unresolved external symbol _libusb_exit@4 referenced in function _main
dpfp.obj : error LNK2019: unresolved external symbol _libusb_strerror@4 referenced in function _main

But then if I click on that same project dpfp and build or re-build, it works fine

Rebuild started...
1>------ Rebuild All started: Project: libusb_static, Configuration: Debug-MT Win32 ------
1>core.c
1>descriptor.c
1>events_windows.c
1>hotplug.c
1>io.c
1>strerror.c
1>sync.c
1>threads_windows.c
1>windows_common.c
1>windows_usbdk.c
1>windows_winusb.c
1>libusb_static.vcxproj -> C:\work\Continuum\libusb\build\v142\Win32\Debug-MT\lib\libusb-1.0.lib
2>------ Rebuild All started: Project: dpfp, Configuration: Debug Win32 ------
2>dpfp.c
2>dpfp.vcxproj -> C:\work\Continuum\libusb\build\v142\Win32\Debug\dpfp.exe
========== Rebuild All: 2 succeeded, 0 failed, 0 skipped ==========

QUESTION
Is this a bug in VS 2019 or something wrong with configuration of the libusb VS .sln?

I found this question but this is for VS 2010; is it possible the bug still isn't fixed?

Visual Studio 2010 batch build fails


Solution

  • I reproduced your problem in VS2019. In Visual Studio 2022, the dpfp project batch build successfully. But there is a project fxload batch build that fails. Currently, batch build of VS2022 still has problems. And you can report to the Developer Community.