title: ObjC app project gets build error at its reference to a C function within a .cpp file within ObjC class lib imported into app
body: <p>Project “app” gets build err:   &quot;Undefined symbol: run_mobile_session()&quot;</p>
  <p>Proj app includes ObjC class lib project hub_lib.</p>
  <p>Proj hub_lib has folder with main.cpp file that has function &quot;run_mobile_session()&quot; that is undefined in app build</p>
  <ol>
  <li>I build without error the hub_lib project and did ctrl-drag of its .h and .a from its Xcode folders pane to a folder within project app.</li>
  <li>I dragged .h &amp; .a from folder within app to folder pane of app.  (ie. imported)</li>
  <li>I selected target to be my provisioned iPhone.</li>
  <li>Built app, got error.</li>
  </ol>
  <p>I ran nm on  and get this...</p>
  <pre><code>DOUGs-MacBook-Pro:mobile_sys_hub_lib dbell$ nm libmobile_sys_hub_lib.a | grep run_mobile_session
                   U __Z18run_mobile_sessionv
  DOUGs-MacBook-Pro:mobile_sys_hub_lib  
  </code></pre>
  <p>The U at the front of the line is &quot;undefined&quot;. nm thinks you have a reference to the symbol but no implementation. – Phillip Mills</p>
  <p>Doug:  main.cpp seems to be getting compiled in the class lib:  I put junk &quot;zzzzzz&quot; within run_mobile_session() and get build error.</p>
  <p>THE CODE...</p>
  <pre><code>------------------------------------------- ObjC app project...
  
  //app.h ...........................
  
  #import &lt;UIKit/UIKit.h&gt;
  
  @interface ViewController : UIViewController
  @end
  
  
  // ViewController.mm  ....................
  
  
  #import &lt;UIKit/UIKit.h&gt;
  #import &quot;hub_lib.h&quot;
  
  @interface ViewController ()    
  @end
  
  @implementation ViewController
  
  . . .  
  
  - (IBAction)start_session:(id)sender
  {
      hub_lib* _lib = [hub_lib    new];
  
      NSLog(@&quot;app:     %d&quot;, [ _lib    start_session]);
  }
  @end
  
  
  
  
  
  ---------------------------------------   lib project...
  // hub_lib.h ....................
  
  #import &lt;Foundation/Foundation.h&gt;
  
  @interface hub_lib : NSObject
  @end
  
  
  
  // hub_lib.mm  ......................................  
  
  #import &quot;hub_lib.h&quot;
  #import &lt;UIKit/UIKit.h&gt;
  
  @implementation hub_lib
  
  extern void run_mobile_session(void);
  
  . . .  
  
  -(int)start_session
  {
          run_mobile_session();
  
    return 0;
  }
  
  @end
  
  
  ---------------------------------------   C++ folder within lib project...
  // main.cpp .....................
  
  #include &lt;stdio.h&gt;
  void run_mobile_session(void);
  
  . . .
  
  void run_mobile_session(void)
  {
     . . .
  }
  </code></pre>