Unload MEX file from MATLAB

17 visualizaciones (últimos 30 días)
defunct C7=5F>20
defunct C7=5F>20 el 8 de Ag. de 2013
Comentada: JulioLP el 12 de Nov. de 2021
Hi, everybody!
I am writing and debugging a mex file in MATLAB. So every time I recompile it I need to reload it somehow in MATLAB. So far, the only things that works is to restart MATLAB, which is very inconvenient.
The way I tried already:
  1. clear mex (removes the file from [~,m] = inmem('-completenames'), but does not actually unload it)
  2. unloadlibrary 'name' (does not work with mex files)
  3. solution posted here: http://stackoverflow.com/questions/17296668/force-matlab-to-reload-library-linked-in-mex-function , which uses bdclose all; close all; rehash;
Are there any other reciepts, what one can do, or is it impossible?
Edit: After some testing, I really belive it is a problem of using shared libraries. I compiled the following MEX-OpenCV example:
#include <mex.h>
#include <opencv2/opencv.hpp>
void mexFunction( int nlhs, mxArray **plhs, int nrhs, const mxArray **prhs){
mexPrintf("Number of input arguments: %d\n",nrhs);
mexPrintf("OpenCV version: %d.%d\n",CV_MAJOR_VERSION,CV_MINOR_VERSION);
}
if I compile it as
mex -lopencv_core testMEX.cpp
it is not possible to recompile it and use it directly after recompilation in MATLAB. However, if I compile the same code with
mex testMEX.cpp
it is loaded in MATLAB automatically directly after recompilation.
  8 comentarios
Alec Jacobson
Alec Jacobson el 10 de Jun. de 2018
Is there any followup to this problem with matlab? I'm suffering the same issue.
JulioLP
JulioLP el 12 de Nov. de 2021
Hi,
I had the same problem. Turns out a simple
clear all
is enough to unload the previous mex file and work with the new one. Not the most elegant solution, but it helps for debugging.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre MATLAB Compiler en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by