Fix build in a specific VS2022 environment

Building Executable_odbcconfig using VS2022 failed for me reproducibly
for some time, with

  mt.exe : general error c101008d: Failed to write the updated manifest to the resource of file "C:/lo/src/build/instdir/program/odbcconfig.exe". The file or directory is corrupted and unreadable.
  make[1]: *** [C:/lo/src/core/dbaccess/Executable_odbcconfig.mk:10: C:/lo/src/build/instdir/program/odbcconfig.exe] Error 139

It is caused by linking odbccp32, and legacy_stdio_definitions required
by the latter with current versions of UCRT.

It seems to work OK for others; but being unable to find what's different
on my system, I have this workaround, using run-time loading instead.

Change-Id: Iab1fe7747ca6e677d89a120778ca805465a05611
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147627
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
This commit is contained in:
Mike Kaganski 2023-02-24 11:38:03 +03:00
parent 1786ddbde4
commit 3fc2c054c5
3 changed files with 12 additions and 11 deletions

View file

@ -15,11 +15,6 @@ $(eval $(call gb_Executable_use_libraries,odbcconfig,\
comphelper \
))
$(eval $(call gb_Executable_use_system_win32_libs,odbcconfig,\
legacy_stdio_definitions \
odbccp32 \
))
$(eval $(call gb_Library_use_sdk_api,odbcconfig))
$(eval $(call gb_Executable_add_exception_objects,odbcconfig,\

View file

@ -18,11 +18,9 @@
*/
#if !defined WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#include <odbcinst.h>
#include <sal/config.h>
#include <systools/win32/odbccp32.hxx>
// displays the error text for the last error (GetLastError), and returns this error value
static int displayLastError()
@ -102,7 +100,9 @@ extern "C" int APIENTRY wWinMain( HINSTANCE _hAppInstance, HINSTANCE, LPWSTR, in
if ( !IsWindow( hAppWindow ) )
return displayLastError();
if (!SQLManageDataSources(hAppWindow))
// Have a odbccp32 variable, to not call FreeLibrary before displayLastError
sal::systools::odbccp32 odbccp32;
if (!odbccp32.SQLManageDataSources(hAppWindow))
return displayLastError();
return 0;

View file

@ -33,6 +33,12 @@ public:
return Invoke<proc_t>("SQLGetInstalledDriversW", sBuf, nBufSize, nullptr);
}
bool SQLManageDataSources(HWND hwndParent)
{
using proc_t = BOOL __stdcall(HWND);
return Invoke<proc_t>("SQLManageDataSources", hwndParent);
}
private:
template <typename proc_t, typename... Args> bool Invoke(const char* func, Args... args) const
{