title: Calling C++ method from Objective C
body: <p>I have the following files.</p>
  
  <p>foo.h (C++ header file) <br/>
  foo.mm (C++ file) <br/>
  test_viewcontroller.h (objective c header file) <br/>
  test_viewcontroller.m (Objective c file)</p>
  
  <p>I have declared a method donothing() in foo.h and defined it in foo.mm.Lets say it is</p>
  
  <blockquote>
    <p>double donothing(double a)
    {
         return a;
    }</p>
  </blockquote>
  
  <p>Now,I try to call this function in test_viewcontroller.m</p>
  
  <blockquote>
    <p>double var = donothing(somevar);</p>
  </blockquote>
  
  <p>I get linker error which says "cannot find symbols" _donothing() in test_viewcontroller.o <br/> collect2: ld returned 1 exit status</p>
  
  <p>Can anyone please point me as to what is wrong? <br/></p>
  
  <hr>
  
  <p>Let me be precise :</p>
  
  <pre><code>#ifdef __cplusplus 
  
  extern "C" 
  {
        char UTMLetterDesignator(double Lat);
        NSString * LLtoUTM(double Lat,double Long,double UTMNorthing, double UTMEasting);
        double test(double a);
  }
  
  #endif
  </code></pre>
  
  <p>@Carl</p>
  
  <p>I have included my code sample.Are saying that I need to wrap only the test() method in ifdef.I dont understand what difference it can make.Can you please explain?</p>