title: Calling C function/subroutine in Fortran code
body: <p>I am attempting to compile and link a Fortran code calling c subroutine:</p>
  
  <p>Fortran code:</p>
  
  <pre><code>program adder
  integer a,b
  a=1
  b=2
  call addnums(a,b)
  stop    
  end program
  </code></pre>
  
  <p>C code:</p>
  
  <pre><code>void addnums( int* a, int* b ) 
  {
      int c = (*a) + (*b);  /* convert pointers to values, then add them */
      printf("sum of %i and %i is %i\n", (*a), (*b), c );
  }
  </code></pre>
  
  <p>I used the following commands to compile and link in windows environment.</p>
  
  <pre><code>ifort -c adder.f
  cl -c addnums.c
  ifort -o add adder.obj addnums.obj
  </code></pre>
  
  <p>I get the following error:</p>
  
  <pre><code>Microsoft (R) Incremental Linker Version 8.00.50727.762
  Copyright (C) Microsoft Corporation.  All rights reserved.
  -out:add.exe 
  -subsystem:console 
  adder.obj 
  addnums.obj 
  adder.obj : error LNK2019: unresolved external symbol ADDNUMS referenced in function MAIN__
  add.exe : fatal error LNK1120: 1 unresolved externals
  </code></pre>
  
  <p>Please help me resolve this issue? Thanks.</p>