run stand-alone C-program from MATLAB?

run stand-alone C-program from MATLAB?

Post by spike hor » Sat, 24 Jul 2004 23:17:43


I am a newbie to MATLAB. Someone sent me the source code for a
stand-alone C++ program. I don't have a C++ compiler on my computer.
Is there a simple way to compile and run the program with MATLAB?
 
 
 

run stand-alone C-program from MATLAB?

Post by ingcalcu » Sat, 24 Jul 2004 23:47:06

hello,

you have to use the mathworks's script "mcc", if you want compile your
working. For the version 6.1 i know that we need use only function to
compile; for example mcc -c [-B sgl] myFunMain.m fun2.m fun3.m ... funN.m,
the main function which call others must be in first position for the link.
There are a lot of option to compile, -B sgl (if no error) is used with the
graphic library, and -c is to generate the C compiler.
i hope to help (sorry for my english)


XXXX@XXXXX.COM ...

 
 
 

run stand-alone C-program from MATLAB?

Post by spik » Sun, 25 Jul 2004 00:06:37

merci, but the command "mcc" isn't recognized by my MATLAB program
(version 7).

i typed "help mcc", and the reply was

mcc.m not found.

any other suggestions?

spike

p.s. vous pouvez m'ecrire en francais. je peux vous comprendre,
j'espere.


de

MATLAB?
 
 
 

run stand-alone C-program from MATLAB?

Post by Titus Edel » Sun, 25 Jul 2004 00:11:01

Hi Spike,
you will need to buy the MATLAB compiler, see
http://www.yqcomputer.com/

Titus
 
 
 

run stand-alone C-program from MATLAB?

Post by spik » Sun, 25 Jul 2004 00:17:13

Titus,

maybe i have it already(?)among all the other toolboxes i bought.

how can i tell?

spike
 
 
 

run stand-alone C-program from MATLAB?

Post by spik » Sun, 25 Jul 2004 00:22:56

Titus,

I checked your link. It's not that I want to compile a MATLAB
program. I have source code for a stand-alone C++ program that I'd
like to run under MATLAB. I don't need to compile the resultant
mixture of MATLAB and C++.

spike
 
 
 

run stand-alone C-program from MATLAB?

Post by uli » Sun, 25 Jul 2004 00:30:54

type 'ver'
it should show the matlab version, your license and a list of the installed
toolboxes together with their version.

You need the MATLAB Compiler!

_uli
 
 
 

run stand-alone C-program from MATLAB?

Post by uli » Sun, 25 Jul 2004 00:36:03

you need the 'matlab compiler' toolbox to do exactly that. Look for mex
functions on the mathwork website...
_uli
 
 
 

run stand-alone C-program from MATLAB?

Post by spik » Sun, 25 Jul 2004 00:55:01

thanks, uli. amazing what $500 can buy, isn't it?

spike
 
 
 

run stand-alone C-program from MATLAB?

Post by Stuart McG » Sun, 25 Jul 2004 01:24:31

Yes, you don't need the MATLAB Compiler. You need a C compiler. Then call
the executable with the ! operator.
 
 
 

run stand-alone C-program from MATLAB?

Post by spik » Sun, 25 Jul 2004 01:37:28


how about the C compiler Lcc that is included in MATLAB (i am running
MATLAB on a PC)? i tried it on the example source file yprime.c and
it worked, using the mex command. it didn't however work on the C++
program that someone sent me. there were many errors. that may be the
problem of the source code i received, rather than the C compiler.

how does Lcc compare with commercial C compilers that run under
Windows on a PC?

spike
 
 
 

run stand-alone C-program from MATLAB?

Post by sturla.mol » Sun, 25 Jul 2004 20:48:05


lcc is a C compiler, not at C++ compiler. C and C++ are two
distinct languages. A C compiler does not compile C++ syntax.

One particularly important issue: In C++ you must use the
qualifier extern "C" in the prototype of functions that are
exported as C functions. Otherwise you will get a linker error.
Thus if you write a C++ MEX file, remember to declare the
main mexFunction like this:

extern "C" void mexFunction(int nlhs, mxArray **plhs,
int nrhs, mxArray **prhs);


You can get several free C and C++ compilers for Windows.
E.g. Microsoft Visual C++ Toolkit (also remeber to download
the Windows Platform SDK), Borland C++ Builder Compiler,
Open Watcom, and MinGW (a Win32-version of GCC). Matlab
should work with any of these compilers.

http://www.yqcomputer.com/
http://www.yqcomputer.com/

http://www.yqcomputer.com/
http://www.yqcomputer.com/

http://www.yqcomputer.com/ #

http://www.yqcomputer.com/




Sturla Molden
 
 
 

run stand-alone C-program from MATLAB?

Post by uli » Mon, 26 Jul 2004 00:20:18

there is also a c++ example in your matlab directory:
~<MATLAB>\extern\examples\mex

have also a look to the technical-solutions site on www.mathworks.com or to
http://www.yqcomputer.com/ +c%2B%2B+mex&hl=us


_uli