title: How do I link PCL library properly for use within an objective-C app compiled in Xcode?
body: <p>Question: How do I use PCL in the context of an Objective-C Cocoa (OSX, not iOS) app? </p>
  
  <p>Tearing my hair out over this one.I can't get libpcl to link properly with my Objective C project in Xcode. I have checked and re-checked everything I can possibly think of. Probably doing something dumb, but I'm stumped.</p>
  
  <p>Actual error is linker:</p>
  
  <pre><code>Undefined symbols for architecture x86_64:
  "pcl::PassThrough&lt;pcl::PointXYZ&gt;::applyFilterIndices(std::__1::vector&lt;int, std::__1::allocator&lt;int&gt; &gt;&amp;)", referenced from:
   pcl::PassThrough&lt;pcl::PointXYZ&gt;::applyFilter(std::__1::vector&lt;int, std::__1::allocator&lt;int&gt; &gt;&amp;) in PCLProcess.o
   ld: symbol(s) not found for architecture x86_64
  </code></pre>
  
  <ul>
  <li><p>The code I'm trying to compile is the standard tutorial code available here:
  <a href="http://pointclouds.org/documentation/tutorials/passthrough.php#passthrough" rel="nofollow">http://pointclouds.org/documentation/tutorials/passthrough.php#passthrough</a></p></li>
  <li><p>I CAN get it to work without Xcode (using Cmake and command line compiling exactly as in the tutorial)</p></li>
  <li><p>I CAN create a "command line" project and compile and link a one-off CPP file using Xcode</p></li>
  <li><p>The issue is the same no matter what version of PCL I've tried. Macports, binary distro, self-compiled 1.6 and trunk. All the same result. </p></li>
  <li><p>I've tried several different machines, OSX 10.7 and 10.8, same issue on both.</p></li>
  <li><p>I've even run nm against the dylib to verify the missing symbols are in the library I'm linking (filters in this case)</p></li>
  </ul>
  
  <p>Any thoughts much appreciated, I've lost half a week to this.</p>
  
  <p>See <a href="https://dl.dropboxusercontent.com/u/930604/Personal/screenshot.png" rel="nofollow">this screenshot</a> for a detailed error message.</p>
  
  <p>Here is the code in question:</p>
  
  <pre><code>//PCLProcess.h
  #import &lt;Foundation/Foundation.h&gt;
  @interface PCLProcess : NSObject
  @end
  
  //PCLProcess.mm
  #import "PCLProcess.h"
  #include &lt;pcl/point_types.h&gt;
  #include &lt;pcl/filters/passthrough.h&gt;
  
  @implementation PCLProcess
  
  -(void)tryThis{
     // Code cut and pasted from tutoral (see link above)
  }
  
  @end
  </code></pre>
  
  <h2>Update</h2>
  
  <p>Here is one more clue. I am in over my head with respect to compilers/linkers and how they work, but now I think I know what is happening but not why (or how to fix it). </p>
  
  <ul>
  <li><p>I ran the linker tool manually, and out of desperation I started plugging in obsolete flags just to see what the results were. The previous error (above) identifies the missing symbols as ""pcl::PassThrough::applyFilterIndices(std::__1::vector >&amp;)" but  ld -y gave me this:</p>
  
  <p>ld: warning: option -y is obsolete and being ignored 
  Undefined symbols for architecture  x86_64:"__ZN3pcl11PassThroughINS_8PointXYZEE18applyFilterIndicesERNSt3__16vectorIiNS3_9allocatorIiEEEE", referenced        from:__ZN3pcl11PassThroughINS_8PointXYZEE11applyFilterERNSt3__16vectorIiNS3_9allocatorIiEEEE in PCLProcess.o 
  ld: symbol(s) not found for architecture x86_64</p></li>
  </ul>
  
  <p>So then I went looking for that symbol and, sure enough, it's missing (or different):</p>
  
  <pre><code>nm /opt/local/lib/libpcl_filters.dylib | grep __ZN3pcl11PassThroughINS_8PointXYZEE18applyFilterIndices
  00000000000a0fa0 
  T  __ZN3pcl11PassThroughINS_8PointXYZEE18applyFilterIndicesERSt6vectorIiSaIiEE
  </code></pre>
  
  <p>I suspect name mangling? But again, I'm not really sure what I'm talking about at this point or (more importantly) how to fix it. </p>