Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to load a c++ dll file into Matlab

I have a C++ dll file that uses a lot of other c++ librarys (IPP, Opencv +++) that I need to load into matlab. How can I do this?

I have tried loadlibrary and mex. The load library does not work.

The mex finds the linux things (platform independent library) and tries to include them. And that does not work.

Does anyone have any good ideas?

like image 588
Rolf Anders Avatar asked Feb 19 '09 13:02

Rolf Anders


People also ask

Can Matlab read C files?

In MATLAB®, you can extend your C and C++ code with a MEX function and call it like any MATLAB built-in function. That means you can use existing C and C++ code without rewriting your algorithms in MATLAB.


1 Answers

loadlibrary should work. I use it all the time to call functions from dlls written in C++ with C wrappers.

What errors are you getting when you try to use loadlibrary?

Make sure that the exported functions of the dll are C functions, not C++ functions. If not, then write C wrappers.

More info on exactly what you are doing when using loadlibrary would be helpful.

like image 123
Dima Avatar answered Sep 22 '22 22:09

Dima