强制MATLAB重新加载在mex函数中链接的库 [英] Force MATLAB to reload library linked in mex function

查看:140
本文介绍了强制MATLAB重新加载在mex函数中链接的库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Mex函数,例如myfunction.mexmaci64(这是OS X上的正确结尾).

I have a Mex-function, say myfunction.mexmaci64 (which is the correct ending on OS X).

现在,myfunction已链接到库mylibrary.dylib. mex文件和库都位于同一文件夹中.

Now, myfunction is linked against a library mylibrary.dylib. Both, mex-file and library, reside in the same folder.

现在,每当我在mylibrary中进行某些更改时,MATLAB都不会重新加载新的库版本,而是使用旧的库版本,直到我重新启动MATLAB为止.在进行开发和调试工作时,这非常容易. 有没有一种方法可以强制MATLAB在不重新启动应用程序的情况下重新加载库?

Now, whenever I change something in mylibrary, MATLAB does not reload the new library version but instead uses the old one until I do restart MATLAB. That is very anoing when doing development and debugging work. Is there a way to force MATLAB to reload the library without restarting the application?

注意:将库静态静态链接到mex函数会很容易.但是,当我在多个mex文件中链接同一库时,我希望保留我的单个共享库以减少编译时间和数据冗余.

Note: It would be easy to link the library statically into the mex function. However, as I link the same library across quite a few mex-files, I would prefer to keep my single shared library to reduce compilation times and data redundancy.

关于讨论,clear mex是否有帮助:

Concerning the discussion wether the clear mex helps:

[~, loaded_mexes] = inmem('-completenames'); % get canonica

返回包含所有已加载的mex文件的列表.该列表不包含链接库,仅包含mex文件本身.使用clear mex成功清空此列表,但不会卸载mylibrary-再次运行mex函数仍会产生与旧共享库相同的输出.

returns a list with all loaded mex-files. This list does not contain the linked library, but only the mex-files itself. Using clear mex successfully empties this list, but does not unload mylibrary - running the mex function again still yields the same output as it did with the old shared library.

推荐答案

要清除内存中的库,我通常会很幸运

To clear a library from memory I usually have excellent luck with

bdclose all;

然后,如果我真的感到好战,我会这么做:

Then if I'm really feeling militant, I'll do:

bdclose all; % clear all libraries out of memory ( supposedly )
clear all;   % clear all workspace variables, mex, etc. ( supposedly )
rehash;      % cause all .m files to be reparsed when invoked again

这篇关于强制MATLAB重新加载在mex函数中链接的库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆