Missing symbol 'for_realloc_lhs' in Matlab's libifcorem​d.dll'

旧巷老猫 提交于 2019-12-11 02:51:50

问题


I built a toto.dll and a toto.lib with ifort (Intel's 2017 update 4 fortran compiler). Then I used mex matlab's compiler to produce several mexw64 files.

When I used mex I linked to toto.lib. Then, I ran a .m file (matlab file) inside matlab 2017a 64bits (under win10 64bits), an this file is using functions from the various mexw64's I compiled.

In the matlab file, at the first call of such function I got the following error :

Invalid MEX-file 'C:\path\to\mexfile.mexw64': Missing symbol 'for_realloc_lhs'
in 'C:\Program Files\MATLAB\R2017a/bin/win64\libifcoremd.dll' required by 'C:\path\to\mexfile.mexw64'.

My fortran compiler is intel fortran 2017 update 4.

I found this :

https://software.intel.com/en-us/forums/intel-visual-fortran-compiler-for-windows/topic/726858

but it does not help that much as for me :

  • replacing the matlab dll by the intel fortran is not a viable (nor correct) solution (it hides the real problem)
  • asking mathworks yielded no answer so far ... (hence my post here)

Can't I somehow tell to matlab to look for the libifcoremd.dll' in the intel fortran directory first, instead of looking in the matlab directory ? (I tried addpath inside the .m file, without success.) What should I do ?


回答1:


If Matlab includes libifcoremd.dll in the same folder as the Matlab executable, which is a horrible thing for them to do, you can't override it. My advice would be to delete the Intel compiler DLLs from that location, though they will likely return on an update.

If they're in a separate folder named on PATH, make sure that the Intel folder is first on PATH.

Probably the best approach for you is to build your DLL to be linked against the static libraries (Fortran > Libraries > Use Run-Time Library > Multithreaded (/MT)). Then you won't be at the mercy of Matlab's bad behavior. I recommend this only when the caller of your DLL is not Fortran.




回答2:


The obj files and toto.lib should be compiled with ifort with the option -nostandard-realloc-lhs if and only if the function for_realloc_lhs is not used, which is the case here.



来源:https://stackoverflow.com/questions/51641751/missing-symbol-for-realloc-lhs-in-matlabs-libifcoremd-dll

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!