--- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -import sys, os, shlex, re +import sys, os, shlex, re, sysconfig from os.path import exists, join, isdir, relpath, expanduser from pathlib import Path from inspect import cleandoc @@ -83,7 +83,10 @@ def get_compiler_settings(): 'define_macros': [('PYODBC_VERSION', VERSION)] } - if os.name == 'nt': + if 'mingw' in sysconfig.get_platform(): + settings['libraries'].append('odbc32') + + elif os.name == 'nt': settings['extra_compile_args'].extend([ '/Wall', '/wd4514', # unreference inline function removed --- a/src/pyodbc.h +++ b/src/pyodbc.h @@ -29,6 +29,7 @@ #define _strcmpi strcasecmp #define _strdup strdup inline int max(int lhs, int rhs) { return (rhs > lhs) ? rhs : lhs; } + inline int min(int lhs, int rhs) { return (rhs < lhs) ? rhs : lhs; } #endif #ifdef __SUN__ @@ -45,7 +46,7 @@ typedef unsigned long long UINT64; #include #include -#ifdef __CYGWIN__ +#if defined(__CYGWIN__) || defined(__MINGW32__) #include #endif