title: Open Watcom Linker finding undefined references when linking C and Fortran code to build Matlab mex file
body: <p>Using Windows 7, Matlab R2011a (32-bit), and Open Watcom Version 1.8, I am attempting to compile a C MEX file that calls Fortran code.</p>
  
  <p>Following directions posted on the Matlab website (<a href="http://www.mathworks.com/support/solutions/en/data/1-155BQG/?solution=1-155BQG" rel="nofollow">support link</a>), I've first compiled a Fortran object file using the following command:</p>
  
  <pre><code>wfl386 -c -fpi87 -SC getqpf.f
  </code></pre>
  
  <p>I've then attempted to link the object file to a number of C files.  All of the C files compile properly, but I receive the following link error.  The undefined references are for functions in the C files called from a subroutine in <code>getqpf.f</code>.   For example, <code>QESTM</code> is defined as a function in one of the C files as <code>int qestm_()</code>.</p>
  
  <p>The <code>q_estimate.c</code> file contains the entry point function for the MEX program.  The idea is for the entry point function to call the subroutine in <code>getqpf.f</code>.  The subroutine in <code>getqpf.f</code> calls the C code functions in the other files.  </p>
  
  <p>How might I get rid of the undefined references?</p>
  
  <pre><code>&gt;&gt; mex q_estimate.c paul2.c paul2_L1.c paul6.c paul6_L1.c runavg.c fit_slope.c getqpf.obj
  Open Watcom Linker Version 1.8 
  Portions Copyright (c) 1985-2002 Sybase, Inc. All Rights Reserved. 
  Source code is available under the Sybase Open Watcom Public License. 
  See http://www.openwatcom.org/ for details. 
  loading object files 
  searching libraries 
  Error! E2028: QESTM is an undefined reference 
  Error! E2028: QESTM1 is an undefined reference 
  Error! E2028: QESTF is an undefined reference 
  Error! E2028: QESTF1 is an undefined reference 
  creating a Windows NT dynamic link library 
  file getqpf.obj(E:\DEVELOPMENT-FINAL\EXPERIMENTS\test-Q-analysis\getqpf.f): undefined symbol QESTM 
  file getqpf.obj(E:\DEVELOPMENT-FINAL\EXPERIMENTS\test-Q-analysis\getqpf.f): undefined symbol QESTM1 
  file getqpf.obj(E:\DEVELOPMENT-FINAL\EXPERIMENTS\test-Q-analysis\getqpf.f): undefined symbol QESTF 
  file getqpf.obj(E:\DEVELOPMENT-FINAL\EXPERIMENTS\test-Q-analysis\getqpf.f): undefined symbol QESTF1 
    C:\PROGRA~2\MATLAB\R2011A~1\BIN\MEX.PL: Error: Link of 'q_estimate.mexw32' failed. 
  </code></pre>