Matlab R2011b unable to compile C file in Ubuntu

I am running Matlab R2011b on a Ubuntu 12.04 machine. I installed gcc-4.4 version. I tried to compile a nplant.c file provided by my university. When I try to compile the file using mex I get the following error message.
Warning: You are using gcc version "4.4.6-13ubuntu1)". The version
currently supported with MEX is "4.3.4".
For a list of currently supported compilers see:
http://www.mathworks.com/support/compilers/current_release/
mex: nplant.c not a normal file or does not exist.
Error using mex (line 206)
Unable to complete successfully.
As I understand the gcc version being higher only provides a warning. However, the message saying error using mex and nplant.c not a normal file, I do not understand.
How do I solve this?

1 comentario

Are you running the command from a directory that contains the file nplant.c? If yes, try running the following commands from MATLAB and tell us what you see:
>> pwd
>> !pwd

Iniciar sesión para comentar.

 Respuesta aceptada

Ken Atwell
Ken Atwell el 9 de Feb. de 2012
I think the warning is a bit of distraction here. Even when using a version of gcc different than what MATLAB officially supports, you should be able to at least compile the file and give it a shot.
A Jan suggests, first make sure you're in the right directory. Does the following command display the contents of the C file:
!cat nplant.c

2 comentarios

oh my god!!! You are absolutely right...I mistyped the file name. It was nlplant.c and not nplant.c
I spent like two days compiling gcc-4.3 and others to get this working..so stupid of me!
Ken Atwell
Ken Atwell el 10 de Feb. de 2012
It happens to all of us. Just yesterday, I had mistyped "nominal" and spent the next 20 minutes believing that I had just discovered a catastrophic bug in Statistics Toolbox. MATLAB works much better when you spell things correctly. :)

Iniciar sesión para comentar.

Más respuestas (1)

Jan
Jan el 9 de Feb. de 2012

0 votos

The error message tells, that Matlab supports GCC 4.3.4. Therefore I suggest to install GCC 4.3.4 for the compilation of Mex files.

2 comentarios

Unfortunately I am unable to install gcc 4.3.4 on Ubuntu 12.04. Are you sure the error is due to the gcc version alone?
Jan
Jan el 9 de Feb. de 2012
No, I'm not sure. But using an unsupported compiler might have strange effects.
Does the file "nplant.c" exist in the current directory? If not, use either CD to adjust the current directory or insert the full path name of the C-file for calling MEX.

Iniciar sesión para comentar.

Categorías

Más información sobre Write C Functions Callable from MATLAB (MEX Files) en Centro de ayuda y File Exchange.

Preguntada:

el 9 de Feb. de 2012

Editada:

Jan
el 7 de Oct. de 2013

Community Treasure Hunt

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

Start Hunting!

Translated by