필터 지우기
필터 지우기

Matlab will not compile my C++ .exe file

조회 수: 4 (최근 30일)
Mini Me
Mini Me 2013년 1월 21일
I have program in C++ that runs great but it has different steps in it. It opens a file first then does some calculations based on the data it gets from the file. Now I'm trying to run it through matlab. I tried mex but it got too complicated because I have VS 2010 Express and MATLAB 2007b. And so mex can never find my c compiler.
I'm now trying to just run it straight from the C++ program executable file through matlab. Here's how I tried to do it:
system('C:\path\file.exe')
it would act like it's compiling the command line window for the executable file does not come up and matlab command window freezes and I have to close Matlab every time to get back on track. So I wrote a sample code to open the file first before the system command open the .exe file. I've done something like M=fopen('fname','r'), but nothing works. Please note that this file I'm trying to open is a .COF file that the program uses to do calculations.
I tried running the .exe file using debug and release modes but nothing happens. It gives no errors which means it sees the .exe file but the command line doesn't come up and matlab command window freezes everytime
After running, it's supposed to prompt the user at the command line input then take input arguments and output results... I do not want to use MEX but if you have a simper way to get the C++ .exe to run through matlab i am opened to it.
Please help....
P.S im using VS 2010, MATLAB R2007b and MAtlab r2011a,Win7, 32 and 64 bit.

답변 (2개)

Walter Roberson
Walter Roberson 2013년 1월 21일
VS 2010 Express is not supported for R2007b. Use VS 2005. See http://www.mathworks.com/support/compilers/release2007b/
  댓글 수: 5
Mini Me
Mini Me 2013년 1월 22일
Mr. Roberson, downloading VS 2005 and using it with Matlab R2007b did not a difference. Matlab still doesn't pull up the executable file when I call it. I simply write system('C:\file1\projects\Debug\myfile.exe') It acts like its compiling so I wait and wait and nothing comes up Any ideas
Jan
Jan 2013년 1월 24일
It acts like it is compiling? Are there any arguments or observations which for this claim? An EXE-file is compiled already, and as long as this EXE is not a compiler itself I do not see any reasons for your assumption. It is more likely that your program hangs due to a bug. Can you exclude that?

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


Ryan Livingston
Ryan Livingston 2013년 1월 24일
I would recommend trying the '-echo' option to SYSTEM. From the doc:
[status,cmdout] = system(command,'-echo')
additionally displays (echoes) the command output in the MATLAB® Command Window. This syntax is most useful for commands that require user input and that run correctly in the MATLAB Command Window.
Sometimes window output can not happen immediately. Also, if your program tries to redirect any of the streams like STDIN, STDOUT then issues could arise.

카테고리

Help CenterFile Exchange에서 Write C Functions Callable from MATLAB (MEX Files)에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by