Trying to compile C++ Source Code for Matlab. Issue with name function definition/modification.
2 views (last 30 days)
Show older comments
Hi,
I use Matlab2019b. I've been trying to compile on Windows an optimization toolbox called SPAMS http://spams-devel.gforge.inria.fr/index.html. The source code is in c++.
A compile.m file is provided, which helps the compilation procedure. An example command produced by the script is the following:
mex -IC:\Users\spams-matlab-v2.6\linalg -IC:\Users\spams-matlab-v2.6\decomp decomp\mex\mexLasso.cpp -outdir ./build/ -DUSE_BLAS_LIB -DNEW_MATLAB_BLAS -DINT_64BITS -largeArrayDims -DNDEBUG -DWINDOWS -DREMOVE_ -LC:\"Program Files"\MATLAB\R2019b\extern\lib\win64\microsoft\libmwblas.lib -LC:\"Program Files"\MATLAB\R2019b\extern\lib\win64\microsoft\libmwlapack.lib OPTIMFLAGS=" -O"
This is repeated for the different .cpp files in the toolbox.
However the commands work only for some of the libraries.
For some others I get errors similar to this:
Error using mex
In file included from C:\Users\ucacmgu\Documents\spams-matlab-v2.6\decomp\mex\mexLasso.cpp:34:0:
C:\Users\spams-matlab-v2.6\decomp/decomp.h: In instantiation of 'void coreLARS(Vector<T>&,
Vector<T>&, Vector<T>&, Vector<T>&, Vector<T>&, Vector<T>&, Vector<T>&, Matrix<T>&, Matrix<T>&, Matrix<T>&,
Matrix<T>&, Matrix<T>&, Matrix<T>&, const AbstractMatrix<T>&, T&, Vector<long long int>&, Vector<T>&, T, bool,
bool, constraint_type, T*, int) [with T = double]':
C:\Users\spams-matlab-v2.6\decomp/decomp.h:819:15: required from 'void lasso(const
Data<T>&, const AbstractMatrix<T>&, const AbstractMatrix<T>&, SpMatrix<T>&, int, T, constraint_type, bool,
bool, int, Matrix<T>*, int) [with T = double]'
C:\Users\spams-matlab-v2.6\decomp\mex\mexLasso.cpp:179:21: required from 'void
callFunction(mxArray**, const mxArray**, int, int) [with T = double; mxArray = mxArray_tag]'
C:\Users\spams-matlab-v2.6\decomp\mex\mexLasso.cpp:216:50: required from here
C:\Users\spams-matlab-v2.6\decomp/decomp.h:1026:28: error: 'isnan_' was not declared in this
scope
if (t > 0 || isnan(t) || isinf(t)) {
C:\Users\ucacmgu\Documents\spams-matlab-v2.6\decomp/decomp.h:1026:40: error: 'finite_' was not declared in
this scope
if (t > 0 || isnan(t) || isinf(t)) {
I found that the isnan and isinf functions in the error are defined in a header file included in the .cpp files. This is the initial part of the header (misc.h):
#ifndef MISC_H
#define MISC_H
#include <stdlib.h>
#include <stdio.h>
#include <cmath>
#include "utils.h"
#if defined(_MSC_VER) || defined(_WIN32) || defined(WINDOWS)
#define isnan _isnan
#define isinf !_finite
#endif
using namespace std;
Really don't know where the error is.
Please help me!
Michele
4 Comments
James Tursa
on 29 Jan 2021
Edited: James Tursa
on 29 Jan 2021
But where in decomp.h is the isnan and isinf stuff?
Answers (0)
See Also
Categories
Find more on Deploy to C++ Applications Using mwArray API (C++03) in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!