Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

building on MSYS2 MINGW64 #1168

Open
RoDuth opened this issue Feb 19, 2023 · 1 comment · May be fixed by #1169
Open

building on MSYS2 MINGW64 #1168

RoDuth opened this issue Feb 19, 2023 · 1 comment · May be fixed by #1169

Comments

@RoDuth
Copy link

RoDuth commented Feb 19, 2023

Can't seem to get build to work on mingw (from looking at other issues seems cygwin is working), I note some old references to MING32 in the source (e.g. in src/pyodbc.h) but it seems setup.py does not account for mingw. Hence the below error (with windows compiler flags).

$ python setup.py build
WARNING: '' not a valid package name; please use only .-separated package names in setup.py
running build
running build_py
running build_ext
building 'pyodbc' extension
gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -march=nocona -msahf -mtune=generic -O2 -pipe -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong -O3 -march=nocona -msahf -mtune=generic -O2 -pipe -Wp,-
D_FORTIFY_SOURCE=2 -fstack-protector-strong -O3 -DPYODBC_VERSION=4.0.36b17 -IC:/msys64/mingw64/include/python3.10 -c src/buffer.cpp -o build/temp.mingw_x86_64-3.10/src/buffer.o /Wall /wd4514 /wd4820 /wd4668 /wd4711 /wd
4100 /wd4127 /wd4191 /d2FH4-
gcc.exe: fatal error: cannot specify '-o' with '-c', '-S' or '-E' with multiple files
compilation terminated.
error: command 'C:\\msys64\\mingw64\\bin/gcc.exe' failed with exit code 1
@RoDuth
Copy link
Author

RoDuth commented Feb 19, 2023

Having a bit of a stab in the dark with setup.py

-import sys, os, re, shlex
+import sys, os, re, shlex, sysconfig

...

         except ValueError:
             pass

-    if os.name == 'nt':
+    if 'mingw' in sysconfig.get_platform():
+        # Windows mingw
+        settings['extra_compile_args'].extend([
+            '-Wno-write-strings',
+            '-Wno-deprecated-declarations',
+        ])
+        settings['libraries'].append('odbc32')
+
+    elif os.name == 'nt':
         settings['extra_compile_args'].extend([
             '/Wall',

I get a little further:

$ python setup.py build
WARNING: '' not a valid package name; please use only .-separated package names in setup.py
running build
running build_py
running build_ext
building 'pyodbc' extension
gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -march=nocona -msahf -mtune=generic -O2 -pipe -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong -O3 -march=nocona -msahf -mtune=generic -O2 -pipe -Wp,-
D_FORTIFY_SOURCE=2 -fstack-protector-strong -O3 -DPYODBC_VERSION=4.0.36b17 -IC:/msys64/mingw64/include/python3.10 -c src/buffer.cpp -o build/temp.mingw_x86_64-3.10/src/buffer.o -Wno-write-strings -Wno-deprecated-declar
ations
gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -march=nocona -msahf -mtune=generic -O2 -pipe -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong -O3 -march=nocona -msahf -mtune=generic -O2 -pipe -Wp,-
D_FORTIFY_SOURCE=2 -fstack-protector-strong -O3 -DPYODBC_VERSION=4.0.36b17 -IC:/msys64/mingw64/include/python3.10 -c src/cnxninfo.cpp -o build/temp.mingw_x86_64-3.10/src/cnxninfo.o -Wno-write-strings -Wno-deprecated-de
clarations
In file included from src/cnxninfo.cpp:8:
src/wrapper.h: In destructor 'RegKey::~RegKey()':
src/wrapper.h:114:13: error: 'RegCloseKey' was not declared in this scope
  114 |             RegCloseKey(hkey);
      |             ^~~~~~~~~~~
error: command 'C:\\msys64\\mingw64\\bin/gcc.exe' failed with exit code 1

RoDuth added a commit to RoDuth/pyodbc that referenced this issue Feb 20, 2023
@RoDuth RoDuth linked a pull request Feb 20, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant