kyamagu / mexplus

C++ Matlab MEX development kit.
Other
99 stars 49 forks source link

Static TLS problem with Matlab #6

Open jbriales opened 9 years ago

jbriales commented 9 years ago

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!

kyamagu commented 9 years ago

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

jbriales commented 9 years ago

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

sepidehhosseinzadeh commented 8 years ago

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

jbriales commented 8 years ago

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.