Compile C file with mex in Linux with higher version of gcc

I installed MATLAB R2012a in Fedora 18 whose gcc version is 4.7.1. When I tried to compile c file using mex, it warned me it only supported 4.6.6. I tried to continue. It gave:
test.c:3:6: error: conflicting types for ‘mexFunction’ In file included from test.c:2:0: /usr/local/MATLAB/R2012b/extern/include/mex.h:145:6: note: previous declaration of ‘mexFunction’ was here
mex: compile of ' "test.c"' failed.
When I change the mexFunction to mexF, test.c could be compiled. However, test could not be executed due to loss of entry points. I downloaded gcc4.6.6 and corresponding gmp, mpfr and tried many configure options to install gcc. However, different options just generated different errors. Is there any other way?

1 Comment

What is the prototype of mexFunction in test.c? From the error, it seems that it doesn't match the standard expected prototype:
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])

Sign in to comment.

Answers (1)

Yes, there must be another way. Installing GCC4.6.6 should work, but obviously not by one of the "many configure options" you have tried so far. I'm convinced that somebody can assist you with installing the compiler, if you explain "different options generated different errors" with all required details.

Categories

Products

Asked:

on 29 Jan 2013

Community Treasure Hunt

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

Start Hunting!