f



Cannot compile c/c++ code with Matlab R2009a Lcc compiler

Hello,
I am using the lcc compiler in Matlab R2009a to create MEX files. The c/c++ files have previously been compiled and found to work in visual studio, but the matlab compiler appear to expect another syntax:

class 'Sample.cpp':

#include <stdio.h>
#include <math.h>
#include "mex.h"

static const int nbrOfBands = 1;

double FindShortestPath(double fromAngle, double toAngle);
double FindShortestPath(double fromAngle, double toAngle, double scanDirection);

double FindShortestPath(double fromAngle, double toAngle)
{

	return findShortestPath(fromAngle, toAngle, 0);
}

double FindShortestPath(double fromAngle, double toAngle, double scanDirection)
{

	double angles[nbrOfBands];
    return 0;
}

when I type 

>> mex Sample.cpp

I get a number of compile errors:

>> mex Sample.cpp
Error Sample.cpp: 8  redeclaration of `FindShortestPath' previously declared at Sample.cpp 7 
Error Sample.cpp: 11  redeclaration of `FindShortestPath' previously declared at Sample.cpp 8 
Error Sample.cpp: 17  redefinition of `FindShortestPath' previously defined at Sample.cpp 10 
Error Sample.cpp: 17  redeclaration of `FindShortestPath' previously declared at Sample.cpp 10 
Error Sample.cpp: 19  integer expression must be constant 
Warning Sample.cpp: 19  local `array 1 of double angles' is not referenced 
Error Sample.cpp: 21  asm: label _FindShortestPath: redefined 
6 errors, 1 warnings 

Save for the warning, there should be no compile error - right?

I am running 32-bit Windows XP and Matlab R2009a.

Any hints about what I could try to solve the problem are most appreciated.


 
0
Hannes
1/31/2011 5:03:04 PM
comp.soft-sys.matlab 211264 articles. 26 followers. lunamoonmoon (257) is leader. Post Follow

2 Replies
1634 Views

Similar Articles

[PageSpeed] 33

You are using a C compiler to compile a C++ function.  Try the Borland BCC55 free C++ compiler or Visual C++ express edition.
0
Matt
1/31/2011 5:20:21 PM
"Matt Fig" wrote in message <ii6r0l$34r$1@fred.mathworks.com>...
> You are using a C compiler to compile a C++ function.  Try the Borland BCC55 free C++ compiler or Visual C++ express edition.

Thanks Matt, now it works.
0
Hannes
2/1/2011 1:44:07 PM
Reply:

Similar Artilces:

C/C++ in matlab and matlab in C/C++ ?
Is it possible to read C/C++ code in matlab and the other way around too? Hi, as long as C or C++ are written in text files you can edit them in the matlab editor. To see the special character of C or C++ coding language, in the editor go to menus: file>preferences>Edito/Debugger>language and on popup "Language" select "C/C++". This does not allow you to run the C/C++ code, just to view it i nicer way... regards, chris saneman <asdfsdf@asd.com> wrote in message <frl846 $f8i$2@news.net.uni-c.dk>... > Is it possible to read C/C...

Conversion from MATLAB to C/C++ using MATLAB compiler
I am working on conversion of .m files to c/c++. I am using the MATLAB compiler version 3.0 and MATLAB version 6.5.1. There seem to be a few functions which do not seem to get converted. The error i got while using functions like TRAIN, NETWORK and INIT (all neural-networks related functions used in the general neural network programs, newpnn.m etc) is The MATLAB compiler does not currently support MATLAB object oriented programming and the functions TRAIN , NETWORK and INIT would produce a run-time error. Could anyone please tell me as to how i can circumnavigate this problem or solve this...

Compile C/C++ code and connect it to matlab
Hello, I want to compile a C++ code and connect it to matlab. Can anyone pls tell me how i should do it. I tried doing it using mex with some built in matlab c codes, but these c codes are very diff from what i have written. My c code is the normal c code that we write.I am naive regarding this and so kindly explain as much as possible. Thanks, Prads On 27 Okt, 02:57, prads <kashya...@gmail.com> wrote: > Hello, > I want to compile a C++ code and connect it to matlab. Can anyone pls tell me how i should do it. I tried doing it using mex with some built in matlab c codes, but thes...

Converting Matlab code to C using Matlab Compiler
Hello All, Please can I get some guidance on how to Convert a structure from Matlab code to C code using Matlab Compiler. Kind regards Sammy ...

C code generated with matlab C compiler sucks
Hi 'C' code generated with matlab compiler sucks. It hard to understand how that code works. When we execute the .exe file its much slower than the original matlab file. I dont know the reason we have C compiler toolbox in matlab. I think it can be used "only" for generation of slow stand alone programs. I hope matlab comes with a new C compiler that provides faster stand alone programs. Think of this. Take care. jack. jack wrote: > > > Hi > > 'C' code generated with matlab compiler sucks. It hard to > understand > how that code works. When w...

Trying to compile C++ code with Matlabs MEX compiler
Hi After successful compilation of unaltered mexcpp.cpp example c++ code from Matlab (C:\MATLAB6p5\extern\examples\mex) I would like to use some functions of a dll. (headerfile.dll) (Sorry about name conventions) When trying to include a header file on mexcpp.cpp #include "headerfile.h" the compiler, called from matlab, sends the following errors: C:\MATLAB6p5\work\Include\headerfile.h(18) : error C2146: syntax error : missing ';' before identifier 'FunctionsName' C:\MATLAB6p5\work\Include\headerfile.h(18) : fatal error C1004: unexpected end of file found #ifnde...

matlab c/c++ compiler
Hi, I'm student and i'm working on wavelet foveation, my first version of m filles takes more than 4 hours to calculate results using 512*512 image, i tried to use matlab c ++ compiler in order to optimise time calculation (making full or partial stend alone application), problem : i had a lot of warnings and errors ! my question is about efficient manuals or books about making stand alone applications using matlab compiler (with visual interfaces if its posible, generating mex files under linux or dll's under windows). Thanks. Marie. On Sat, 15 Nov 2003 11:49:24 +0...

compiling matlab .m / generating .c (c code) from .m
Hi everyone, When I compile a matlab .m file (with mcc command), I get an executable, that works well, and it also generates a C code (2 .c files), and some other files (a .ctf, some .m files that do not have matlab codes, but non readable codes, and others). As I want to integrate the program with a C project, I don't want it to be a black box, that I cant' debug. I tried to compile the .c files in an external compiler, and it did not work. I tried in DevC++ and also in Microsoft Visual C++. They show errors like "unexpected end of file while looking for precompiled header direc...

Compiling Matlab code to C++ code
Hi, I'm trying to compile matlab code into C++. I ran mbuild -setup to use MS VS.(on a side note, can Matlab use g++ instead? it only gave options for MS VS and LCC) Then I tried 'mcc -m add -d bin -v' The program is simple: function add(As, Bs) A = str2num(As); B = str2num(Bs); C = A + B; But I run into this non descriptive error message: Generating MATLAB path for the compiled application... Created 34 path items. Depfun main loop converged in 2 iterations, total number of files = 11 Begin validation of MEX files: Thu Feb 22 09:04:57 2007 End validation of MEX files: Thu Fe...

program that compiles in C compiler but not in C++ compiler
Hi, I need a small program that compiles in C compiler but not in C++ compiler. Thx in advans, Karthik Balaguru KBG <karthik.balaguru@lntinfotech.com> wrote: > I need a small program that compiles in C compiler but not in C++ > compiler. No problem, just send $10 to paypal@zevv.nl and I'll do your homework for you. -- :wq ^X^Cy^K^X^C^C^C^C KBG said: > Hi, > > I need a small program that compiles in C compiler but not in C++ > compiler. Can you think of any syntactic differences between C and C++? For example, what about keywords? They are very, very sen...

g++ compiled C++ code called from gcc compiled C code
Hi all! In a C library compiled with gcc there is a pointer to a function defined and called from within the library. Now I'm using that library in a C++ project and I'd like to set this function pointer to a C++ function. Do I have to set the C++ function __attribute__((cdecl)) ? Are there any other things I have to worry about? See example code below. Thanks very much, Klaus Example Code: ----------------------------------------------------- *** lib.c (compiled with gcc and linked to a library): void (* logfunc)(int,char*,...); int getSomething(void) { ... logf...

compiling c code but libraries are compiled in c++
hi, We have written cunit code for testing some APIs. defination of those APIs are in c++ and .so library is created of them. when I compile my cunit code it gets compiled successfully but while liking it gives undefined reference to symbol. can anyone help me in this matter. Regards Sumit Shrivastava On 29 May 2007 04:11:14 -0700 sumit <sumit.shrivastava09@gmail.com> wrote: | We have written cunit code for testing some APIs. defination of | those APIs are in c++ and .so library is created of them. when I | compile my cunit code it gets compiled successf...

methods to call matlab in C C++ and call C C++ in matlab
Hi, I am reading the help documents about how to program matlab and C C++ together and my questions are a little bit general. It seems that are several ways to call matlab in C C++ and another several ways to call C C++ in matlab. Please correct me if I am wrong or missing something when I try to list them. To call matlab code in C C++, are there two methods available? The first one is Matlab engine and the second one is to use MATLAB Compiler mcc to create C or C++ shared libraries from your MATLAB code. To call C C++ in matlab, are there also two methods? The first one is to call funct...

Are sun studio C/C++ compilers and Forte C/C++ compilers same ??
Is there any difference between sun studio compilers and forte compilers??? or the names have been changed??? In article <1145338052.955429.256610@v46g2000cwv.googlegroups.com>, "ameya_agnihotri" <ameyaagnihotri22@gmail.com> writes: > Is there any difference between sun studio compilers and forte > compilers??? > or the names have been changed??? One of many name changes in the product's history (including amongst others, Java somethingortheother, Workshop, Proworks/Teamworks, and probably more I've forgotten). Of course, the versions and features cha...