mexplus icon indicating copy to clipboard operation
mexplus copied to clipboard

Static TLS problem with Matlab

Open jbriales opened this issue 9 years ago • 4 comments

Hello again! Pitifully regardless how useful this tool seemed to me I have encountered an almost unavoidable issue with Matlab. After preparing the mex library to use the classes defined in other libraries I'm working with (concretely the MRPT toolbox, http://www.mrpt.org/), I get the following error in Matlab during execution: Error using MRPT.RealLRF_ Invalid MEX-file '/home/jesus/Code/Matlab/mexMRPT/+MRPT/RealLRF_.mexa64': dlopen: cannot load any more object with static TLS

It seems as if the linked libraries of MRPT have too many dependencies, so that Matlab collapses. I think you have also worked out some similar wrapping and solutions for OpenCV, which is in some way similar to the MRPT toolbox I'm using. So, do you think there could be any workaround for this issue with static TLS in Matlab?

I highly thank you for your work and support!

jbriales avatar Dec 03 '14 16:12 jbriales

I can't help much with this issue. See http://stackoverflow.com/questions/19268293/matlab-error-cannot-open-with-static-tls

kyamagu avatar Dec 03 '14 22:12 kyamagu

Solved! I just used static libraries instead of dynamic ones.

jbriales avatar Dec 27 '14 13:12 jbriales

@jesusbriales Hi! Could you tell us how did you do that? I am having the same problem. Thanks

sepidehhosseinzadeh avatar Apr 16 '16 22:04 sepidehhosseinzadeh

Hi @sepidehhosseinzadeh, I suppose it highly depends on the particular project you are working with. If you are adding an external project as a dependency, it might help to have its libraries as static (e.g. using STATIC option for add_library in Cmake) in order to reduce the number of dynamic dependencies of the compiled MEX library.

Regretfully, it's been a while since I had to deal with this... To sum up I would say it need not to be straightforward to solve, depending on the particular libraries involved. If you give some more details about what you're working on maybe I could give additional advice.

jbriales avatar Apr 18 '16 10:04 jbriales