shared_ptr_base.h 和 gnu-libstdc++ 4.9 / 4.8 的链接器错误

Linker error with shared_ptr_base.h and gnu-libstdc++ 4.9 / 4.8

我尝试编译 https://github.com/personalrobotics/OpenChisel/tree/master/open_chisel 使用它在 google tango device

上渲染

我尝试使用以下标志为 Android 4.4、ndk r10e 和 NDK_TOOLCHAIN_VERSION=4.9 (gcc 4.9) 编译它:

LOCAL_CFLAGS = -std=c++11 -frtti -fexceptions -fopenmp -w
LOCAL_LDLIBS = -llog -lGLESv2 -L$(SYSROOT)/usr/lib

包括最新的 Eigen 版本 3.2.8

我也尝试过 NDK_TOOLCHAIN_VERSION=4.8 和更早的 Eigen 版本。

但是对于 ChunkManager.cpp 文件,我总是得到以下链接器错误:

  1. Eigen/Eigen/Core (Unknown) In file included Eigen/Eigen/src/Core/util/Memory.h: In instantiation of 'void Eigen::aligned_allocator::construct(Eigen::aligned_allocator::pointer, const T&) [with T = std::_Sp_counted_ptr_inplace, (__gnu_cxx::_Lock_policy)2u>; Eigen::aligned_allocator::pointer = std::_Sp_counted_ptr_inplace, (__gnu_cxx::_Lock_policy)2u>*]':

这只是一个信息,但也许它告诉了某人一些事情

  1. android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/alloc_traits.h Information:(253, 4) :_Require::__construct_helper<_Tp, Args>::type> std::allocator_traits<_Alloc>::_S_construct(_Alloc&, _Tp*, _Args&& ...) [with _Tp = std::_Sp_counted_ptr_inplace, (__gnu_cxx::_Lock_policy)2u>; _Args = {const Eigen::aligned_allocator}; _Alloc = Eigen::aligned_allocator, (__gnu_cxx::_Lock_policy)2u> >; std::_Require::__construct_helper<_Tp, _Args>::type> = void]'

  2. android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/alloc_traits.h:399:57: required from 'static decltype (_S_construct(__a, __p, (forward<_Args>)(std::allocator_traits::construct::__args)...)) std::allocator_traits<_Alloc>::construct(_Alloc&, _Tp*, _Args&& ...) [with _Tp = std::_Sp_counted_ptr_inplace, (__gnu_cxx::_Lock_policy)2u>; _Args = {const Eigen::aligned_allocator}; _Alloc = Eigen::aligned_allocator, (__gnu_cxx::_Lock_policy)2u> >; decltype (_S_construct(__a, __p, (forward<_Args>)(std::allocator_traits::construct::__args)...)) = ]' android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/shared_ptr_base.h:620:37: required from 'std::__shared_count<_Lp>::__shared_count(std::_Sp_make_shared_tag, _Tp*, const _Alloc&, _Args&& ...) [with _Tp = chisel::Mesh; _Alloc = Eigen::aligned_allocator; _Args = {}; __gnu_cxx::_Lock_policy _Lp = (__gnu_cxx::_Lock_policy)2u]' android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/shared_ptr_base.h:1090:35: required from 'std::__shared_ptr<_Tp, _Lp>::__shared_ptr(std::_Sp_make_shared_tag, const _Alloc&, _Args&& ...) [with _Alloc = Eigen::aligned_allocator; _Args = {}; _Tp = chisel::Mesh; __gnu_cxx::_Lock_policy _Lp = (__gnu_cxx::_Lock_policy)2u]' android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/shared_ptr.h:316:64: required from 'std::shared_ptr<_Tp>::shared_ptr(std::_Sp_make_shared_tag, const _Alloc&, _Args&& ...) [with _Alloc = Eigen::aligned_allocator; _Args = {}; _Tp = chisel::Mesh]' android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/shared_ptr.h:588:39: required from 'std::shared_ptr<_Tp1> std::allocate_shared(const _Alloc&, _Args&& ...) [with _Tp = chisel::Mesh; _Alloc = Eigen::aligned_allocator; _Args = {}]' OpenChisel/open_chisel/src/ChunkManager.cpp:105:79: required from here Eigen/Eigen/src/Core/util/Memory.h:733:9: error: use of deleted function 'std::_Sp_counted_ptr_inplace, (__gnu_cxx::_Lock_policy)2u>::_Sp_counted_ptr_inplace(const std::_Sp_counted_ptr_inplace, (__gnu_cxx::_Lock_policy)2u>&)'

  3. android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/shared_ptr.h (Unknown) In file included _Sp_counted_base(_Sp_counted_base const&) = delete; ^ class _Sp_counted_ptr_inplace final : public _Sp_counted_base<_Lp> ^

  4. android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/shared_ptr_base.h Information:(494, 11) 'std::_Sp_counted_ptr_inplace, (_gnu_cxx::_Lock_policy)2u>::_Sp_counted_ptr_inplace(const std::_Sp_counted_ptr_inplace, (_gnu_cxx::_Lock_policy)2u>&)' is implicitly deleted because the default definition would be ill-formed: Error:(203, 7) error: 'std::_Sp_counted_base<_Lp>::_Sp_counted_base(const std::_Sp_counted_base<_Lp>&) [with _gnu_cxx::_Lock_policy _Lp = (_gnu_cxx::_Lock_policy)2u]' is private Error:(494, 11) error: within this context Error:(494, 11) error: use of deleted function 'std::_Sp_counted_base<_Lp>::_Sp_counted_base(const std::_Sp_counted_base<_Lp>&) [with _gnu_cxx::_Lock_policy _Lp = (_gnu_cxx::_Lock_policy)2u]' Information:(203, 7) declared here make: * [app/src/main/obj/local/armeabi-v7a/objs/rgb_point_cloud_builder/////_/third-party/OpenChisel/open_chisel/src/ChunkManager.o] Error 1

我完全迷路了。任何建议表示赞赏!

似乎是使用 Eigen 和 shared_pointer c++11 的组合导致了错误。

幸运的是有一个 patched version of chisel 它使用 boost 共享指针。