kzampog / cilantro

A lean C++ library for working with point cloud data
MIT License
1.03k stars 208 forks source link

how to use this library in my project? #52

Closed Gaoqinghong91 closed 4 years ago

Gaoqinghong91 commented 4 years ago

are there any examples about how to write CMakeLists. and how to this library in my project when i write a CMakeLists and make the "non_rigid_icp.cpp" , but i get mistake like:

[ 50%] Building CXX object CMakeFiles/gen.dir/non_rigid_icp.cpp.o [100%] Linking CXX executable gen CMakeFiles/gen.dir/non_rigid_icp.cpp.o: In function color_toggle(cilantro::Visualizer&)': non_rigid_icp.cpp:(.text+0x17a): undefined reference tocilantro::Visualizer::getRenderingProperties(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&) const' non_rigid_icp.cpp:(.text+0x1a5): undefined reference to cilantro::RenderingProperties::noColor' non_rigid_icp.cpp:(.text+0x1de): undefined reference tocilantro::RenderingProperties::noColor' non_rigid_icp.cpp:(.text+0x230): undefined reference to `cilantro::Visualizer::setRenderingProperties(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, cilantro::RenderingProperties const&)' non_rigid_icp.cpp:(.text+0x295): undefined reference to cilantro::Visualizer::getRenderingProperties(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const' non_rigid_icp.cpp:(.text+0x2e5): undefined reference tocilantro::RenderingProperties::noColor' non_rigid_icp.cpp:(.text+0x31e): undefined reference to cilantro::RenderingProperties::noColor' non_rigid_icp.cpp:(.text+0x370): undefined reference tocilantro::Visualizer::setRenderingProperties(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, cilantro::RenderingProperties const&)' CMakeFiles/gen.dir/non_rigid_icp.cpp.o: In function warp_toggle(cilantro::Visualizer&)': non_rigid_icp.cpp:(.text+0x4e9): undefined reference tocilantro::Visualizer::toggleVisibility(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&)' CMakeFiles/gen.dir/non_rigid_icp.cpp.o: In function main': non_rigid_icp.cpp:(.text+0xf07): undefined reference tocilantro::Visualizer::Visualizer(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, std::cxx11::basic_string<char, std::char_traits, std::allocator > const&)' non_rigid_icp.cpp:(.text+0xf6f): undefined reference to `cilantro::Visualizer::Visualizer(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, std::cxx11::basic_string<char, std::char_traits, std::allocator > const&)' non_rigid_icp.cpp:(.text+0xfd7): undefined reference to `cilantro::Visualizer::Visualizer(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, std::cxx11::basic_string<char, std::char_traits, std::allocator > const&)' non_rigid_icp.cpp:(.text+0x10c2): undefined reference to cilantro::Visualizer::registerKeyboardCallback(unsigned char, std::function<void ()>)' non_rigid_icp.cpp:(.text+0x1136): undefined reference tocilantro::Visualizer::registerKeyboardCallback(unsigned char, std::function<void ()>)' non_rigid_icp.cpp:(.text+0x13e6): undefined reference to cilantro::Visualizer::registerKeyboardCallback(unsigned char, std::function<void ()>)' non_rigid_icp.cpp:(.text+0x171a): undefined reference tocilantro::Visualizer::clearRenderArea()' non_rigid_icp.cpp:(.text+0x1729): undefined reference to cilantro::Visualizer::render()' non_rigid_icp.cpp:(.text+0x1738): undefined reference tocilantro::Visualizer::render()' non_rigid_icp.cpp:(.text+0x1747): undefined reference to cilantro::Visualizer::render()' non_rigid_icp.cpp:(.text+0x1774): undefined reference tocilantro::Visualizer::~Visualizer()' non_rigid_icp.cpp:(.text+0x1783): undefined reference to cilantro::Visualizer::~Visualizer()' non_rigid_icp.cpp:(.text+0x1792): undefined reference tocilantro::Visualizer::~Visualizer()' non_rigid_icp.cpp:(.text+0x1c04): undefined reference to cilantro::Visualizer::~Visualizer()' non_rigid_icp.cpp:(.text+0x1c13): undefined reference tocilantro::Visualizer::~Visualizer()' CMakeFiles/gen.dir/non_rigid_icp.cpp.o:non_rigid_icp.cpp:(.text+0x1c22): more undefined references to cilantro::Visualizer::~Visualizer()' follow CMakeFiles/gen.dir/non_rigid_icp.cpp.o: In functioncilantro::PLYReader::PLYReader(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, bool)': non_rigid_icp.cpp:(.text._ZN8cilantro9PLYReaderC2ERKNSt7cxx1112basic_stringIcSt11char_traitsIcESaIcEEEb[_ZN8cilantro9PLYReaderC5ERKNSt7cxx1112basic_stringIcSt11char_traitsIcESaIcEEEb]+0x42): undefined reference to `tinyply::PlyFile::PlyFile()' non_rigid_icp.cpp:(.text._ZN8cilantro9PLYReaderC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEb[_ZN8cilantro9PLYReaderC5ERKNSt7cxx1112basic_stringIcSt11char_traitsIcESaIcEEEb]+0x103): undefined reference to tinyply::PlyFile::parse_header(std::istream&)' non_rigid_icp.cpp:(.text._ZN8cilantro9PLYReaderC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEb[_ZN8cilantro9PLYReaderC5ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEb]+0x138): undefined reference totinyply::PlyFile::~PlyFile()' CMakeFiles/gen.dir/non_rigid_icp.cpp.o: In function cilantro::PLYReader::elementPropertyExists(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&) const': non_rigid_icp.cpp:(.text._ZNK8cilantro9PLYReader21elementPropertyExistsERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt6vectorIS6_SaIS6_EE[_ZNK8cilantro9PLYReader21elementPropertyExistsERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt6vectorIS6_SaIS6_EE]+0x46): undefined reference totinyply::PlyFile::get_elements() const' CMakeFiles/gen.dir/non_rigid_icp.cpp.o: In function cilantro::PLYReader::requestData(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, unsigned int)': non_rigid_icp.cpp:(.text._ZN8cilantro9PLYReader11requestDataERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt6vectorIS6_SaIS6_EEj[_ZN8cilantro9PLYReader11requestDataERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt6vectorIS6_SaIS6_EEj]+0x89): undefined reference totinyply::PlyFile::request_properties_from_element(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, std::vector<std::cxx11::basic_string<char, std::char_traits, std::allocator >, std::allocator<std::__cxx11::basic_string<char, std::char_traits, std::allocator > > >, unsigned int)' CMakeFiles/gen.dir/non_rigid_icp.cpp.o: In function cilantro::PLYReader::readData()': non_rigid_icp.cpp:(.text._ZN8cilantro9PLYReader8readDataEv[_ZN8cilantro9PLYReader8readDataEv]+0x2e): undefined reference totinyply::PlyFile::read(std::istream&)' CMakeFiles/gen.dir/non_rigid_icp.cpp.o: In function cilantro::RenderingProperties::RenderingProperties()': non_rigid_icp.cpp:(.text._ZN8cilantro19RenderingPropertiesC2Ev[_ZN8cilantro19RenderingPropertiesC5Ev]+0x30): undefined reference tocilantro::RenderingProperties::noColor' non_rigid_icp.cpp:(.text._ZN8cilantro19RenderingPropertiesC2Ev[_ZN8cilantro19RenderingPropertiesC5Ev]+0x45): undefined reference to cilantro::RenderingProperties::noColor' CMakeFiles/gen.dir/non_rigid_icp.cpp.o: In functioncilantro::PLYReader::~PLYReader()': non_rigid_icp.cpp:(.text._ZN8cilantro9PLYReaderD2Ev[_ZN8cilantro9PLYReaderD5Ev]+0x18): undefined reference to tinyply::PlyFile::~PlyFile()' CMakeFiles/gen.dir/non_rigid_icp.cpp.o: In functioncilantro::PointCloudRenderable::PointCloudRenderable<cilantro::PointCloud<float, 3l>, void>(cilantro::PointCloud<float, 3l> const&, cilantro::RenderingProperties const&)': non_rigid_icp.cpp:(.text._ZN8cilantro20PointCloudRenderableC2INS_10PointCloudIfLl3EEEvEERKT_RKNS_19RenderingPropertiesE[_ZN8cilantro20PointCloudRenderableC5INS_10PointCloudIfLl3EEEvEERKT_RKNS_19RenderingPropertiesE]+0x72): undefined reference to vtable for cilantro::PointCloudRenderable' CMakeFiles/gen.dir/non_rigid_icp.cpp.o: In functioncilantro::PointCorrespondencesRenderable::PointCorrespondencesRenderable<cilantro::PointCloud<float, 3l>, void>(cilantro::PointCloud<float, 3l> const&, cilantro::PointCloud<float, 3l> const&, cilantro::RenderingProperties const&)': non_rigid_icp.cpp:(.text._ZN8cilantro30PointCorrespondencesRenderableC2INS_10PointCloudIfLl3EEEvEERKT_S6_RKNS_19RenderingPropertiesE[_ZN8cilantro30PointCorrespondencesRenderableC5INS_10PointCloudIfLl3EEEvEERKT_S6_RKNS_19RenderingPropertiesE]+0x7f): undefined reference to `vtable for cilantro::PointCorrespondencesRenderable' collect2: error: ld returned 1 exit status CMakeFiles/gen.dir/build.make:131: recipe for target 'gen' failed make[2]: [gen] Error 1 CMakeFiles/Makefile2:95: recipe for target 'CMakeFiles/gen.dir/all' failed make[1]: [CMakeFiles/gen.dir/all] Error 2 Makefile:103: recipe for target 'all' failed make: *** [all] Error 2 thank you very much!!

Algomorph commented 4 years ago

@Gaoqinghong91,

  1. Please use proper punctuation ("?" at end of questions, capitalized letter in the beginning of each sentence, etc.) when asking a question. Without proper punctuation, your question is hard to read. Maybe this can help: coursera.org/learn/grammar-punctuation.
  2. Please use proper formatting in your question. The build output can go inside code tags to differentiate it from the body of your message. Reference: https://docs.github.com/en/github/writing-on-github/basic-writing-and-formatting-syntax
  3. Go through a basic CMake tutorial first if you're unfamiliar with CMake. Here is one: https://cmake.org/cmake/help/latest/guide/tutorial/index.html
  4. You should provide the relevant portions of your CMake code if your build doesn't work.
  5. You need to install cilantro if you're planning to use it in your CMake project. This can be done by issuing make install from the terminal if you're working in Linux or MacOS (or by building the "INSTALL" project if you're working in Windows with MSVC, but it looks like you're not).
  6. After installing cilantro, you should link it to your CMake project like so (assuming you have it properly discovered via the find_package command apriori) :
    target_link_libraries(your_project_name_in_CMake PUBLIC cilantro)

    Reference: https://cmake.org/cmake/help/latest/command/target_link_libraries.html

Gaoqinghong91 commented 4 years ago

@Algomorph ,Thank you so much for your reply and advice. my system is ubuntu 16.04 and I have installed.

Are there any examples about how to write CMakeLists?

  1. The follow is my CMakeLists:
    
    cmake_minimum_required (VERSION 2.8)
    project (point)
    set(CMAKE_CXX_STANDARD 11)
    find_package(cilantro REQUIRED)
    find_package(Eigen3 REQUIRED)
    find_package(Pangolin REQUIRED)

add_executable(gen non_rigid_icp.cpp ) target_link_libraries(gen ${cilantro_LIBS} ${Pangolin_LIBRARIES} )



2.the 'non_rigid_icp.cpp' is copied from the examples of cilantro.
kzampog commented 4 years ago

Hi,

Apologies for the delayed response :)

I think you have to change ${cilantro_LIBS} to ${cilantro_LIBRARIES} in your CMakeLists -- other than that, it should work. You most likely don't have to explicitly link against Eigen and Pangolin (the cilantro config should take care of that).

Cheers!

Gaoqinghong91 commented 4 years ago

thank you for your reply, i have solved this problem.

zhanghua7099 commented 1 year ago

Hi! I faced the same problem. Could you please give some details about your solutions? Thank you very much!