coin-or / qpOASES

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

Unable to compile Matlab interface of qpoases [MAC] #106

Closed eurika-kaiser closed 3 years ago

eurika-kaiser commented 3 years ago

OS: macosx 10.15.6 Matlab: 2020a qpOASES: v3.2

Hello,

I'm having some issues compiling qpOASES using the Matlab interface. I have NOT compiled qpOASES separately. When I try running make in Matlab I obtain the following error shown further below.

Before having this issue, I had the problem that my SDK couldn't be located, which I solved similarly as outlined here.

While trying to solve the compiling issue using make, I found also issue #66 . As suggested, I added the additional flag -lmwlapack , but it didn't solve the compiling issue.

Any ideas how to proceed? Thanks a lot!

>> make

qpOASES -- An Implementation of the Online Active Set Strategy.
Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka,
Christian Kirches et al. All rights reserved.

qpOASES is distributed under the terms of the
GNU Lesser General Public License 2.1 in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Lesser General Public License for more details.

Building with 'Xcode Clang++'.
In file included from ~/Code/qpOASES/interfaces/matlab/qpOASES.cpp:36:
In file included from ../../include/qpOASES.hpp:47:
../../src/Matrices.cpp:855:38: warning: for loop has empty body [-Wempty-body]
                                for (i = jc[j]; i < jc[j+1]; i++);
                                                                 ^
../../src/Matrices.cpp:855:38: note: put the semicolon on a separate line to silence this warning
In file included from ~/Code/qpOASES/interfaces/matlab/qpOASES.cpp:49:
./qpOASES_matlab_utils.cpp:268:89: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
                                snprintf(msg, MAX_STRING_LENGTH, "ERROR (qpOASES): Empty argument %d not allowed!", idx+1);
                                                                                                  ~~                ^~~~~
                                                                                                  %ld
./qpOASES_matlab_utils.cpp:288:9: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
                                                         idx+1, (long int)mxGetM(prhs[idx]), (long int)mxGetN(prhs[idx]), (int)m,(int)n);
                                                         ^~~~~
./qpOASES_matlab_utils.cpp:300:107: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
                                snprintf(msg, MAX_STRING_LENGTH, "ERROR (qpOASES): Vector argument %d must not be in sparse format!", idx+1);
                                                                                                   ~~                                 ^~~~~
                                                                                                   %ld
./qpOASES_matlab_utils.cpp:370:54: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
                                "ERROR (qpOASES): Argument %d contains 'NaN' !", rhs_index + 1);
                                                           ~~                    ^~~~~~~~~~~~~
                                                           %ld
./qpOASES_matlab_utils.cpp:379:6: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
                                        rhs_index + 1);
                                        ^~~~~~~~~~~~~
6 warnings generated.

Error using mex
Undefined symbols for architecture x86_64:
  "_qpOASES_dpotrf", referenced from:
      qpOASES::QProblemB::computeCholesky() in qpOASES.o
      qpOASES::QProblem::computeProjectedCholesky() in qpOASES.o
  "_qpOASES_dtrcon", referenced from:
      qpOASES::SQProblemSchur::updateSchurQR(long) in qpOASES.o
  "_qpOASES_dtrtrs", referenced from:
      qpOASES::SQProblemSchur::backsolveSchurQR(long, double const*, long, double*) in qpOASES.o
  "_qpOASES_gemm", referenced from:
      qpOASES::DenseMatrix::times(long, double, double const*, long, double, double*, long) const in qpOASES.o
      virtual thunk to qpOASES::DenseMatrix::times(long, double, double const*, long, double, double*, long) const in qpOASES.o
      qpOASES::DenseMatrix::transTimes(long, double, double const*, long, double, double*, long) const in qpOASES.o
      virtual thunk to qpOASES::DenseMatrix::transTimes(long, double, double const*, long, double, double*, long) const in qpOASES.o
      qpOASES::QProblem::setA(double const*) in qpOASES.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Error in make (line 131)
            eval( cmd );
apotschka commented 3 years ago

Thanks for raising the issue, Eurika. I will have to install Matlab on my MacBook first to see if I can reproduce the problem. It might take a couple of days until I get to it and I appreciate your patience.

eurika-kaiser commented 3 years ago

Absolutely, I very much appreciate your help on this!

On Nov 15, 2020, at 11:39 PM, Andreas Potschka notifications@github.com wrote:

Thanks for raising the issue, Eurika. I will have to install Matlab on my MacBook first to see if I can reproduce the problem. It might take a couple of days until I get to it and I appreciate your patience.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/coin-or/qpOASES/issues/106#issuecomment-727796322, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACF4I5J2TSSLAOVM5W72NTTSQDJL7ANCNFSM4TVBGV7Q.

apotschka commented 3 years ago

Hi Eurika,

I could successfully reproduce your problem. For a quick fix, please also remove -D__AVOID_LA_NAMING_CONFLICTS__ from CPPFLAGS in make.m. Your addition of -lmwlapack is indeed required.

The reason is that qpOASES ships a subset of BLAS and LAPACK routines that can be used on embedded hardware. When optimized versions are available on the system, it is usually better to use those.

This fix should make it possible for you to run qpOASES with dense linear algebra. If you need also the sparse linear algebra version, there seems to be a problem with using Matlab's version of MA57, which currently leads to segmentation faults. My first try would be to experiment with the -D__USE_LONG_INTEGERS__ -D__USE_LONG_FINTS__ settings to account for possibly different integer sizes in different breeds of C++ and Fortran compilers.

I hope this helps.

eurika-kaiser commented 3 years ago

Hi Andreas,

This works perfectly! I have the same issue with the sparse linear algebra version but don’t need it for now, so haven’t experimented further as you suggested.

Thank you very much for your effort and quick response on that!!

Best, Eurika

On Nov 20, 2020, at 12:46 AM, Andreas Potschka notifications@github.com wrote:

Hi Eurika,

I could successfully reproduce your problem. For a quick fix, please also remove -D__AVOID_LA_NAMING_CONFLICTS__ from CPPFLAGS in make.m. Your addition of -lmwlapack is indeed required.

The reason is that qpOASES ships a subset of BLAS and LAPACK routines that can be used on embedded hardware. When optimized versions are available on the system, it is usually better to use those.

This fix should make it possible for you to run qpOASES with dense linear algebra. If you need also the sparse linear algebra version, there seems to be a problem with using Matlab's version of MA57, which currently leads to segmentation faults. My first try would be to experiment with the -DUSE_LONG_INTEGERS -DUSE_LONG_FINTS settings to account for possibly different integer sizes in different breeds of C++ and Fortran compilers.

I hope this helps.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/coin-or/qpOASES/issues/106#issuecomment-731030820, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACF4I5JEZIK55E4PCZU3PF3SQYUGLANCNFSM4TVBGV7Q.