TypeInfo exception while including pcl library

On 21/10/2013 at 22:41, xxxxxxxx wrote:

User Information:
Cinema 4D Version:   14 
Platform:      Mac OSX  ; 
Language(s) :     C++  ;

I am trying to include a pcl library into plugin. pcl builds use typeid and typeinfo statements, which require me to disable -fno-rtti flag to compile (Set "Enable C++ Runtime Types to YES" in build settings). This leads to the following error in linking phase below.
Is there a way around it?

Ld ./objectify.dylib normal x86_64
    cd "/Applications/MAXON/CINEMA 4D R14/plugins/objectify"
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch x86_64 -dynamiclib "-L/Applications/MAXON/CINEMA 4D R14/plugins/objectify/../../../../(build)/Debug" -L../../resource/_api_lib "-F/Applications/MAXON/CINEMA 4D R14/plugins/objectify/../../../../(build)/Debug" -filelist "/Applications/MAXON/CINEMA 4D R14/plugins/objectify/../../../../(build)/objectify.build/Debug/objectify.build/Objects-normal/x86_64/objectify.LinkFileList" -exported_symbols_list ../../resource/_api_lib/export.txt -install_name /./objectify.dylib -mmacosx-version-min=10.6 -dead_strip -no_dead_strip_inits_and_terms ../../resource/_api_lib/lib_api_debug.a -single_module -compatibility_version 1 -current_version 1 -o "/Applications/MAXON/CINEMA 4D R14/plugins/objectify/./objectify.dylib"

Undefined symbols for architecture x86_64:
  "typeinfo for ObjectData", referenced from:
      typeinfo for Objectify in objectify.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

On 22/10/2013 at 10:53, xxxxxxxx wrote:

This is how I would do it

1. Move all your pcl stuff into a separate *.h and *.cpp. Only *.cpp should contain the pcl includes;
2. Add an include for your pcl header in your plugin class
3. Set "Enable C++ Runtime Types to YES" for your target
4. Go to Build Phases ->Compile Sources, Double click on the main file and add -fno-rtti compiler option.

This should in principle enable RTTI for the entire project except the main plugin class.



On 23/10/2013 at 20:51, xxxxxxxx wrote:

Thanks @eight_io. This works exactly. However, now I am getting weird boost's shared pointer deallocation errors, while exiting the plugin. Any ideas how to fix signal SIGABRT with the trace below?

#4 0x0000000117b41f3e in void
boost::checked_deletepcl::search::KdTree<pcl::PointXYZ (pcl::search::KdTreepcl::PointXYZ* ) at
#5 0x0000000117b42059 in
boost::detail::sp_counted_impl_ppcl::search::KdTree<pcl::PointXYZ::dispose() at
#6 0x0000000117b41bd2 in boost::detail::sp_counted_base::release() at
#7 0x0000000117b41b7d in boost::detail::shared_count::~shared_count() at
#8 0x0000000117b41b45 in boost::detail::shared_count::~shared_count() at
#9 0x0000000117b460dc in
boost::shared_ptrpcl::search::KdTree<pcl::PointXYZ >::~shared_ptr() at
#10 0x0000000117b41495 in
boost::shared_ptrpcl::search::KdTree<pcl::PointXYZ >::~shared_ptr() at
#11 0x0000000117b40ff2 in
std::allocator<float> >, std::allocator<std::vector<float,
std::allocator<float> > > >&) at /Applications/MAXON/CINEMA 4D
#12 0x0000000117b3c01b in Objectify::GetVirtualObjects(BaseObject*,
HierarchyHelp* ) at /Applications/MAXON/CINEMA 4D
#13 0x00000001007c04a1 in ___lldb_unnamed_function19295$$CINEMA 4D ()

On 24/10/2013 at 07:17, xxxxxxxx wrote:

Hard to say without looking at the code, but it seems that this is the issue of using shared pointer. Read the boost best practices on using shared pointers: 1) use named variables for shared pointers 2) use make_shared to allocate them. In the interim, you could also declare them as global variables instead method variables -- that will bomb when you exit Cinema but not earlier.