Fwd: [MATLAB Central] Re: MEX Setup for Mac OS X 10.6

brian arnold, at mathworks, generally gives good advice, so i'm forwarding his email about creating a MEX.

best

denis

Denis Pelli
Professor of Psychology and Neural Science
New York University
http://psych.nyu.edu/pelli/

Begin forwarded message:

From: MATLAB Central Newsreader <newsreader@...>
Date: April 14, 2010 11:45:11 AM EDT
Subject: [MATLAB Central] Re: MEX Setup for Mac OS X 10.6

Here are the latest results from your watch list at the MATLAB Central Newsreader. To edit your watch list, or unsubscribe from e-mails, go to your profile page.

Subject: Re: MEX Setup for Mac OS X 10.6
From: Brian Arnold <Brian.Arnold@...>
Date: Wed Apr 14 15:29:17 -0400 2010

Hi Robert,

OK. You're now past PATH issues and into build issues.

Are the missing symbols expected to be in the compiled code that you are
linking, or are they expected to be in a separate static or dynamic
library? If you have multiple source files that you want linked into
one library, make sure the file you are compiling for the MEX command is
including all of the source code you need (not just the header files).
If you are linking your code against other libraries, check that all of
the libraries that you need to link against have been built with the
correct symbols, and that you have -l paths to all of the libraries (in
the case of frameworks, -framework...). You may want to use other
command line development tools such as the 'nm' tool to diagnose missing
symbol problems.

To check that MEX is working using yprime.c, make a copy of the file in
your home folder or some other writable location, cd to the folder
containing your copy, and then run 'mex yprime.c'. The file should be
located here:

/Applications/MATLAB_R2010b.app/extern/examples/mex/yprime.c

Check out the other examples for increasing complexity.

Good luck,

- Brian

Robert wrote:
> Thanks for your help. I don't remember making a startup script, and I
> can't find any .login, .bash, or similar files. 'echo $PATH' gives me
> '/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin'.
>
> I just upgraded to XCode 3.2 though, and now 'gcc --version' in the
> Terminal is finding 'i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple
> Inc. build 5659)'. Running 'mex -setup' now seems to get the right
> configuration.
>
> However, now I'm getting errors about "undefined symbols" that look like
> they're problems with linking. The undefined symbols are functions and
> classes from other C++ files in the same folder, for which I've added
> #include lines for the corresponding .h files. In an attempt to
> troubleshoot I tried running 'mex yprime.c' as suggested at
> http://www.mathworks.com/support/tech-notes/1600/1605.html. But I
> cannot even begin to start troubleshooting since Matlab cannot find that
> file. Why not? I don't think I've removed anything from my path.
>
> Thanks,
> ~Robert
>
>
> Brian Arnold <Brian.Arnold@...> wrote in message
> <hpl74k$6cn$1@...>...
>> Hi Robert,
>>
>> If gcc isn't on the path when you open a new Terminal window ("command
>> not found") and you know that it's located in /usr/bin, then you
>> probably have a shell startup script file somewhere that is changing
>> the PATH environment variable, which can cause all manner of problems
>> (not just this one).
>>
>> In Terminal, type 'echo $PATH' and examine what it returns. If it
>> doesn't start with /usr/bin:, then there's your problem. It's very
>> likely that if it contains anything besides the default system paths,
>> then it probably contains the name of the thing that will remind you
>> why PATH got redefined. You need to locate the offending shell file
>> redefining PATH, and either fix it or remove it.
>>
>> Common startup script file names (where ~ means your home directory)
>> include ~/.login, ~/.bashrc, ~/.bash_login, ~/.bash_profile ~/.cshrc,
>> ~/.xinitrc, ~/.MacOSX/environment.plist, and so on. Type 'ls -la ~'
>> to find these hidden folders and files and inspect them for lines that
>> change PATH.
>>
>> I'd definitely install Xcode 3.2 for OS X 10.6.2 to avoid other issues
>> and ensure that you have the current gcc compilers, but I don't think
>> that will resolve your first issue. FWIW, on 10.6.2 with Xcode 3.2,
>> the gcc alias should point to gcc-3.2, but MATLAB MEX will use an
>> explicit gcc version number, and not use the alias, which is expected
>> behavior.
>>
>> Report back if you are having success, or other issues with MATLAB MEX.
>>
>> Thanks,
>>
>> - Brian

View thread: http://www.mathworks.com/matlabcentral/newsreader/view_thread/272685#736108