diff --git a/setup.py b/setup.py index e5ffb1ae..b205385c 100755 --- a/setup.py +++ b/setup.py @@ -159,6 +159,17 @@ def get_compiler_settings(version_str): sys.argv.remove('--windbg') settings['extra_compile_args'].extend('/Od /Ge /GS /GZ /RTC1 /Wp64 /Yd'.split()) + # Visual Studio 2019 defaults to using __CxxFrameHandler4 which is in + # VCRUNTIME140_1.DLL which Python 3.7 and earlier are not linked to. This requirement + # means pyodbc will not load unless the user has installed a UCRT update. Turn this + # off to match the Python 3.7 settings. + # + # Unfortunately these are *hidden* settings. I guess we should be glad they actually + # made the settings. + # https://lectem.github.io/msvc/reverse-engineering/build/2019/01/21/MSVC-hidden-flags.html + settings['extra_compile_args'].append('/d2FH4-') + settings['extra_link_args'].append('/d2:-FH4-') + settings['libraries'].append('odbc32') settings['libraries'].append('advapi32')