title: OS X Lion, Matlab 2011a, Mex: Undefined symbols for architecture x86_64
body: <p>Hello Fellow Matlab/OS X Users,</p>
  
  <p>I was wondering if you can help me out once again.
  I got here a c-file (st.c, a Stockwell time-frequency analysis for MEG-Data) for Matlab which I should compile for my system (OS X Lion, Xcode 4.1.1).
  It includes</p>
  
  <pre><code>#include &lt;fftw3.h&gt;
  </code></pre>
  
  <p>So I downloaded the newest Version from <a href="http://www.fftw.org/" rel="nofollow">http://www.fftw.org/</a> and compiled it.
  So far so good. But if I try to compile the c file</p>
  
  <pre><code>mex -st.c
  </code></pre>
  
  <p>I get the following error:</p>
  
  <pre><code>-&gt; gcc-4.2 -O -Wl,-twolevel_namespace -undefined error -arch x86_64 -Wl,-syslibroot,/Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.5 -bundle -Wl,-exported_symbols_list,/Applications/MATLAB_R2011a.app/extern/lib/maci64/mexFunction.map -o  "st.mexmaci64"  st.o  -L/Applications/MATLAB_R2011a.app/bin/maci64 -lmx -lmex -lmat -lstdc++
  Undefined symbols for architecture x86_64:
    "_fftw_destroy_plan", referenced from:
        _ist in st.o
        _st in st.o
    "_fftw_free", referenced from:
        _ist in st.o
        _st in st.o
    "_fftw_malloc", referenced from:
        _ist in st.o
        _st in st.o
    "_fftw_import_wisdom_from_file", referenced from:
        _ist in st.o
        _st in st.o
    "_fftw_plan_dft_1d", referenced from:
        _ist in st.o
        _st in st.o
    "_fftw_export_wisdom_to_file", referenced from:
        _ist in st.o
        _st in st.o
    "_fftw_execute", referenced from:
        _ist in st.o
        _st in st.o
    "_mexFunction", referenced from:
       -exported_symbol[s_list] command line option
  ld: symbol(s) not found for architecture x86_64
  collect2: ld returned 1 exit status
  
      mex: link of ' "st.mexmaci64"' failed.
  </code></pre>
  
  <p>(I should say that compiling the c-file from the Matlab example (yprime.c) works without any problem.)
  By googling I couldnt find to much, but there was someone suggesting the following:</p>
  
  <blockquote>
    <p>MATLAB needs to   link 64-bit (x86_64). You'll need to find a working
    64-bit gfortran   compiler whose libraries are 64-bit and
    ABI-compatible with Apple's gcc.</p>
  </blockquote>
  
  <p>Here <a href="http://r.research.att.com/tools/" rel="nofollow">http://r.research.att.com/tools/</a> I found GNU Fortran 4.2.4 for Mac OS X 10.7.
  But this didnt change anything, the error remains the same.</p>
  
  <p>I guess the architecture is compiled in the wrong way, but I have no idea how to change that for Matlab/Xcode. If this is the case, could someone pls tell me how to do it ?</p>
  
  <p>Thanks for your Help</p>