python-oursql / oursql

oursql is a set of MySQL bindings for python with a focus on wrapping the MYSQL_STMT API to provide real parameterization and real server-side cursors.
BSD 3-Clause "New" or "Revised" License
35 stars 19 forks source link

Error at installing: ER_ERROR_FIRST not declared #2

Closed AndiH closed 8 years ago

AndiH commented 9 years ago

For me, pip install oursql fails with the following error message

oursqlx/_exceptions.c:620:24: error: 'ER_ERROR_FIRST' was not declared in this scope
                 if (err >= ER_ERROR_FIRST && err <= ER_ERROR_LAST)
oursqlx/_exceptions.c:620:49: error: 'ER_ERROR_LAST' was not declared in this scope
                 if (err >= ER_ERROR_FIRST && err <= ER_ERROR_LAST)

The same is true when cloning the repo manually and installing via python setup.py build_ext. I tested it with and without Cython installed (the latter only for the pip-based installation). Apart for my default compiler clang (v. clang-700.1.76) I tested it also for gcc (v. gcc 5.2.0 --without-multilib). I'm running OS X 10.11.1.

Commenting out lines 620 and 621 (and removing the else from line 622) in _exceptions.c solves the problem for me, but this surely suppressed some errors, so it's only an intermediate solution.

hayorov commented 9 years ago

Same for me: pip install oursql

... clang -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Qunused-arguments -Qunused-arguments -I/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c oursqlx/compat.c -o build/temp.macosx-10.11-x86_64-2.7/oursqlx/compat.o -I/usr/local/Cellar/mysql/5.7.9/include/mysql -fno-omit-frame-pointer In file included from oursqlx/compat.c:55: oursqlx/_exceptions.c:620:24: error: use of undeclared identifier 'ER_ERROR_FIRST' if (err >= ER_ERROR_FIRST && err <= ER_ERROR_LAST) ^ oursqlx/_exceptions.c:620:49: error: use of undeclared identifier 'ER_ERROR_LAST' if (err >= ER_ERROR_FIRST && err <= ER_ERROR_LAST) ^ 2 errors generated. error: command 'clang' failed with exit status 1

----------------------------------------

(env)mbp:devportal allexx$ clang --version Apple LLVM version 7.0.0 (clang-700.1.76) Target: x86_64-apple-darwin15.0.0 Thread model: posigcc

(env)mbp:devportal allexx$ gcc --version Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 Apple LLVM version 7.0.0 (clang-700.1.76) Target: x86_64-apple-darwin15.0.0 Thread model: posix

gregschlom commented 8 years ago

This broke because of a change in recent versions of mysql. ER_ERROR_FIRST is defined in /usr/local/include/mysql/mysqld_error.h. This constant was removed somewhere between mysql 5.6.26 and mysql 5.7.9. Switching to mysql 5.6.26 should solve the issue until oursql devs update their code.

housamz commented 8 years ago

I had the same error, this solved it for me: 1- Download the package manually. 2- Go to: DOWNLOAD_DIR/oursql-0.9.3.1/oursqlx/_exceptions.c 3- Comment the last “default” (from line 613 to line 623) 4- Run: python setup.py install