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

Installation issue with Python interface #120

Open
jdiedrichsen opened this issue May 18, 2021 · 3 comments
Open

Installation issue with Python interface #120

jdiedrichsen opened this issue May 18, 2021 · 3 comments

Comments

@jdiedrichsen
Copy link

On Python 3.7, Mac OSX 10.14, I run into the following problem when trying to install the Python interface, in each way outline in the README.rst file:

Any insight into the problem would be greatly appreciated.

Thanks!

Joern

(Python) bash-3.2$ make python
cd ./interfaces/python/ && python setup.py build_ext --inplace
Compiling qpoases.pyx because it depends on /Users/jdiedrichsen/.local/share/virtualenvs/Python--3BEScb9/lib/python3.7/site-packages/numpy/init.pxd.
[1/1] Cythonizing qpoases.pyx
/Users/jdiedrichsen/.local/share/virtualenvs/Python--3BEScb9/lib/python3.7/site-packages/Cython/Compiler/Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: /Users/jdiedrichsen/Python/qpOASES/interfaces/python/qpoases.pxd
tree = Parsing.p_module(s, pxd, full_module_name)
warning: qpoases.pyx:649:14: cpdef variables will not be supported in Cython 3; currently they are no different from cdef variables
warning: qpoases.pyx:650:14: cpdef variables will not be supported in Cython 3; currently they are no different from cdef variables
running build_ext
building 'qpoases' extension
creating build/temp.macosx-10.9-x86_64-3.7
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/anaconda3/include -arch x86_64 -I/anaconda3/include -arch x86_64 -I/usr/include -I/Users/jdiedrichsen/Python/qpOASES/include -I/Users/jdiedrichsen/Python/qpOASES/include/qpOASES -I/Users/jdiedrichsen/.local/share/virtualenvs/Python--3BEScb9/lib/python3.7/site-packages/numpy/core/include -I/Library/Developer/CommandLineTools/usr/include/c++/v1 -I/Users/jdiedrichsen/.local/share/virtualenvs/Python--3BEScb9/include -I/anaconda3/include/python3.7m -c qpoases.cpp -o build/temp.macosx-10.9-x86_64-3.7/qpoases.o -D__USE_LONG_INTEGERS__ -D__USE_LONG_FINTS__ -stdlib=libc++ -Wno-c++11-long-long -Wall -pedantic -Wshadow -Wfloat-equal -O3 -Wconversion -Wsign-conversion -finline-functions -fPIC -DLINUX -D__USE_LONG_INTEGERS__ -D__USE_LONG_FINTS__ -D__NO_COPYRIGHT__
In file included from qpoases.cpp:71:
/anaconda3/include/python3.7m/Python.h:14:2: error: "Something's broken. UCHAR_MAX should be defined in limits.h."
#error "Something's broken. UCHAR_MAX should be defined in limits.h."
^
/anaconda3/include/python3.7m/Python.h:18:2: error: "Python's source code assumes C's unsigned char is an 8-bit type."
#error "Python's source code assumes C's unsigned char is an 8-bit type."
^
/anaconda3/include/python3.7m/Python.h:27:5: error: "Python.h requires that stdio.h define NULL."

error "Python.h requires that stdio.h define NULL."

^

In file included from qpoases.cpp:71:
In file included from /anaconda3/include/python3.7m/Python.h:30:
/Library/Developer/CommandLineTools/usr/include/c++/v1/string.h:74:64: error: use of undeclared identifier 'strchr'
char* __libcpp_strchr(const char* __s, int __c) {return (char*)strchr(__s, __c);}
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/string.h:81:75: error: use of undeclared identifier 'strpbrk'
char* __libcpp_strpbrk(const char* __s1, const char* __s2) {return (char*)strpbrk(__s1, __s2);}
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/string.h:88:65: error: use of undeclared identifier 'strrchr'; did you mean 'strchr'?
char* __libcpp_strrchr(const char* __s, int __c) {return (char*)strrchr(__s, __c);}
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/string.h:76:13: note: 'strchr' declared here
const char* strchr(const char* __s, int __c) {return __libcpp_strchr(__s, __c);}
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/string.h:95:49: error: unknown type name 'size_t'
void* __libcpp_memchr(const void* __s, int __c, size_t __n) {return (void*)memchr(__s, __c, __n);}
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/string.h:97:46: error: unknown type name 'size_t'
const void* memchr(const void* __s, int __c, size_t __n) {return __libcpp_memchr(__s, __c, __n);}
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/string.h:99:46: error: unknown type name 'size_t'
void* memchr( void* __s, int __c, size_t __n) {return __libcpp_memchr(__s, __c, __n);}
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/string.h:102:74: error: use of undeclared identifier 'strstr'; did you mean 'strchr'?
char* __libcpp_strstr(const char* __s1, const char* __s2) {return (char*)strstr(__s1, __s2);}
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/string.h:78:13: note: 'strchr' declared here
char* strchr( char* __s, int __c) {return __libcpp_strchr(__s, __c);}
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/string.h:102:74: error: no matching function for call to 'strchr'
char* __libcpp_strstr(const char* __s1, const char* __s2) {return (char*)strstr(__s1, __s2);}
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/string.h:78:13: note: candidate disabled:
char* strchr( char* __s, int __c) {return __libcpp_strchr(__s, __c);}
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/string.h:102:81: error: cannot initialize a parameter of type 'char ' with an lvalue of type 'const char '
char
__libcpp_strstr(const char
__s1, const char* __s2) {return (char*)strstr(__s1, __s2);}
^~~~
/Library/Developer/CommandLineTools/usr/include/c++/v1/string.h:78:32: note: passing argument to parameter '__s' here
char* strchr( char* __s, int __c) {return __libcpp_strchr(__s, __c);}
^
In file included from qpoases.cpp:71:
In file included from /anaconda3/include/python3.7m/Python.h:34:
/Library/Developer/CommandLineTools/usr/include/c++/v1/stdlib.h:111:82: error: use of undeclared identifier 'labs'; did you mean 'abs'?
inline _LIBCPP_INLINE_VISIBILITY long abs( long __x) _NOEXCEPT {return labs(__x);}
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/stdlib.h:111:44: note: 'abs' declared here
inline _LIBCPP_INLINE_VISIBILITY long abs( long __x) _NOEXCEPT {return labs(__x);}
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/stdlib.h:113:81: error: use of undeclared identifier 'llabs'
inline _LIBCPP_INLINE_VISIBILITY long long abs(long long __x) _NOEXCEPT {return llabs(__x);}
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/stdlib.h:116:35: error: unknown type name 'ldiv_t'
inline _LIBCPP_INLINE_VISIBILITY ldiv_t div( long __x, long __y) _NOEXCEPT {return ldiv(__x, __y);}
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/stdlib.h:116:95: error: use of undeclared identifier 'ldiv'; did you mean 'div'?
inline _LIBCPP_INLINE_VISIBILITY ldiv_t div( long __x, long __y) _NOEXCEPT {return ldiv(__x, __y);}
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/stdlib.h:116:42: note: 'div' declared here
inline _LIBCPP_INLINE_VISIBILITY ldiv_t div( long __x, long __y) _NOEXCEPT {return ldiv(__x, __y);}
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/stdlib.h:118:34: error: unknown type name 'lldiv_t'
inline _LIBCPP_INLINE_VISIBILITY lldiv_t div(long long __x, long long __y) _NOEXCEPT {return lldiv(__x, __y);}
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/stdlib.h:118:94: error: use of undeclared identifier 'lldiv'
inline _LIBCPP_INLINE_VISIBILITY lldiv_t div(long long __x, long long __y) _NOEXCEPT {return lldiv(__x, __y);}
^
In file included from qpoases.cpp:71:
In file included from /anaconda3/include/python3.7m/Python.h:63:
In file included from /anaconda3/include/python3.7m/pyport.h:191:
/Library/Developer/CommandLineTools/usr/include/c++/v1/math.h:761:41: error: no member named 'fabsf' in the global namespace
abs(float __lcpp_x) _NOEXCEPT {return ::fabsf(__lcpp_x);}
~~^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
error: command 'gcc' failed with exit status 1
make: *** [python] Error 1

@apotschka
Copy link
Contributor

Doing cd ./interfaces/python/ && python setup.py build_ext --inplace works on my Mac (OSX 11.0.1, Anaconda 4.10.1, Python 3.8.2).

My suspicion is that your GCC does not find the correct header files. Maybe you have multiple GCC installations (some homebrew packages ship one, Anaconda Cython might have one, ...).

Please try the following (see stackoverflow and Cython Tutorial):

helloWorld.pyx:

print("Hello world")

setup.py:

from distutils.core import setup
from Cython.Build import cythonize

setup(
    ext_modules = cythonize("helloWorld.pyx")
)

Run on command line:

python setup.py build_ext --inplace

Does this compile?

@jdiedrichsen
Copy link
Author

Hi - thanks for your answer.
Yes- the basic cython helloworld compiles fine.
I'm trying a clean reinstall of miniconda now to make sure, but not sure otherwise what is going on.

@apotschka
Copy link
Contributor

Maybe this comparison of the gcc calls on our machines helps? I added spaces for better comparison.

gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/opt/anaconda3/include -arch x86_64 -I/opt/anaconda3/include -arch x86_64 -I/usr/include -I/Users/potschka/git/qpOASES/include        -I/Users/potschka/git/qpOASES/include/qpOASES        -I/opt/anaconda3/lib/python3.8/site-packages/numpy/core/include                                               -I/Library/Developer/CommandLineTools/usr/include/c++/v1                                                                        -I/opt/anaconda3/include/python3.8 -c qpoases.cpp -o build/temp.macosx-10.9-x86_64-3.8/qpoases.o -D__USE_LONG_INTEGERS__ -D__USE_LONG_FINTS__ -stdlib=libc++ -Wno-c++11-long-long -Wall -pedantic -Wshadow -Wfloat-equal -O3 -Wconversion -Wsign-conversion -finline-functions -fPIC -DLINUX -D__USE_LONG_INTEGERS__ -D__USE_LONG_FINTS__ -D__NO_COPYRIGHT__
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/anaconda3/include     -arch x86_64 -I/anaconda3/include     -arch x86_64 -I/usr/include -I/Users/jdiedrichsen/Python/qpOASES/include -I/Users/jdiedrichsen/Python/qpOASES/include/qpOASES -I/Users/jdiedrichsen/.local/share/virtualenvs/Python--3BEScb9/lib/python3.7/site-packages/numpy/core/include -I/Library/Developer/CommandLineTools/usr/include/c++/v1 -I/Users/jdiedrichsen/.local/share/virtualenvs/Python--3BEScb9/include -I/anaconda3/include/python3.7m    -c qpoases.cpp -o build/temp.macosx-10.9-x86_64-3.7/qpoases.o -D__USE_LONG_INTEGERS__ -D__USE_LONG_FINTS__ -stdlib=libc++ -Wno-c++11-long-long -Wall -pedantic -Wshadow -Wfloat-equal -O3 -Wconversion -Wsign-conversion -finline-functions -fPIC -DLINUX -D__USE_LONG_INTEGERS__ -D__USE_LONG_FINTS__ -D__NO_COPYRIGHT__

The only differences I can spot is a different version of Python (3.7m vs. 3.8) and that you are using a virtual environment.

If you send me your commands for the creation of your virtual environment, I can try to replicate the issue on my MacBook.

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

No branches or pull requests

2 participants