qpOASES
qpOASES copied to clipboard
Installation issue with Python interface
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:
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?
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.
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.