coin-or / qpOASES

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

mex cmd error of make.m in matlab interface #63

Open svigerske opened 4 years ago

svigerske commented 4 years ago

Issue created by migration from Trac.

Original creator: zhaoye8810

Original creation time: 2017-05-04 14:33:30

Assignee: ferreau

Version: 3.2.1

Hello, I try to run the matlab file runOCP.m from BLOCK-ALAIN-master repo. It calls the functionqpOASES_sequence in qpOASES-3.2.1/interfaces/matlab. When I run 'make.m' in that directory, I got the following error.

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++'. Error using mex Undefined symbols for architecture x86_64: "dpotrf", referenced from: qpOASES::QProblemB::computeCholesky() in qpOASES.o qpOASES::QProblem::computeProjectedCholesky() in qpOASES.o "dtrcon", referenced from: qpOASES::SQProblemSchur::updateSchurQR(long) in qpOASES.o "dtrtrs", referenced from: qpOASES::SQProblemSchur::backsolveSchurQR(long, double const, long, double) 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 );

131 eval( cmd );

The error is caused by the mex cmd. My cmd is defined as

mex -output qpOASES -I. -I../../include -I../../src -largeArrayDims -Dcpluplus -DMATLAB -DSINGLE_OBJECT -DLINUX -lmwblas -O -DNO_COPYRIGHT -largeArrayDims -DUSE_LONG_INTEGERS -DUSE_LONG_FINTS__ -DSOLVER_MA57 -lmwma57 qpOASES.cpp

It seems the 'dpotrf' and 'dtrcon' are MACRO defined in LapackBlasReplacement. Does anyone know how to fix this issue? Thank you.

svigerske commented 4 years ago

Comment by zhaoye8810 created at 2017-05-04 14:39:27

As a side comment, I am using matlab R2015a in MacOS Sierra 10.12.1. I build qpOASES by using Cmake (it seems working well, and I can run the examples).

svigerske commented 4 years ago

Comment by ferreau created at 2017-05-05 09:17:53

Changing status from new to assigned.

svigerske commented 4 years ago

Comment by ferreau created at 2017-05-05 09:17:53

Changing type from user support to installation issue.

svigerske commented 4 years ago

Comment by raulest50 created at 2017-06-17 16:26:28

Replying to [comment:1 zhaoye8810]:

As a side comment, I am using matlab R2015a in MacOS Sierra 10.12.1. I build qpOASES by using Cmake (it seems working well, and I can run the examples).


I also want to share my experience to add more clues to this problem.

In a college computer the MinGW64 compiler was installed using the apps manager from matlab 2017. after this make function compiled succesfully.

In my personal computer i tried to install the MinGW64 manually for matlab (no app manager). I was able to compile c code to test the compiler as suggested in example -> https://www.mathworks.com/help/matlab/matlab_external/install-mingw-support-package.html

but when running make from qpoases matlab interface the " Error in make (line 131) eval( cmd ); " was prompted.

i tried to uncomment the "#define __NO_SNPRINTF__" but i did not work.

finally i installed microsoft visual studio 2017 and applied the bug fix shwon in -> https://www.mathworks.com/support/bugreports/1487958.

(see also -> https://www.mathworks.com/matlabcentral/answers/335092-can-i-use-microsoft-visual-studio-2017-with-matlab )

then i used

clear mex

mex -setup cpp

make clean

make

(I also had to comment the "#define __NO_SNPRINTF__" again in Types.hpp)

and finally i got it :

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 'Microsoft Visual C++ 2017'. MEX completed successfully. INFO (make.m): qpOASES.mexw64 successfully created. Building with 'Microsoft Visual C++ 2017'. MEX completed successfully. INFO (make.m): qpOASES_sequence.mexw64 successfully created.

load('ws1.mat') [x] = qpOASES(H, g, [-5;-5], [5;5], opt)

x =

-0.5000 -0.5000

I think it has something to do with the MinGW64 installation, when doing manually there must be an additional step to do in order to compile qpoases interface.