Problem with Visual Studio 2010

Hello everyone! My Goal is to program a standalone Application that interacts with Matlab.
My System is: * Windows 7 * 64bit * Visual Studio 2010 * MATLAB R2011a
I set in VS the following Parameters:
Configuration Properties > Linker > General > Additional Library Directories to "C:\Program Files\MATLAB\R2011a\extern\lib\win64\microsoft"
Configuration Properties > C/C++ > General > Additional Include Directories to "C:\Program Files\MATLAB\R2011a\extern\include"
an the error that occur is
error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "mxArrayToString" in Funktion "mexFunction".
Or every other Mexelement that i am using ... Any Help is welcome.

댓글 수: 1

Jan
Jan 2011년 9월 8일
And did you include mex.h in the code and add all needed libraries found in the lib path?
When does the error occur? Do you run the mex command from within Matlab or do you want to compile the mex from MSVC for any reasons?

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

 채택된 답변

Michael
Michael 2011년 9월 9일

0 개 추천

Thank you for your Advice. My Application is now compiling without errors, BUT now i don't have a standalone Application anymore.
I want my GUI as a standalone application that is ABLE to communicate with my installed Matlab version and if i delete my Matlab version then my Gui is still functional, except the Matlab functions... Is there a chance to do this?

댓글 수: 1

Kaustubha Govind
Kaustubha Govind 2011년 9월 15일
Ah. It looks like you need the MATLAB Engine API (http://www.mathworks.com/help/techdoc/matlab_external/f29148.html) and not the MEX API. MEX is used to call C/C++ code from MATLAB, but MATLAB Engine is used to call MATLAB code for C/C++ applications. The call to the function engOpen (that starts the MATLAB Engine) should fail if MATLAB is not present, so you can use that condition to decide whether to make MATLAB calls or not.

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

추가 답변 (3개)

Michael
Michael 2011년 9월 8일

0 개 추천

I want to compile it with MSVC.
The include of "mex.h" is made and the error occurs if i try to compile it.
Okay the Functionname "mexFunction" is a bit confusing so i renamed it in "test"^^
error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "mexPrintf" in Funktion ""void __cdecl test(void)"
Kaustubha Govind
Kaustubha Govind 2011년 9월 8일

0 개 추천

You have to define a gateway function with the following prototype:
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]);
In addition, please follow instructions under the section "Compiling MEX-Files with the Microsoft Visual C++ IDE" on this page. And remember to configure your Visual Studio to compile for an x64 target if you have 64-bit MATLAB.
Michael
Michael 2011년 9월 28일

0 개 추천

Thats it! Thank you very much.
The direct link to the solution is:
4.d was i little bit unclear for myself, there I used "Configuration Properties -> Debugging ==> environment variable" and it works.

카테고리

도움말 센터File Exchange에서 Call MATLAB from C에 대해 자세히 알아보기

질문:

2011년 9월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by