How do I link PCL library properly for use within an objective-C app compiled in Xcode?

Question: How do I use PCL in the context of an Objective-C Cocoa (OSX, not iOS) app?

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.

Actual error is linker:

Undefined symbols for architecture x86_64:
"pcl::PassThrough<pcl::PointXYZ>::applyFilterIndices(std::__1::vector<int, std::__1::allocator<int> >&)", referenced from:
 pcl::PassThrough<pcl::PointXYZ>::applyFilter(std::__1::vector<int, std::__1::allocator<int> >&) in PCLProcess.o
 ld: symbol(s) not found for architecture x86_64
  • The code I'm trying to compile is the standard tutorial code available here:

  • I CAN get it to work without Xcode (using Cmake and command line compiling exactly as in the tutorial)

  • I CAN create a "command line" project and compile and link a one-off CPP file using Xcode

  • 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.

  • I've tried several different machines, OSX 10.7 and 10.8, same issue on both.

  • I've even run nm against the dylib to verify the missing symbols are in the library I'm linking (filters in this case)

Any thoughts much appreciated, I've lost half a week to this.

See this screenshot for a detailed error message.

Here is the code in question:

#import <Foundation/Foundation.h>
@interface PCLProcess : NSObject

#import "PCLProcess.h"
#include <pcl/point_types.h>
#include <pcl/filters/passthrough.h>

@implementation PCLProcess

   // Code cut and pasted from tutoral (see link above)


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).

  • 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 >&)" but ld -y gave me this:

    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

So then I went looking for that symbol and, sure enough, it's missing (or different):

nm /opt/local/lib/libpcl_filters.dylib | grep __ZN3pcl11PassThroughINS_8PointXYZEE18applyFilterIndices
T  __ZN3pcl11PassThroughINS_8PointXYZEE18applyFilterIndicesERSt6vectorIiSaIiEE

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.


Short answer:

Two Build settings under "Build Options":

C++ Language Dialect: GNU++98[-std=gnu++98]

C++ Standard Library: libstdc++ (GNU C++ standard library)

This second setting (C++ Standard Library) is the crucial one; Using libc++ will produce the "undefined symbols" linker errors shown in the question above.

Details for anyone trying this:

This works with Xcode 4.62, llvm4.2, libpcl 1.7 (currently dev, I compiled from trunk) and boost 1.53. Along the way I ran into a known issue with Boost and Cocoa involving the use of nil (see this link: and also some strangeness with boost traits (see this:c++: Boost 1.48 type traits and Cocoa inclusion weirdness) Consequently I ended up including PCL headers as follows:

#define nil Boost_nil
#define Nil Boost_Nil
#ifdef check
#undef check

#include <pcl/pcl_base.h>
#include <pcl/point_types.h>
#include <pcl/filters/passthrough.h>

#undef Nil
#undef nil

Need Your Help

Setting sample rate on AUHAL

osx core-audio voip audiounit sample-rate

I'm using Audio Unit Framework to develop a VOIP app on mac os x.

CSS transitions: Strange unwanted delay in Webkit browsers (Chrome and Safari)

html css3 cross-browser webkit css-transitions

I was hoping someone could help explain the strange behaviour I'm experiencing in Webkit browsers with unwanted delays in CSS transitions.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.