I don't really like Matlab, but where I do civil service at the moment I have to use it. Luckily there is some extern c-code in it (at least it gets to almost acceptable speeds this way).
Now since there are strong security issues where I work I don't have admin rights on my machine, this implied that I installed Xubuntu today, which took me all day...
Now, to use the c-file you have to compile them out of Matlab via a comand
Code:
mex myfile.c
But before doing this you have to choose which compiler to use...I choose gcc (version 4.1.3 or 4.3.1 don't remember) also because the only available already installed.
The error I get is very strange because it says something like: "error: missing '(' or (...) before '/' token"
(...) stands for a part I don't remember now (I'm at home now and not at work)
and the C-code starts with some comments //
I think that there is something not installed in the gcc, but what is it?
Hope it was comprehensible
__________________ Administrator
A COUNTRY WITHOUT AN ARMY IS LIKE A FISH WITHOUT A BIKE!!!
I don't believe in god, but I do believe in what others call utopies.
>> mex givegradient.c
Warning: You are using gcc version "4.1.2". The earliest gcc version supported
with mex is "3.4.0". The latest version tested for use with mex is "3.4.5".
To download a different version of gcc, visit http://gcc.gnu.org
givegradient.c:2: error: expected identifier or ‘(’ before ‘/’ token
givegradient.c:16: error: expected identifier or ‘(’ before ‘/’ token
givegradient.c:142: error: expected declaration specifiers or ‘...’ before ‘/’ token
givegradient.c:143: error: expected declaration specifiers or ‘...’ before ‘/’ token
givegradient.c:144: error: expected declaration specifiers or ‘...’ before ‘/’ token
givegradient.c:147: error: conflicting types for ‘mexFunction’
/usr/local/matlab/extern/include/mex.h:148: error: previous declaration of ‘mexFunction’ was here
givegradient.c: In function ‘mexFunction’:
givegradient.c:156: error: ‘nrhs’ undeclared (first use in this function)
givegradient.c:156: error: (Each undeclared identifier is reported only once
givegradient.c:156: error: for each function it appears in.)
givegradient.c:159: error: ‘prhs’ undeclared (first use in this function)
givegradient.c:159: warning: assignment discards qualifiers from pointer target type
givegradient.c:166: error: ‘plhs’ undeclared (first use in this function)
mex: compile of 'givegradient.c' failed.
??? Error using ==> mex
Unable to complete successfully.
__________________ Administrator
A COUNTRY WITHOUT AN ARMY IS LIKE A FISH WITHOUT A BIKE!!!
I don't believe in god, but I do believe in what others call utopies.
Um, it might be that because the file is a ".c" file, that gcc thinks its ANSI C, which does not recognize "//" as a comment line (although Microsoft C++ might!).
I'd try changing the extension on the source file to ".cpp" or else edit your "//" lines to "/* blah */"....
I haven't touched gcc in years, so I may have no idea of what I'm talking about!
Syntactically correct,
Buffy
__________________ "If you do not agree with anything I say, I'll not only retract it, but deny under oath that I ever said it!" __________________________________________________ ______________-- Tom Lehrer
"What, you guys couldn’t even wear one of your tuxedo t-shirts? I mean, I know each one of you have one."
yeah, its because you used gcc, gcc by default thinks that any file passed to it as a C file, unless otherwise specified, that is why g++ was created, because unlike gcc, g++ thinks that any file passed to it is cpp by default.
you may want to link your mex to g++ vs gcc... you could make a make file too