Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
Mathematics
General TopicsResearchOperations ResearchStatisticsMathematical LogicNumerical AnalysisUndergraduate MathAlgebra HelpRecreational Math
Math Software
MapleMathematicaMATLABScilabSASSPSS

Math Forum / Math Software / MATLAB / September 2011



Tip: Looking for answers? Try searching our database.

Run C code in Matlab

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Emma Robertson - 03 Sep 2011 16:01 GMT
Hi everyone,

I have never used/compiled C codes before and I am trying to run one in Matlab at the moment. Here's how I did it in a Mac OS:

Input  "mex -setup" at  the command line

I got the following options:

The options files available for mex are:

 1: /Applications/MATLAB_R2010aSV.app/bin/gccopts.sh :
     Template Options file for building gcc MEX-files

 2: /Applications/MATLAB_R2010aSV.app/bin/mexopts.sh :
     Template Options file for building MEX-files via the system ANSI compiler


 0: Exit with no changes

Enter the number of the compiler (0-2):
2

Overwrite /Users/username/.matlab/R2010a/mexopts.sh ([y]/n)?
y

Then I wrote the following in the command line
mex filename.c
and got
??? Error using ==> mex at 222
Unable to complete successfully.

I tried running it with option 1 but got the same error message.  Any idea if this is a compiling error or if it is actually an error within the code. The code is very long and hence it is not a good idea to post it here.  If anyone has the time to assist with this query I can email the code instead.

I appreciate any input thanks
Emma
Wayne King - 03 Sep 2011 18:33 GMT
> Hi everyone,
>
[quoted text clipped - 31 lines]
> I appreciate any input thanks
> Emma

Hi Emma, Please share with us what you got before

??? Error using ==> mex at 222
Unable to complete successfully.

Weren't there other messages produced in the command window after you entered:

mex filename.c

Wayne
Emma Robertson - 04 Sep 2011 02:05 GMT
> > Hi everyone,
> >
[quoted text clipped - 42 lines]
>
> Wayne

Sure. I got this before the error message

/Applications/MATLAB_R2010aSV.app/bin/mex: line 306: gcc-4.0: command not found
/Applications/MATLAB_R2010aSV.app/bin/mex: line 1058: gcc-4.0: command not found

   mex: compile of ' "filename.c"' failed.

Thanks.
Christopher Creutzig - 05 Sep 2011 12:31 GMT
> Sure. I got this before the error message
>
> /Applications/MATLAB_R2010aSV.app/bin/mex: line 306: gcc-4.0: command not found
> /Applications/MATLAB_R2010aSV.app/bin/mex: line 1058: gcc-4.0: command not found
>
>     mex: compile of ' "filename.c"' failed.

Please note that you need to install a C compiler first. The easiest way
is probably to download XCode from
http://developer.apple.com/xcode/index.php

Christopher
Emma Robertson - 06 Sep 2011 22:26 GMT
Hi

Thanks for the link.

I would need to upgrade my OS (to Lion) to download the Xcode you mentioned and I don't want to do that just yet.  Is there any other compiler you would suggest?
Ron Daigle - 07 Sep 2011 01:03 GMT
> Hi
>
> Thanks for the link.
>
> I would need to upgrade my OS (to Lion) to download the Xcode you mentioned and I don't want to do that just yet.  Is there any other compiler you would suggest?

Emma,

The install disc that came with your Mac should have "developer tools" under optional installs.  Installing this package should provide you with a workable version of GCC.
Christopher Creutzig - 07 Sep 2011 07:50 GMT
> I would need to upgrade my OS (to Lion) to download the Xcode you mentioned and I don't want to do that just yet.  Is there any other compiler you would suggest?

Following that link, in the big white box, in the bottom right corner,
there is a link to XCode 3. If you don't have the developer tools DVD
any more or feel you bought your system so long ago that you should get
something slightly more up to date.

HTH,
    Christopher
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2012 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.