coin-or / qpOASES

Open-source C++ implementation of the recently proposed online active set strategy
GNU Lesser General Public License v2.1
385 stars 129 forks source link

Error for python interface #70

Open svigerske opened 4 years ago

svigerske commented 4 years ago

Issue created by migration from Trac.

Original creator: hdminh

Original creation time: 2017-07-18 16:45:25

Assignee: ferreau

Version: 3.2.1

Hi, I got the following error for python interface (python 2.7.13, Ubuntu/Linux 16.04, 64bits)

python ../examples/example1.py Traceback (most recent call last): File "../examples/example1.py", line 27, in from qpoases import PyQProblem as QProblem ImportError: /home/minh/miniconda2/envs/newton/lib/python2.7/site-packages/qpoases.so: undefined symbol: _ZN7qpOASES9QProblemBC1EiNS_11HessianTypeENS_11BooleanTypeE

Thanks, Minh

svigerske commented 4 years ago

Comment by jonrkarr created at 2017-11-17 23:19:47

I'm also having the same issue with qpOASES 3.2.1, Python 2.7.12 and 3.6.3, numpy 1.13.1, and Ubuntu 16.04.

I compiled using these commands:

cd /tmp
wget https://www.coin-or.org/download/source/qpOASES/qpOASES-3.2.1.tgz
tar -xvvf qpOASES-3.2.1.tgz
cd qpOASES-3.2.1
make
cd interfaces/python
python setup.py build_ext --inplace

Then I try to import qpoases:

python -c "import qpoases"

This produces this error on Python 2.7 (I also get a similar error with Python 3.6):

Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: ./qpoases.so: undefined symbol: _ZN7qpOASES8QProblemC1EiiNS_11HessianTypeENS_11BooleanTypeE

Any help would be greatly appreciated!

svigerske commented 4 years ago

Comment by pmoran created at 2018-03-03 03:32:14

The C++ library seems to be compiled with long, but the cython interface is just using int. I had a quick hack but couldn't get cython to use long as well. However, you can make C++ use int instead of long... I'm not sure what the deeper ramifications might be but it's working okay for me.

In make_linux.mk, search for CPPFLAGS and delete "-DUSE_LONG_INTEGERS"

Be sure to make clean and remove the compiled python build directory and cython .so before recompiling.

eliasp525 commented 1 year ago

Just as a sidenote,

with python 3.8, Ubuntu 20.04 and current version of qpoases I had to add -D__USE_LONG_INTEGERS__ to CPPFLAGS in make_linux.mk to avoid a similar undefined symbol ImportError.

I cloned the repo to install though, didn't use the release :sweat_smile: