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
here is something that may be of help:
Tutorial on MATLAB executables (MEX files)
----------------
Microsoft, the leader in using innovative tactics to promote irksome experience, coupled with antiquated technology that's held together by a pyramid of makeshift afterthoughts.
Apple, the leader in using irksome tactics to promote innovative experience, coupled with an antiquated core that's enhanced by state-of-the-art afterthoughts.
Linux, the leader in not using any tactics to promote user-defined experience, coupled with state-of-the-art core enhanced by innovative afterthoughts.
