我正在尝试编译一个项目Kintinuous使用pcl-1.7。但是我遇到了一些错误。我在Google上搜索了很长时间,但我仍然不知道。我是编程的新手。请帮我。错误看起来像这样:
In file included from /usr/include/flann/util/matrix.h:35:0,
from /usr/include/flann/flann.hpp:41,
from /usr/include/pcl-1.7/pcl/kdtree/flann.h:50,
from /usr/include/pcl-1.7/pcl/kdtree/kdtree_flann.h:45,
from /data2/houzhixing/Kintinuous/src/backend/DeformationGraph.h:27,
from /data2/houzhixing/Kintinuous/src/backend/DeformationGraph.cpp:19:
/usr/include/flann/util/serialization.h: In instantiation of 'static void flann::serialization::access::serialize(Archive&, T&) [with Archive = flann::serialization::LoadArchive; T = std::unordered_map<unsigned int, std::vector<unsigned int> >]':
/usr/include/flann/util/serialization.h:26:30: required from 'void flann::serialization::serialize(Archive&, T&) [with Archive = flann::serialization::LoadArchive; T = std::unordered_map<unsigned int, std::vector<unsigned int> >]'
/usr/include/flann/util/serialization.h:35:40: required from 'static void flann::serialization::Serializer<T>::load(InputArchive&, T&) [with InputArchive = flann::serialization::LoadArchive; T = std::unordered_map<unsigned int, std::vector<unsigned int> >]'
/usr/include/flann/util/serialization.h:276:61: required from 'Archive& flann::serialization::InputArchive<Archive>::operator&(T&) [with T = std::unordered_map<unsigned int, std::vector<unsigned int> >; Archive = flann::serialization::LoadArchive]'
/usr/include/flann/util/lsh_table.h:319:10: required from 'void flann::lsh::LshTable<ElementType>::serialize(Archive&) [with Archive = flann::serialization::LoadArchive; ElementType = float]'
/usr/include/flann/util/serialization.h:18:9: required from 'static void flann::serialization::access::serialize(Archive&, T&) [with Archive = flann::serialization::LoadArchive; T = flann::lsh::LshTable<float>]'
/usr/include/flann/util/serialization.h:26:30: [ skipping 6 instantiation contexts, use -ftemplate-backtrace-limit=0 to disable ]
/usr/include/flann/util/serialization.h:18:9: required from 'static void flann::serialization::access::serialize(Archive&, T&) [with Archive = flann::serialization::LoadArchive; T = flann::LshIndex<flann::L2_Simple<float> >]'
/usr/include/flann/util/serialization.h:26:30: required from 'void flann::serialization::serialize(Archive&, T&) [with Archive = flann::serialization::LoadArchive; T = flann::LshIndex<flann::L2_Simple<float> >]'
/usr/include/flann/util/serialization.h:35:40: required from 'static void flann::serialization::Serializer<T>::load(InputArchive&, T&) [with InputArchive = flann::serialization::LoadArchive; T = flann::LshIndex<flann::L2_Simple<float> >]'
/usr/include/flann/util/serialization.h:276:61: required from 'Archive& flann::serialization::InputArchive<Archive>::operator&(T&) [with T = flann::LshIndex<flann::L2_Simple<float> >; Archive = flann::serialization::LoadArchive]'
/usr/include/flann/algorithms/lsh_index.h:204:9: required from 'void flann::LshIndex<Distance>::loadIndex(FILE*) [with Distance = flann::L2_Simple<float>; FILE = _IO_FILE]'
/data2/houzhixing/Kintinuous/src/backend/DeformationGraph.cpp:1054:1: required from here
/usr/include/flann/util/serialization.h:18:9: error: 'class std::unordered_map<unsigned int, std::vector<unsigned int> >' has no member named 'serialize'
type.serialize(ar);
^
/usr/include/flann/util/serialization.h: In instantiation of 'static void flann::serialization::access::serialize(Archive&, T&) [with Archive = flann::serialization::SaveArchive; T = std::unordered_map<unsigned int, std::vector<unsigned int> >]':
/usr/include/flann/util/serialization.h:26:30: required from 'void flann::serialization::serialize(Archive&, T&) [with Archive = flann::serialization::SaveArchive; T = std::unordered_map<unsigned int, std::vector<unsigned int> >]'
/usr/include/flann/util/serialization.h:40:56: required from 'static void flann::serialization::Serializer<T>::save(OutputArchive&, const T&) [with OutputArchive = flann::serialization::SaveArchive; T = std::unordered_map<unsigned int, std::vector<unsigned int> >]'
/usr/include/flann/util/serialization.h:294:61: required from 'Archive& flann::serialization::OutputArchive<Archive>::operator&(const T&) [with T = std::unordered_map<unsigned int, std::vector<unsigned int> >; Archive = flann::serialization::SaveArchive]'
/usr/include/flann/util/lsh_table.h:319:10: required from 'void flann::lsh::LshTable<ElementType>::serialize(Archive&) [with Archive = flann::serialization::SaveArchive; ElementType = float]'
/usr/include/flann/util/serialization.h:18:9: required from 'static void flann::serialization::access::serialize(Archive&, T&) [with Archive = flann::serialization::SaveArchive; T = flann::lsh::LshTable<float>]'
/usr/include/flann/util/serialization.h:26:30: [ skipping 6 instantiation contexts, use -ftemplate-backtrace-limit=0 to disable ]
/usr/include/flann/util/serialization.h:18:9: required from 'static void flann::serialization::access::serialize(Archive&, T&) [with Archive = flann::serialization::SaveArchive; T = flann::LshIndex<flann::L2_Simple<float> >]'
/usr/include/flann/util/serialization.h:26:30: required from 'void flann::serialization::serialize(Archive&, T&) [with Archive = flann::serialization::SaveArchive; T = flann::LshIndex<flann::L2_Simple<float> >]'
/usr/include/flann/util/serialization.h:40:56: required from 'static void flann::serialization::Serializer<T>::save(OutputArchive&, const T&) [with OutputArchive = flann::serialization::SaveArchive; T = flann::LshIndex<flann::L2_Simple<float> >]'
/usr/include/flann/util/serialization.h:294:61: required from 'Archive& flann::serialization::OutputArchive<Archive>::operator&(const T&) [with T = flann::LshIndex<flann::L2_Simple<float> >; Archive = flann::serialization::SaveArchive]'
/usr/include/flann/algorithms/lsh_index.h:198:9: required from 'void flann::LshIndex<Distance>::saveIndex(FILE*) [with Distance = flann::L2_Simple<float>; FILE = _IO_FILE]'
/data2/houzhixing/Kintinuous/src/backend/DeformationGraph.cpp:1054:1: required from here
/usr/include/flann/util/serialization.h:18:9: error: 'class std::unordered_map<unsigned int, std::vector<unsigned int> >' has no member named 'serialize'
make[2]: *** [CMakeFiles/backend.dir/backend/DeformationGraph.cpp.o] Error 1
make[1]: *** [CMakeFiles/backend.dir/all] Error 2
make: *** [all] Error 2
提前致谢。
答案 0 :(得分:3)
我在不同的库上遇到了同样的问题,它依赖于flann并由https://github.com/mariusmuja/flann/issues/214
修复如果我们在一些opencv标头之后包含了flann标头并使用了
g++ -std=c++11
,那么序列化代码中就会出现一个神秘的错误。更改包含顺序修复了问题(包括任何opencv标头之前的flann标头)。在std≥C++ 11的情况下,似乎opencv头文件泄漏#define USE_UNORDERED_MAP 1
。然后由原始flann库中的lsh_table.h中的#if
获取。
解决方案是在OpenCV之前包含flann。