Not able to integrate Matlab and VC++

Hi, I am trying to integrate Matlab and VC++, but no success so far. I am using MS Visual Studio .NET 2010 Professional; Matlab 2011b (fully licensed). My objective is to create a dll from matlab m file and then run it from VC++ program.
I am getting strange errors each time. These are my observations/ difficulties:
1. I could configure mex -setup and it detected VC++ compiler automatically. After accepting it, I did not set anything inside VC++ IDE.
2. I wrote functions in matlab and then try to make 'dll' from them, using mcc. But I could not execute mcc from matlab command window. However, mcc can be run from MS-Dos command prompt, But that is not working, though it is producing a dll file.
Is there any book (apart from mathworks site) clearly explaining the integration process (using mex files, s functions or dll etc) step-by-step with screen shots?
Is there any complete example (some sites have some examples on old versions of matlab and vc++, but they are not working either) that we can download and try?
Any method (other than dll) is ok, once it works.
Thanks in advance and please help me, David

답변 (1개)

Kaustubha Govind
Kaustubha Govind 2011년 11월 16일

0 개 추천

You are confused between two completely different Mathworks technologies:
  1. MEX-functions are used to call native code (C, C++, FORTRAN, etc.) from MATLAB. S-functions are a subset of MEX-functions that can be called from Simulink. Also, MEX-functions are basically DLLs under the hood, but with a platform specific extension (.mexw32, .mexw64, etc) and a required entry function called "mexFunction". The function "mex -setup" is used to setup the compiler used by the "mex" command which compiles C/C++ code into MEX binaries.
  2. The MATLAB Compiler product is used to compile MATLAB code into executables or libraries that can be deployed to a computer that does not have MATLAB installed. It requires additional MATLAB runtime libraries (called the MATLAB Compiler Runtime or MCR) to be packaged along with the deployed binary. This is where the "mcc" and "mbuild" commands belong.
To choose a compiler for running "mcc", you need to run "mbuild -setup" (not "mex -setup"). If you are unable to run the mcc command even after running "mbuild -setup", please post back with the exact error message that you see.
Also, FYI, there is another product called MATLAB Coder which lets you generate standalone C code from MATLAB code, but it only supports a limited subset of MATLAB functions.

댓글 수: 1

david bathu
david bathu 2011년 11월 16일
Hi Kaustubha,
I must completely agree with you that I got the concepts wrong (not just confusion). Thanks for your clarifications. I think, I have to read and understand the Matalab technologies first. Then I will give another try. And then seek your assistance with specific questions.
Thanks again for your prompt response.
David

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

카테고리

도움말 센터File Exchange에서 Troubleshooting in MATLAB Compiler SDK에 대해 자세히 알아보기

질문:

2011년 11월 16일

Community Treasure Hunt

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

Start Hunting!

Translated by