Is it possible to call a function defined in a MEX file inside a code compiled into C shared library?

2 views (last 30 days)
Hello,
I've written a function in matlab taking in input an image, extracting some features using a library and predicting a value using LIBSVM library.
This function works well in Matlab. But to call this function in a C code, I've compiled this function using Matlab compiler into a C shared library.
When I call the function inside my C code, everything goes well (the image is well loaded into the function, some files are loaded) except the function svmpredict from LIBSVM. I have the error: "Undefined function 'svmpredict' for input arguments of type 'struct'."
The strange thing is that the folder where the MEX file for svmpredict is defined is in the path. That is why I wonder: is it even possible to call a function defined in a MEX file inside a function compiled into a C shared library?
Thanks in advance.

Accepted Answer

Titus Edelhofer
Titus Edelhofer on 9 Apr 2014
Hi Yoann,
first of all: yes, you can call a MEX file, that should work. Some questions:
- you wrote a MEX file (called svmpredict?) to call features from LIBSVM?
- is the LIBSVM a dll or a static library? In the first case it needs to be on the Windows search path (or the same folder as the C-application and the generated dll).
- how do you call the svmpredict? Is it through some feval or similar? Try to add the mex file manually to the project (as "additional files") to make sure this is not the case
- do verbose output when building the library, any warnings/error messages popping up?
Titus
  1 Comment
Yoann
Yoann on 9 Apr 2014
Hi Titus,
Thank you very very much for your answer. The problem was that I called svmpredict function using evalc.
Adding svmpredict.mexw32 as additional file solve my problem!
Thanks again. Yoann

Sign in to comment.

More Answers (0)

Categories

Find more on Recognition, Object Detection, and Semantic Segmentation in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!