After generating MATLAB DLL, how do you implement in C++?

조회 수: 3 (최근 30일)
Juliana Tobias
Juliana Tobias 2017년 3월 31일
댓글: Juliana Tobias 2017년 4월 3일
I'm trying to run a matlab program within my main c++ code. The below article is where I've been trying to run the example provided in Visual Studio 2015, by running mcc and build commands on the provided files (sierpinski.m, main_for_lib.c, main_for_lib.h, and triangle.c). I created a new project in Visual Studio 2015 and added all the header files to the header folder and all the rest of the files into the source files folder. I'm unable to build and run the program from "triangle.c" file, as the "mclmcrrt.h" file cannot be found. I looked back to my windows folder to see if one was ever generated and that answer is no, there wasn't one generated.
Here are my main questions on this issue:
  • by following this example, what is the mclmcrrt.h file and how would I access it?
  • how should all my files be added to my c++ project in visual studio, do I need to do some linking/include dependencies?
  • What is the main way in c++ to use a matlab dll and call the program in your code?
https://www.mathworks.com/help/compiler_sdk/cxx/matlab-compiler-generated-interface-functions.html

답변 (1개)

Varun Gunda
Varun Gunda 2017년 4월 3일
If you are using the MCR to utilize the DLLs, please add the directory:
[MCR root]\extern
to your Visual Studio project path. [MCR root] is the MCR installation path on the system. For example: 'C:\Program Files\MATLAB\MATLAB Compiler Runtime\v716\extern'.
If you are using a MATLAB installation to utilize the DLLs, please add the directory:
[matlabroot]\extern
to your Visual Studio project path. [matlabroot] is the MATLAB installation directory on your system. For example: 'C:\Program Files\MATLAB\R2011b\extern'.
You can find [matlabroot] by typing the following command into the command window.
matlabroot
  댓글 수: 1
Juliana Tobias
Juliana Tobias 2017년 4월 3일
Hi Varun,
I've added the MCR root in Visual Studio to my project as an "Include Directory", is that the correct type of directory?
Also, which of the files produced from the mcc do I include in my project and where? For example, do I only include the dll under source files or do I need the dll, the .lib, and the .h files?
Thanks, Julie

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Software Development Tools에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by