Search code examples
c++linuxmatlab-compiler

how to integrate matlab compiled code into c++ in Debian system


I have been trying to use Matlab compiler SDK to packaging my Matlab program as C++ shared library in Debian system. I have got the folder including test.c, test.h, test.so (test is my Matlab program name), and I have installed the Matlab_runtime in the Debian system. I have set the variables LD_LIBRARY_PATH_ and _ XAPPLRESDIR_ as required in the readme.txt _ *( _ replace MCR_ROOT by the directory where the MATLAB Runtime is installed on the target machine. (1) Set the environment variable XAPPLRESDIR to this value: MCR_ROOT/v91/X11/app-defaults (2) If the environment variable LD_LIBRARY_PATH is undefined, set it to the concatenation of the following strings: MCR_ROOT/v91/runtime/glnxa64: MCR_ROOT/v91/bin/glnxa64: MCR_ROOT/v91/sys/os/glnxa64: MCR_ROOT/v91/sys/opengl/lib/glnxa64_)* . I edit my main.cpp include test.h. when I try to compile the main.cpp use _ gcc main.cpp -o main_, I got the error as follows: In file included from main.cpp:2:0: test.h:15:22: fetal error: mclmcrrt.h: No such file or directory #include "mclmcrrt.h"

I know that mclmcrrt.h is in the package of Matlab_runtime, it means I failed to link to the library of Matlab_runtime. Anybody knows what should I do to make my main.cpp compile successfully? I tried two days to work on how to connect to the Matlab_runtime library, but still failed. I am a beginner to linux. Great thanks if anyone can help.

Solution

  • This is a compilation problem, not linkage. Your compiler does not know where mclmcrrt.h is. Please help it find it by telling it where it is:

    gcc -I<the_folder_where_mclmcrrt.h_lives_in> ...