Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Visual Studio can't overwrite mex file

Subject: Visual Studio can't overwrite mex file

From: Michael

Date: 1 Dec, 2009 22:31:06

Message: 1 of 5

Hi,

Matlab 2008b
I'm working on building mex files from VS 2008 SP1 on Win XP SP3.

I've setup my VS project to be as close to the default settings for VS given by the mex setup option for VS.

When I go to rebuild my project, VS complains it can't delete the mex file from the previous build. I have to call "clear all" or similar in matlab in order to build again from VS. What I don't understand is that when I build from matlab using mex, this doesn't happen. Does mex clear the mex object from memory behind the scenes? I don't see anything in verbose output to indicate what might be going on.

This is only a minor annoyance, but would be nice if there's a way around it.

Thanks,
MIchael

Subject: Visual Studio can't overwrite mex file

From: Praetorian

Date: 2 Dec, 2009 00:20:02

Message: 2 of 5

On Dec 1, 3:31 pm, "Michael" <mich...@circular-logic.com> wrote:
> Hi,
>
> Matlab 2008b
> I'm working on building mex files from VS 2008 SP1 on Win XP SP3.
>
> I've setup my VS project to be as close to the default settings for VS given by the mex setup option for VS.
>
> When I go to rebuild my project, VS complains it can't delete the mex file from the previous build. I have to call "clear all" or similar in matlab in order to build again from VS. What I don't understand is that when I build from matlab using mex, this doesn't happen. Does mex clear the mex object from memory behind the scenes? I don't see anything in verbose output to indicate what might be going on.
>
> This is only a minor annoyance, but would be nice if there's a way around it.
>
> Thanks,
> MIchael

Michael,
mex.m does exactly that, it unloads the mex file if it is loaded in
memory by MATLAB. You don't have to use "clear all", "clear functions"
and "clear <mexfilename>" work too. These will leave your workspace
variables intact. I don't know of any alternatives to having to call
clear.

HTH,
Ashish

Subject: Visual Studio can't overwrite mex file

From: ImageAnalyst

Date: 2 Dec, 2009 03:08:27

Message: 3 of 5

I'm not sure of the cause but you can install "unlocker" so that when
it does happen, it's a simple one-click to delete the file and start
again. Basically it pries the hands off the file of any other
application that has a lock on it and is preventing you from deleting
it. When you try to delete something that something else has a hold
on, unlocker pops up and with one click allows you to delete the file,
despite the other app trying to hang on to it.
Here's the download link and description:
http://download.cnet.com/Unlocker/3000-2248_4-10493998.html

Subject: Visual Studio can't overwrite mex file

From: Michael

Date: 2 Dec, 2009 04:47:01

Message: 4 of 5

> Michael,
> mex.m does exactly that, it unloads the mex file if it is loaded in
> memory by MATLAB. You don't have to use "clear all", "clear functions"
> and "clear <mexfilename>" work too. These will leave your workspace
> variables intact. I don't know of any alternatives to having to call
> clear.
>
> HTH,
> Ashish

Thanks, that's good to know for sure. And "clear functions" or "clear <mexfilename>" definitely is a better way to go!

Cheers

Subject: Visual Studio can't overwrite mex file

From: Michael

Date: 2 Dec, 2009 04:50:23

Message: 5 of 5

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <7a0eee13-1fa1-4174-8ab8-32f90f6cbfa8@k19g2000yqc.googlegroups.com>...
> I'm not sure of the cause but you can install "unlocker" so that when
> it does happen, it's a simple one-click to delete the file and start
> again. Basically it pries the hands off the file of any other
> application that has a lock on it and is preventing you from deleting
> it. When you try to delete something that something else has a hold
> on, unlocker pops up and with one click allows you to delete the file,
> despite the other app trying to hang on to it.
> Here's the download link and description:
> http://download.cnet.com/Unlocker/3000-2248_4-10493998.html

It's not an issue like this, but thanks for this link, Unlocker will come in handy at other times as I fight with Windows!

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us