EDIT: Updated code
I'm using PCL library to generate a mesh from point clouds. This is the code, based on the Greedy Triangulation tutorial in the PCL docs:
#include <pcl/point_types.h>
#include <pcl/common/io.h>
#include <pcl/io/ply_io.h>
#include <pcl/search/kdtree.h>
#include <pcl/features/normal_3d.h>
#include <pcl/surface/gp3.h>
#include <pcl/io/obj_io.h>
#include <vector>
int main() {
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);
pcl::PCLPointCloud2 cloud1;
pcl::PCLPointCloud2 cloud2;
pcl::PCLPointCloud2 cloud3;
pcl::io::loadPLYFile("../cam_1_2.ply", cloud1);
pcl::io::loadPLYFile("../cam_2_3.ply", cloud2);
pcl::io::loadPLYFile("../cam_3_4.ply", cloud3);
cloud1 += cloud2 + cloud3;
pcl::fromPCLPointCloud2(cloud1, *cloud);
pcl::NormalEstimation<pcl::PointXYZ, pcl::Normal> n;
pcl::PointCloud<pcl::Normal>::Ptr normals(new pcl::PointCloud<pcl::Normal>);
pcl::search::KdTree<pcl::PointXYZ>::Ptr tree(new pcl::search::KdTree<pcl::PointXYZ>);
tree->setInputCloud(cloud);
n.setInputCloud(cloud);
n.setSearchMethod(tree);
n.setKSearch(20);
n.compute(*normals);
pcl::PointCloud<pcl::PointNormal>::Ptr cloudWithNormals(new pcl::PointCloud<pcl::PointNormal>);
pcl::concatenateFields(*cloud, *normals, *cloudWithNormals);
pcl::search::KdTree<pcl::PointNormal>::Ptr tree2 (new pcl::search::KdTree<pcl::PointNormal>);
tree2->setInputCloud (cloudWithNormals);
pcl::GreedyProjectionTriangulation<pcl::PointNormal> gp3;
pcl::PolygonMesh triangles;
gp3.setSearchRadius(0.025);
gp3.setMu(2.5);
gp3.setMaximumNearestNeighbors(100);
gp3.setMaximumSurfaceAngle(M_PI/4);
gp3.setMinimumAngle(M_PI/18);
gp3.setMaximumAngle(2 * M_PI / 3);
gp3.setNormalConsistency(false);
gp3.setInputCloud(cloudWithNormals);
gp3.setSearchMethod(tree2);
gp3.reconstruct(triangles);
std::vector<int> parts = gp3.getPartIDs();
std::vector<int> states = gp3.getPointStates();
pcl::io::saveOBJFile("../cam_1_2.obj", triangles);
return 0;
}
This is the CMakeLists file i'm using to build this:
cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
project(TestProject)
find_package(PCL 1.12 REQUIRED COMPONENTS common io)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
add_executable(Test main.cpp)
target_link_libraries(Test ${PCL_LIBRARIES} liblz4.so libpthread.so)
This is the make output in terminal:
make 2 ↵
Consolidate compiler generated dependencies of target Test
[ 50%] Building CXX object CMakeFiles/Test.dir/main.cpp.o
[100%] Linking CXX executable Test
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o: in function `pcl::search::KdTree<pcl::PointXYZ, pcl::KdTreeFLANN<pcl::PointXYZ, flann::L2_Simple<float> > >::KdTree(bool)':
main.cpp:(.text._ZN3pcl6search6KdTreeINS_8PointXYZENS_11KdTreeFLANNIS2_N5flann9L2_SimpleIfEEEEEC2Eb[_ZN3pcl6search6KdTreeINS_8PointXYZENS_11KdTreeFLANNIS2_N5flann9L2_SimpleIfEEEEEC5Eb]+0x5e): undefined reference to `pcl::search::Search<pcl::PointXYZ>::Search(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool)'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o: in function `pcl::search::OrganizedNeighbor<pcl::PointXYZ>::OrganizedNeighbor(bool, float, unsigned int)':
main.cpp:(.text._ZN3pcl6search17OrganizedNeighborINS_8PointXYZEEC2Ebfj[_ZN3pcl6search17OrganizedNeighborINS_8PointXYZEEC5Ebfj]+0x66): undefined reference to `pcl::search::Search<pcl::PointXYZ>::Search(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool)'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE[_ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE]+0x20): undefined reference to `pcl::search::Search<pcl::PointXYZ>::getName[abi:cxx11]() const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE[_ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE]+0x28): undefined reference to `pcl::search::Search<pcl::PointXYZ>::setSortedResults(bool)'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE[_ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE]+0x30): undefined reference to `pcl::search::Search<pcl::PointXYZ>::getSortedResults()'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE[_ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE]+0x50): undefined reference to `pcl::search::OrganizedNeighbor<pcl::PointXYZ>::nearestKSearch(pcl::PointXYZ const&, int, std::vector<int, std::allocator<int> >&, std::vector<float, std::allocator<float> >&) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE[_ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE]+0x58): undefined reference to `pcl::search::Search<pcl::PointXYZ>::nearestKSearch(pcl::PointCloud<pcl::PointXYZ> const&, int, int, std::vector<int, std::allocator<int> >&, std::vector<float, std::allocator<float> >&) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE[_ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE]+0x60): undefined reference to `pcl::search::Search<pcl::PointXYZ>::nearestKSearch(int, int, std::vector<int, std::allocator<int> >&, std::vector<float, std::allocator<float> >&) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE[_ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE]+0x68): undefined reference to `pcl::search::Search<pcl::PointXYZ>::nearestKSearch(pcl::PointCloud<pcl::PointXYZ> const&, std::vector<int, std::allocator<int> > const&, int, std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&, std::vector<std::vector<float, std::allocator<float> >, std::allocator<std::vector<float, std::allocator<float> > > >&) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE[_ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE]+0x70): undefined reference to `pcl::search::OrganizedNeighbor<pcl::PointXYZ>::radiusSearch(pcl::PointXYZ const&, double, std::vector<int, std::allocator<int> >&, std::vector<float, std::allocator<float> >&, unsigned int) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE[_ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE]+0x78): undefined reference to `pcl::search::Search<pcl::PointXYZ>::radiusSearch(pcl::PointCloud<pcl::PointXYZ> const&, int, double, std::vector<int, std::allocator<int> >&, std::vector<float, std::allocator<float> >&, unsigned int) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE[_ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE]+0x80): undefined reference to `pcl::search::Search<pcl::PointXYZ>::radiusSearch(int, double, std::vector<int, std::allocator<int> >&, std::vector<float, std::allocator<float> >&, unsigned int) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE[_ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE]+0x88): undefined reference to `pcl::search::Search<pcl::PointXYZ>::radiusSearch(pcl::PointCloud<pcl::PointXYZ> const&, std::vector<int, std::allocator<int> > const&, double, std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&, std::vector<std::vector<float, std::allocator<float> >, std::allocator<std::vector<float, std::allocator<float> > > >&, unsigned int) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search6KdTreeINS_8PointXYZENS_11KdTreeFLANNIS2_N5flann9L2_SimpleIfEEEEEE[_ZTVN3pcl6search6KdTreeINS_8PointXYZENS_11KdTreeFLANNIS2_N5flann9L2_SimpleIfEEEEEE]+0x20): undefined reference to `pcl::search::Search<pcl::PointXYZ>::getName[abi:cxx11]() const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search6KdTreeINS_8PointXYZENS_11KdTreeFLANNIS2_N5flann9L2_SimpleIfEEEEEE[_ZTVN3pcl6search6KdTreeINS_8PointXYZENS_11KdTreeFLANNIS2_N5flann9L2_SimpleIfEEEEEE]+0x30): undefined reference to `pcl::search::Search<pcl::PointXYZ>::getSortedResults()'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search6KdTreeINS_8PointXYZENS_11KdTreeFLANNIS2_N5flann9L2_SimpleIfEEEEEE[_ZTVN3pcl6search6KdTreeINS_8PointXYZENS_11KdTreeFLANNIS2_N5flann9L2_SimpleIfEEEEEE]+0x58): undefined reference to `pcl::search::Search<pcl::PointXYZ>::nearestKSearch(pcl::PointCloud<pcl::PointXYZ> const&, int, int, std::vector<int, std::allocator<int> >&, std::vector<float, std::allocator<float> >&) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search6KdTreeINS_8PointXYZENS_11KdTreeFLANNIS2_N5flann9L2_SimpleIfEEEEEE[_ZTVN3pcl6search6KdTreeINS_8PointXYZENS_11KdTreeFLANNIS2_N5flann9L2_SimpleIfEEEEEE]+0x60): undefined reference to `pcl::search::Search<pcl::PointXYZ>::nearestKSearch(int, int, std::vector<int, std::allocator<int> >&, std::vector<float, std::allocator<float> >&) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search6KdTreeINS_8PointXYZENS_11KdTreeFLANNIS2_N5flann9L2_SimpleIfEEEEEE[_ZTVN3pcl6search6KdTreeINS_8PointXYZENS_11KdTreeFLANNIS2_N5flann9L2_SimpleIfEEEEEE]+0x68): undefined reference to `pcl::search::Search<pcl::PointXYZ>::nearestKSearch(pcl::PointCloud<pcl::PointXYZ> const&, std::vector<int, std::allocator<int> > const&, int, std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&, std::vector<std::vector<float, std::allocator<float> >, std::allocator<std::vector<float, std::allocator<float> > > >&) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search6KdTreeINS_8PointXYZENS_11KdTreeFLANNIS2_N5flann9L2_SimpleIfEEEEEE[_ZTVN3pcl6search6KdTreeINS_8PointXYZENS_11KdTreeFLANNIS2_N5flann9L2_SimpleIfEEEEEE]+0x78): undefined reference to `pcl::search::Search<pcl::PointXYZ>::radiusSearch(pcl::PointCloud<pcl::PointXYZ> const&, int, double, std::vector<int, std::allocator<int> >&, std::vector<float, std::allocator<float> >&, unsigned int) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search6KdTreeINS_8PointXYZENS_11KdTreeFLANNIS2_N5flann9L2_SimpleIfEEEEEE[_ZTVN3pcl6search6KdTreeINS_8PointXYZENS_11KdTreeFLANNIS2_N5flann9L2_SimpleIfEEEEEE]+0x80): undefined reference to `pcl::search::Search<pcl::PointXYZ>::radiusSearch(int, double, std::vector<int, std::allocator<int> >&, std::vector<float, std::allocator<float> >&, unsigned int) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search6KdTreeINS_8PointXYZENS_11KdTreeFLANNIS2_N5flann9L2_SimpleIfEEEEEE[_ZTVN3pcl6search6KdTreeINS_8PointXYZENS_11KdTreeFLANNIS2_N5flann9L2_SimpleIfEEEEEE]+0x88): undefined reference to `pcl::search::Search<pcl::PointXYZ>::radiusSearch(pcl::PointCloud<pcl::PointXYZ> const&, std::vector<int, std::allocator<int> > const&, double, std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&, std::vector<std::vector<float, std::allocator<float> >, std::allocator<std::vector<float, std::allocator<float> > > >&, unsigned int) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search6SearchINS_8PointXYZEEE[_ZTVN3pcl6search6SearchINS_8PointXYZEEE]+0x20): undefined reference to `pcl::search::Search<pcl::PointXYZ>::getName[abi:cxx11]() const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search6SearchINS_8PointXYZEEE[_ZTVN3pcl6search6SearchINS_8PointXYZEEE]+0x28): undefined reference to `pcl::search::Search<pcl::PointXYZ>::setSortedResults(bool)'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search6SearchINS_8PointXYZEEE[_ZTVN3pcl6search6SearchINS_8PointXYZEEE]+0x30): undefined reference to `pcl::search::Search<pcl::PointXYZ>::getSortedResults()'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search6SearchINS_8PointXYZEEE[_ZTVN3pcl6search6SearchINS_8PointXYZEEE]+0x38): undefined reference to `pcl::search::Search<pcl::PointXYZ>::setInputCloud(std::shared_ptr<pcl::PointCloud<pcl::PointXYZ> const> const&, std::shared_ptr<std::vector<int, std::allocator<int> > const> const&)'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search6SearchINS_8PointXYZEEE[_ZTVN3pcl6search6SearchINS_8PointXYZEEE]+0x58): undefined reference to `pcl::search::Search<pcl::PointXYZ>::nearestKSearch(pcl::PointCloud<pcl::PointXYZ> const&, int, int, std::vector<int, std::allocator<int> >&, std::vector<float, std::allocator<float> >&) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search6SearchINS_8PointXYZEEE[_ZTVN3pcl6search6SearchINS_8PointXYZEEE]+0x60): undefined reference to `pcl::search::Search<pcl::PointXYZ>::nearestKSearch(int, int, std::vector<int, std::allocator<int> >&, std::vector<float, std::allocator<float> >&) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search6SearchINS_8PointXYZEEE[_ZTVN3pcl6search6SearchINS_8PointXYZEEE]+0x68): undefined reference to `pcl::search::Search<pcl::PointXYZ>::nearestKSearch(pcl::PointCloud<pcl::PointXYZ> const&, std::vector<int, std::allocator<int> > const&, int, std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&, std::vector<std::vector<float, std::allocator<float> >, std::allocator<std::vector<float, std::allocator<float> > > >&) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search6SearchINS_8PointXYZEEE[_ZTVN3pcl6search6SearchINS_8PointXYZEEE]+0x78): undefined reference to `pcl::search::Search<pcl::PointXYZ>::radiusSearch(pcl::PointCloud<pcl::PointXYZ> const&, int, double, std::vector<int, std::allocator<int> >&, std::vector<float, std::allocator<float> >&, unsigned int) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search6SearchINS_8PointXYZEEE[_ZTVN3pcl6search6SearchINS_8PointXYZEEE]+0x80): undefined reference to `pcl::search::Search<pcl::PointXYZ>::radiusSearch(int, double, std::vector<int, std::allocator<int> >&, std::vector<float, std::allocator<float> >&, unsigned int) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search6SearchINS_8PointXYZEEE[_ZTVN3pcl6search6SearchINS_8PointXYZEEE]+0x88): undefined reference to `pcl::search::Search<pcl::PointXYZ>::radiusSearch(pcl::PointCloud<pcl::PointXYZ> const&, std::vector<int, std::allocator<int> > const&, double, std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&, std::vector<std::vector<float, std::allocator<float> >, std::allocator<std::vector<float, std::allocator<float> > > >&, unsigned int) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o: in function `pcl::search::OrganizedNeighbor<pcl::PointXYZ>::setInputCloud(std::shared_ptr<pcl::PointCloud<pcl::PointXYZ> const> const&, std::shared_ptr<std::vector<int, std::allocator<int> > const> const&)':
main.cpp:(.text._ZN3pcl6search17OrganizedNeighborINS_8PointXYZEE13setInputCloudERKSt10shared_ptrIKNS_10PointCloudIS2_EEERKS4_IKSt6vectorIiSaIiEEE[_ZN3pcl6search17OrganizedNeighborINS_8PointXYZEE13setInputCloudERKSt10shared_ptrIKNS_10PointCloudIS2_EEERKS4_IKSt6vectorIiSaIiEEE]+0x1ea): undefined reference to `pcl::search::OrganizedNeighbor<pcl::PointXYZ>::estimateProjectionMatrix()'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/Test.dir/build.make:154: Test] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/Test.dir/all] Error 2
make: *** [Makefile:91: all] Error 2
I have found a few related issues people have encountered similar to this and I have tried all the solutions provided without any help.
I am building this on Arch linux 1.4, PCL versuin 1.12.1
EDIT: Following is the output of make -j6 VERBOSE=1
❯ make -j6 VERBOSE=1
/usr/local/bin/cmake -S/home/beany/Documents/projects/pc2mesh -B/home/beany/Documents/projects/pc2mesh/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/local/bin/cmake -E cmake_progress_start /home/beany/Documents/projects/pc2mesh/build/CMakeFiles /home/beany/Documents/projects/pc2mesh/build//CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/home/beany/Documents/projects/pc2mesh/build'
make -f CMakeFiles/Test.dir/build.make CMakeFiles/Test.dir/depend
make[2]: Entering directory '/home/beany/Documents/projects/pc2mesh/build'
cd /home/beany/Documents/projects/pc2mesh/build && /usr/local/bin/cmake -E cmake_depends "Unix Makefiles" /home/beany/Documents/projects/pc2mesh /home/beany/Documents/projects/pc2mesh /home/beany/Documents/projects/pc2mesh/build /home/beany/Documents/projects/pc2mesh/build /home/beany/Documents/projects/pc2mesh/build/CMakeFiles/Test.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/home/beany/Documents/projects/pc2mesh/build'
make -f CMakeFiles/Test.dir/build.make CMakeFiles/Test.dir/build
make[2]: Entering directory '/home/beany/Documents/projects/pc2mesh/build'
[ 50%] Building CXX object CMakeFiles/Test.dir/main.cpp.o
/opt/cuda/bin/g++ -DBOOST_ATOMIC_DYN_LINK -DBOOST_ATOMIC_NO_LIB -DBOOST_DATE_TIME_DYN_LINK -DBOOST_DATE_TIME_NO_LIB -DBOOST_FILESYSTEM_DYN_LINK -DBOOST_FILESYSTEM_NO_LIB -DBOOST_IOSTREAMS_DYN_LINK -DBOOST_IOSTREAMS_NO_LIB -DBOOST_SERIALIZATION_DYN_LINK -DBOOST_SERIALIZATION_NO_LIB -DBOOST_SYSTEM_DYN_LINK -DBOOST_SYSTEM_NO_LIB -DDISABLE_PCAP -DDISABLE_PNG -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_WIDGETS_LIB -Dkiss_fft_scalar=double -isystem /usr/include/pcl-1.12 -isystem /usr/include/eigen3 -isystem /usr/include/ni -isystem /usr/include/openni2 -isystem /usr/include/vtk -isystem /usr/include/freetype2 -isystem /usr/include/qt -isystem /usr/include/qt/QtOpenGL -isystem /usr/include/qt/QtWidgets -isystem /usr/include/qt/QtGui -isystem /usr/include/qt/QtCore -isystem /usr/lib/qt/mkspecs/linux-g++ -msse4.2 -mfpmath=sse -march=native -mavx2 -pthread -fopenmp -fPIC -MD -MT CMakeFiles/Test.dir/main.cpp.o -MF CMakeFiles/Test.dir/main.cpp.o.d -o CMakeFiles/Test.dir/main.cpp.o -c /home/beany/Documents/projects/pc2mesh/main.cpp
[100%] Linking CXX executable Test
/usr/local/bin/cmake -E cmake_link_script CMakeFiles/Test.dir/link.txt --verbose=1
/opt/cuda/bin/g++ -rdynamic CMakeFiles/Test.dir/main.cpp.o -o Test -Wl,-rpath,/usr/lib/openmpi /usr/lib/libpcl_io.so -lOpenNI /usr/lib/libusb-1.0.so -lOpenNI2 /usr/lib/libusb-1.0.so /usr/lib/libvtkChartsCore.so.9.1.0 /usr/lib/libvtkInteractionImage.so.9.1.0 /usr/lib/libvtkIOGeometry.so.9.1.0 /usr/lib/libvtkIOPLY.so.9.1.0 /usr/lib/libvtkRenderingLOD.so.9.1.0 /usr/lib/libvtkViewsContext2D.so.9.1.0 /usr/lib/libvtkGUISupportQt.so.9.1.0 -llz4 -lpthread /usr/lib/libpcl_octree.so /usr/lib/libpcl_common.so /usr/lib/libboost_system.so.1.78.0 /usr/lib/libboost_filesystem.so.1.78.0 /usr/lib/libboost_atomic.so.1.78.0 /usr/lib/libboost_date_time.so.1.78.0 /usr/lib/libboost_iostreams.so.1.78.0 /usr/lib/libboost_serialization.so.1.78.0 /usr/lib/libjsoncpp.so /usr/lib/libvtkViewsCore.so.9.1.0 /usr/lib/libvtkInteractionWidgets.so.9.1.0 /usr/lib/libvtkFiltersModeling.so.9.1.0 /usr/lib/libvtkInteractionStyle.so.9.1.0 /usr/lib/libvtkFiltersExtraction.so.9.1.0 /usr/lib/libvtkIOLegacy.so.9.1.0 /usr/lib/libvtkIOCore.so.9.1.0 /usr/lib/libvtkRenderingAnnotation.so.9.1.0 /usr/lib/libvtkRenderingContext2D.so.9.1.0 /usr/lib/libvtkRenderingFreeType.so.9.1.0 /usr/lib/libfreetype.so /usr/lib/libvtkImagingSources.so.9.1.0 /usr/lib/libvtkIOImage.so.9.1.0 /usr/lib/libvtkImagingCore.so.9.1.0 /usr/lib/libvtkRenderingOpenGL2.so.9.1.0 /usr/lib/libvtkRenderingUI.so.9.1.0 /usr/lib/libvtkRenderingCore.so.9.1.0 /usr/lib/libvtkCommonColor.so.9.1.0 /usr/lib/libvtkFiltersGeometry.so.9.1.0 /usr/lib/libvtkFiltersSources.so.9.1.0 /usr/lib/libvtkFiltersGeneral.so.9.1.0 /usr/lib/libvtkCommonComputationalGeometry.so.9.1.0 /usr/lib/libvtkFiltersCore.so.9.1.0 /usr/lib/libvtkCommonExecutionModel.so.9.1.0 /usr/lib/libvtkCommonDataModel.so.9.1.0 /usr/lib/libvtkCommonMisc.so.9.1.0 /usr/lib/libvtkCommonTransforms.so.9.1.0 /usr/lib/libvtkCommonMath.so.9.1.0 /usr/lib/libvtkkissfft.so.9.1.0 /usr/lib/libGLEW.so /usr/lib/libX11.so /usr/lib/libQt5OpenGL.so.5.15.2 /usr/lib/libQt5Widgets.so.5.15.2 /usr/lib/libQt5Gui.so.5.15.2 /usr/lib/libQt5Core.so.5.15.2 /usr/lib/libvtkCommonCore.so.9.1.0 -pthread /usr/lib/libtbb.so.12.5 -lgomp -lpthread /usr/lib/libvtksys.so.9.1.0 -ldl -Wl,-rpath-link,/usr/lib/openmpi
I just got the code in https://pcl.readthedocs.io/projects/tutorials/en/master/greedy_projection.html#greedy-triangulation, I copied and pasted the code .cpp and the CMakeList.txt explained on the tutorial and that one is working fine for me.
Taking a look on the diffs from your code I discovered when I compile without the "common io" in find_package its compiling without problems.I'm using PCL 1.2 and ubuntu 20.04.
In my case, the changes in CMakeList is like:
find_package(PCL 1.2 REQUIRED COMPONENTS)
The answer posted above by #Junior solved my problem as well. Simply remove the "common io" from find_package. By refering to https://github.com/PointCloudLibrary/pcl/tree/master/doc/tutorials/content/sources/greedy_projection.
Working CMakeList.txt
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
project(TestProject)
find_package(PCL 1.2 REQUIRED)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
add_executable (Test main.cpp)
target_link_libraries (Test ${PCL_LIBRARIES})
Failed to compile CMakeList.txt
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
project(TestProject)
find_package(PCL 1.2 REQUIRED common io)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
add_executable (Test main.cpp)
target_link_libraries (Test ${PCL_LIBRARIES})
If all else fails, reinstall it https://github.com/PointCloudLibrary/pcl/issues/4790#issuecomment-855379558
Uninstall
how to uninstall libpcl!
sudo apt-get purge --auto-remove libpcl-dev
Reinstall
pcl download link
sudo apt install libpcl-dev
Adding the search module to the list of required components in find_package should solve the linking errors. You are using classes from that module, after all.
Related
I have the following errors on Ubuntu 20.04:
[1/1] Linking CXX executable bin/project_2022_matrix_tests
FAILED: bin/project_2022_matrix_tests
: && /usr/bin/c++ -g CMakeFiles/project_2022_matrix_tests.dir/CException.cpp.o CMakeFiles/project_2022_matrix_tests.dir/tests/CException_unit_tests.cpp.o CMakeFiles/project_2022_matrix_tests.dir/tests/main_unit_tests.cpp.o -o bin/project_2022_matrix_tests -L/home/username/.conan/data/gtest/cci.20210126/_/_/package/71c983c52942eb4756e4bd60e4cbec9fd7557e5d/lib -Wl,-rpath,/home/username/.conan/data/gtest/cci.20210126/_/_/package/71c983c52942eb4756e4bd60e4cbec9fd7557e5d/lib -lgtest_main -lgmock_main -lgmock -lgtest -lpthread -lpthread && :
/usr/bin/ld : CMakeFiles/project_2022_matrix_tests.dir/tests/CException_unit_tests.cpp.o : in the function « testing::AssertionResult::AppendMessage(testing::Message const&) » :
/home/username/.conan/data/gtest/cci.20210126/_/_/package/71c983c52942eb4756e4bd60e4cbec9fd7557e5d/include/gtest/gtest.h:357 : undefined reference to « testing::Message::GetString[abi:cxx11]() const »
/usr/bin/ld : CMakeFiles/project_2022_matrix_tests.dir/tests/CException_unit_tests.cpp.o : in the function « testing::AssertionResult testing::internal::CmpHelperEQFailure<CException*, decltype(nullptr)>(char const*, char const*, CException* const&, decltype(nullptr) const&) » :
/home/username/.conan/data/gtest/cci.20210126/_/_/package/71c983c52942eb4756e4bd60e4cbec9fd7557e5d/include/gtest/gtest.h:1529 : undefined reference to « testing::internal::EqFailure(char const*, char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool) »
/usr/bin/ld : CMakeFiles/project_2022_matrix_tests.dir/tests/CException_unit_tests.cpp.o : in the function « testing::AssertionResult testing::internal::CmpHelperEQFailure<char*, decltype(nullptr)>(char const*, char const*, char* const&, decltype(nullptr) const&) » :
/home/username/.conan/data/gtest/cci.20210126/_/_/package/71c983c52942eb4756e4bd60e4cbec9fd7557e5d/include/gtest/gtest.h:1529 : undefined reference to « testing::internal::EqFailure(char const*, char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool) »
/usr/bin/ld : CMakeFiles/project_2022_matrix_tests.dir/tests/CException_unit_tests.cpp.o : in the function « testing::AssertionResult testing::internal::CmpHelperEQFailure<int, int>(char const*, char const*, int const&, int const&) » :
/home/username/.conan/data/gtest/cci.20210126/_/_/package/71c983c52942eb4756e4bd60e4cbec9fd7557e5d/include/gtest/gtest.h:1529 : undefined reference to « testing::internal::EqFailure(char const*, char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool) »
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
My CMakeLists.txt:
cmake_minimum_required(VERSION 3.21)
project(project_2022_matrix_tests)
set(CMAKE_CXX_STANDARD 14)
if(EXISTS ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
else()
message(WARNING "The file conanbuildinfo.cmake doesn't exist, you have to run conan install first")
endif()
find_package(GTest REQUIRED)
include_directories(.)
enable_testing()
add_executable(project_2022_matrix_tests
CException.cpp
CException.h
CMatrix.cpp
CMatrix.h
CIndexableMatrix.h
main.cpp)
add_executable(project_2022_matrix_tests_tests
CException.cpp
CException.h
tests/CException_unit_tests.cpp tests/main_unit_tests.cpp tests/CMatrix_unit_tests.cpp)
target_link_libraries(project_2022_matrix_tests_tests gtest)
I have to say this works on CLion on macOS but for some reasons, not on Ubuntu...
If you need/want more information, please ask.
Thanks for your future reply.
To use the solution that was posted as a comment, just edit the .conan/profiles/default and change the line compiler.libcxx to set the value to libstdc++11.
I am working on one project where I need to compile all our backend c++ applications from centos to rhel8 Linux machine. I am facing a boost program option error with the boost 1.66 version which comes preloaded in rhel8. If I use boost 1.63 it works for me but mt library. mt library is not available in boost 1.66 version. So i made few changes in makefile. Please find below the difference of make file between 1.63 and 1.66 boost. I am getting program option linking error . Please help me to solve this issue.
working command-line compilation with boost 1.63.
/usr/bin/g++ -o /home/rhel8/allan/dev/kevlar/bin/linux5_64_DBG/toolset -g -export-dynamic -Wl,"-(" /home/rhel8/allan/dev/kevlar/tools/linux5_64_DBG/KevlarToolSet.o /home/rhel8/allan/dev/kevlar/tools/linux5_64_DBG/KevlarToolSetMain.o /home/rhel8/allan/dev/kevlar/tools/linux5_64_DBG/KevlarJournalEditorTool.o /home/rhel8/allan/dev/kevlar/tools/linux5_64_DBG/KevlarQueryCheckpointTool.o /home/rhel8/allan/dev/cure/lib/linux5_64_DBG/libcureapplication.a /home/rhel8/allan/dev/eqmon/lib/linux5_64_DBG/libeqmon-mt.a /home/rhel8/allan/dev/eqcyclopsmon/lib/linux5_64_DBG/libeqcyclopsmon.a /home/rhel8/allan/dev/ivcom/src/linux5_64_DBG/libivcom.a /home/rhel8/allan/dev/gslog/lib/linux5_64_DBG/libgslog-mt.a /home/rhel8/allan/dev/gscpputil/linux5_64_DBG/libgscpputil.a /home/rhel8/allan/dev/pcre/linux5_64/lib/libpcre.a /home/rhel8/allan/dev/pcre/linux5_64/lib/libpcrecpp.a /home/rhel8/allan/dev/gscushmdb/linux5_64_DBG/libgscushmdb.a /home/rhel8/allan/dev/hermes/lib/linux5_64_DBG/libhermescommandmanager.a /home/rhel8/allan/dev/hermes/lib/linux5_64_DBG/libhermescommon.a /home/rhel8/allan/dev/ivshmdb/api/linux5_64_DBG/libivshmdbapi.a /home/rhel8/allan/dev/ivshmdb/lib/linux5_64_DBG/libIvShmDbUserEnums.a /home/rhel8/allan/dev/ivshmdb/lib/linux5_64_DBG/libivshmdbcommanddefinition.a /home/rhel8/allan/dev/ivshmdb/lib/linux5_64_DBG/libIvShmDbUserRecords.a /home/rhel8/allan/dev/kevlar/lib/linux5_64_DBG/libkevlarapplication.a /home/rhel8/allan/dev/kevlar/lib/linux5_64_DBG/libkevlarcurrenttime.a /home/rhel8/allan/dev/kevlar/lib/linux5_64_DBG/libkevlarcommandlinetools.a /home/rhel8/allan/dev/kevlar/lib/linux5_64_DBG/libkevlardatastreampair.a /home/rhel8/allan/dev/kevlar/lib/linux5_64_DBG/libkevlarflightrecorder.a /home/rhel8/allan/dev/kevlar/lib/linux5_64_DBG/libkevlarjournalmanager.a /home/rhel8/allan/dev/kevlar/lib/linux5_64_DBG/libkevlarmessagewrapper.a /home/rhel8/allan/dev/kevlar/lib/linux5_64_DBG/libkevlarreplicator.a /home/rhel8/allan/dev/kevlar/lib/linux5_64_DBG/libkevlarresources.a /home/rhel8/allan/dev/kevlar/lib/linux5_64_DBG/libkevlarsharedmemoryutils.a /home/rhel8/allan/dev/kevlar/lib/linux5_64_DBG/libkevlartransaction.a /home/rhel8/allan/dev/kevlar/lib/linux5_64_DBG/libkevlaruniqueid.a /home/rhel8/allan/dev/kevlar/lib/linux5_64_DBG/libKevlarUserEnums.a /home/rhel8/allan/dev/kevlar/lib/linux5_64_DBG/libkevlarcommanddefinition.a /home/rhel8/allan/dev/kevlar/lib/linux5_64_DBG/libKevlarUserRecords.a /home/rhel8/allan/dev/kevlar/lib/linux5_64_DBG/libUserRecords.a -Wl,"-)" /home/rhel8/allan/boost_1.63/lib/libboost_filesystem-mt.a /home/rhel8/allan/boost_1.63/lib/libboost_regex-mt.a /home/rhel8/allan/boost_1.63/lib/libboost_program_options-mt.a /home/rhel8/allan/boost_1.63/lib/libboost_date_time-mt.a /home/rhel8/allan/boost_1.63/lib/libboost_system-mt.a -lexpat /home/rhel8/allan/dev/pcre/linux5_64/lib/libpcre.a /home/rhel8/allan/dev/pcre/linux5_64/lib/libpcrecpp.a /usr/lib64/libpython2.7.so -pthread -Xlinker -ldl -ltirpc -lutil -lrt
/home/rhel8/allan/boost_1.63/lib/libboost_filesystem-mt.a /home/rhel8/allan/boost_1.63/lib/libboost_regex-mt.a /home/rhel8/allan/boost_1.63/lib/libboost_program_options-mt.a /home/rhel8/allan/boost_1.63/lib/libboost_date_time-mt.a /home/rhel8/allan/boost_1.63/lib/libboost_system-mt.a
non working command line compilation with boost 1.66
/usr/bin/g++ -o /home/rhel8/allan/dev/kevlar/bin/linux5_64_DBG/toolset -g -export-dynamic -Wl,"-(" /home/rhel8/allan/dev/kevlar/tools/linux5_64_DBG/KevlarToolSet.o /home/rhel8/allan/dev/kevlar/tools/linux5_64_DBG/KevlarToolSetMain.o /home/rhel8/allan/dev/kevlar/tools/linux5_64_DBG/KevlarJournalEditorTool.o /home/rhel8/allan/dev/kevlar/tools/linux5_64_DBG/KevlarQueryCheckpointTool.o /home/rhel8/allan/dev/cure/lib/linux5_64_DBG/libcureapplication.a /home/rhel8/allan/dev/eqmon/lib/linux5_64_DBG/libeqmon-mt.a /home/rhel8/allan/dev/eqcyclopsmon/lib/linux5_64_DBG/libeqcyclopsmon.a /home/rhel8/allan/dev/ivcom/src/linux5_64_DBG/libivcom.a /home/rhel8/allan/dev/gslog/lib/linux5_64_DBG/libgslog-mt.a /home/rhel8/allan/dev/gscpputil/linux5_64_DBG/libgscpputil.a /home/rhel8/allan/dev/pcre/linux5_64/lib/libpcre.a /home/rhel8/allan/dev/pcre/linux5_64/lib/libpcrecpp.a /home/rhel8/allan/dev/gscushmdb/linux5_64_DBG/libgscushmdb.a /home/rhel8/allan/dev/hermes/lib/linux5_64_DBG/libhermescommandmanager.a /home/rhel8/allan/dev/hermes/lib/linux5_64_DBG/libhermescommon.a /home/rhel8/allan/dev/ivshmdb/api/linux5_64_DBG/libivshmdbapi.a /home/rhel8/allan/dev/ivshmdb/lib/linux5_64_DBG/libIvShmDbUserEnums.a /home/rhel8/allan/dev/ivshmdb/lib/linux5_64_DBG/libivshmdbcommanddefinition.a /home/rhel8/allan/dev/ivshmdb/lib/linux5_64_DBG/libIvShmDbUserRecords.a /home/rhel8/allan/dev/kevlar/lib/linux5_64_DBG/libkevlarapplication.a /home/rhel8/allan/dev/kevlar/lib/linux5_64_DBG/libkevlarcurrenttime.a /home/rhel8/allan/dev/kevlar/lib/linux5_64_DBG/libkevlarcommandlinetools.a /home/rhel8/allan/dev/kevlar/lib/linux5_64_DBG/libkevlardatastreampair.a /home/rhel8/allan/dev/kevlar/lib/linux5_64_DBG/libkevlarflightrecorder.a /home/rhel8/allan/dev/kevlar/lib/linux5_64_DBG/libkevlarjournalmanager.a /home/rhel8/allan/dev/kevlar/lib/linux5_64_DBG/libkevlarmessagewrapper.a /home/rhel8/allan/dev/kevlar/lib/linux5_64_DBG/libkevlarreplicator.a /home/rhel8/allan/dev/kevlar/lib/linux5_64_DBG/libkevlarresources.a /home/rhel8/allan/dev/kevlar/lib/linux5_64_DBG/libkevlarsharedmemoryutils.a /home/rhel8/allan/dev/kevlar/lib/linux5_64_DBG/libkevlartransaction.a /home/rhel8/allan/dev/kevlar/lib/linux5_64_DBG/libkevlaruniqueid.a /home/rhel8/allan/dev/kevlar/lib/linux5_64_DBG/libKevlarUserEnums.a /home/rhel8/allan/dev/kevlar/lib/linux5_64_DBG/libkevlarcommanddefinition.a /home/rhel8/allan/dev/kevlar/lib/linux5_64_DBG/libKevlarUserRecords.a /home/rhel8/allan/dev/kevlar/lib/linux5_64_DBG/libUserRecords.a -Wl,"-)" -lboost_filesystem -lboost_regex -lboost_program_options -lboost_date_time -lboost_system -lexpat /home/rhel8/allan/dev/pcre/linux5_64/lib/libpcre.a /home/rhel8/allan/dev/pcre/linux5_64/lib/libpcrecpp.a /usr/lib64/libpython2.7.so -pthread -Xlinker -ldl -ltirpc -lutil -lrt
-lboost_filesystem -lboost_regex -lboost_program_options -lboost_date_time -lboost_system -lexpat
this library are available in /usr/lib64 folder with so extension.
Below is the error when i compile with boost 1.66
Error after compiling with 1.66 boost version
/home/rhel8/allan/dev/timer/lib/linux5_64_DBG/libtimercommandlinetools.a(KevlarCommandLineToolSet.o):(.data.rel.ro._ZTVN5boost15program_options11typed_valueISt6vectorISsSaISsEEcEE[_ZTVN5boost15program_options11typed_valueISt6vectorISsSaISsEEcEE]+0x38): undefined reference to boost::program_options::value_semantic_codecvt_helper<char>::parse(boost::any&, std::vector<std::string, std::allocator<std::string> > const&, bool) const' /home/rhel8/allan/dev/timer/lib/linux5_64_DBG/libtimercommandlinetools.a(KevlarCommandLineToolSet.o):(.data.rel.ro._ZTVN5boost15program_options11typed_valueISscEE[_ZTVN5boost15program_options11typed_valueISscEE]+0x38): undefined reference to boost::program_options::value_semantic_codecvt_helper::parse(boost::any&, std::vector<std::string, std::allocatorstd::string > const&, bool) const'
/home/rhel8/allan/dev/timer/lib/linux5_64_DBG/libtimercommandlinetools.a(KevlarCommandLineToolSet.o):(.data.rel.ro._ZTVN5boost15program_options20invalid_option_valueE[_ZTVN5boost15program_options20invalid_option_valueE]+0x30): undefined reference to boost::program_options::error_with_option_name::substitute_placeholders(std::string const&) const' /home/rhel8/allan/dev/timer/lib/linux5_64_DBG/libtimercommandlinetools.a(KevlarCommandLineToolSet.o):(.data.rel.ro._ZTVN5boost15program_options16validation_errorE[_ZTVN5boost15program_options16validation_errorE]+0x30): undefined reference to boost::program_options::error_with_option_name::substitute_placeholders(std::string const&) const'
/home/rhel8/allan/dev/timer/lib/linux5_64_DBG/libtimercommandlinetools.a(KevlarCommandLineToolSet.o): In function boost::program_options::typed_value<std::vector<std::string, std::allocator<std::string> >, char>::name() const': /usr/include/boost/program_options/detail/value_semantic.hpp:22: undefined reference to boost::program_options::arg'
/home/rhel8/allan/dev/timer/lib/linux5_64_DBG/libtimercommandlinetools.a(KevlarCommandLineToolSet.o): In function boost::program_options::typed_value<std::string, char>::name() const':/usr/include/boost/program_options/detail/value_semantic.hpp:22: undefined reference to boost::program_options::arg' /home/rhel8/allan/dev/timer/lib/linux5_64_DBG/libtimercommandlinetools.a(KevlarCommandLineToolSet.o): In function boost::program_options::typed_value<std::string, char>::xparse(boost::any&, std::vector<std::string, std::allocator<std::string> > const&) const':/usr/include/boost/program_options/detail/value_semantic.hpp:184: undefined reference to boost::program_options::validate(boost::any&, std::vector<std::string, std::allocatorstd::string > const&, std::string*, int)' /home/rhel8/allan/dev/timer/lib/linux5_64_DBG/libtimercommandlinetools.a(KevlarCommandLineToolSet.o): In function void boost::program_options::validate<std::string, char>(boost::any&, std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::vector<std::string, std::allocator<std::string> >*, int)': /usr/include/boost/program_options/detail/value_semantic.hpp:149: undefined reference to boost::program_options::validate(boost::any&, std::vector<std::string, std::allocatorstd::string > const&, std::string*, int)' /usr/include/boost/program_options/detail/value_semantic.hpp:153: undefined reference to boost::program_options::invalid_option_value::invalid_option_value(std::string const&)' /home/rhel8/allan/dev/timer/lib/linux5_64_DBG/libtimercommandlinetools.a(KevlarCommandLineToolSet.o):(.data.rel.ro._ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_15program_options20invalid_option_valueEEEEE[_ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_15program_options20invalid_option_valueEEEEE]+0x38): undefined reference to boost::program_options::error_with_option_name::substitute_placeholders(std::string const&) const' /home/rhel8/allan/dev/timer/lib/linux5_64_DBG/libtimercommandlinetools.a(KevlarCommandLineToolSet.o):(.data.rel.ro._ZTVN5boost16exception_detail19error_info_injectorINS_15program_options20invalid_option_valueEEE[_ZTVN5boost16exception_detail19error_info_injectorINS_15program_options20invalid_option_valueEEE]+0x30): undefined reference to boost::program_options::error_with_option_name::substitute_placeholders(std::string const&) const' /home/rhel8/allan/dev/timer/lib/linux5_64_DBG/libtimercommandlinetools.a(KevlarCommandLineTool.o): In function KevlarCommandLineTool::KevlarCommandLineTool(std::string const&, std::string const&)':/home/rhel8/allan/dev/timer/commandLineTools/KevlarCommandLineTool.cpp:12: undefined reference to boost::program_options::options_description::options_description(std::string const&, unsigned int, unsigned int)' /home/rhel8/allan/dev/timer/lib/linux5_64_DBG/libtimercommandlinetools.a(KevlarCommandLineTool.o): In function boost::program_options::basic_command_line_parser::basic_command_line_parser(int, char const* const*)': /usr/include/boost/program_options/detail/parsers.hpp:44: undefined reference to boost::program_options::detail::cmdline::cmdline(std::vector<std::string, std::allocator<std::string> > const&)' /home/rhel8/allan/dev/timer/lib/linux5_64_DBG/libtimercommandlinetools.a(KevlarCommandLineTool.o): In function std::vector<std::string, std::allocatorstd::string > boost::program_options::to_internalstd::string(std::vector<std::string, std::allocatorstd::string > const&)': /usr/include/boost/program_options/detail/convert.hpp:79: undefined reference to boost::program_options::to_internal(std::string const&)' /home/rhel8/allan/dev/timer/lib/linux5_64_DBG/libtimercommandlinetools.a(KevlarJournalEditor.o): In function KevlarJournalEditor::KevlarJournalEditor(CureApplication*)': /home/rhel8/allan/dev/timer/commandLineTools/KevlarJournalEditor.cpp:36: undefined reference to boost::program_options::options_description::options_description(std::string const&, unsigned int, unsigned int)' /home/rhel8/allan/dev/timer/commandLineTools/KevlarJournalEditor.cpp:36: undefined reference to boost::program_options::options_description::options_description(std::string const&, unsigned int, unsigned int)' /home/rhel8/allan/dev/timer/lib/linux5_64_DBG/libtimercommandlinetools.a(KevlarJournalEditor.o): In function boost::program_options::validation_error::validation_error(boost::program_options::validation_error::kind_t, std::string const&, std::string const&, int)': /usr/include/boost/program_options/errors.hpp:378: undefined reference to boost::program_options::validation_error::get_template(boost::program_options::validation_error::kind_t)' /usr/include/boost/program_options/errors.hpp:378: undefined reference to boost::program_options::error_with_option_name::error_with_option_name(std::string const&, std::string const&, std::string const&, int)'/home/rhel8/allan/dev/timer/lib/linux5_64_DBG/libtimercommandlinetools.a(KevlarJournalEditor.o): In function boost::program_options::variables_map::operator[](std::string const&) const': /usr/include/boost/program_options/variables_map.hpp:155: undefined reference to boost::program_options::abstract_variables_map::operator[](std::string const&) const' /home/rhel8/allan/dev/timer/lib/linux5_64_DBG/libtimercommandlinetools.a(KevlarJournalEditor.o):(.data.rel.ro._ZTVN5boost15program_options11typed_valueIicEE[_ZTVN5boost15program_options11typed_valueIicEE]+0x38): undefined reference to boost::program_options::value_semantic_codecvt_helper::parse(boost::any&, std::vector<std::string, std::allocatorstd::string > const&, bool) const'/home/rhel8/allan/dev/timer/lib/linux5_64_DBG/libtimercommandlinetools.a(KevlarJournalEditor.o): In function boost::program_options::typed_value<int, char>::name() const':/usr/include/boost/program_options/detail/value_semantic.hpp:22: undefined reference to boost::program_options::arg' /home/rhel8/allan/dev/timer/lib/linux5_64_DBG/libtimercommandlinetools.a(KevlarJournalEditor.o): In function void boost::program_options::validate<int, char>(boost::any&, std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, int*, long)':/usr/include/boost/program_options/detail/value_semantic.hpp:95: undefined reference to boost::program_options::invalid_option_value::invalid_option_value(std::string const&)'/home/rhel8/allan/dev/timer/lib/linux5_64_DBG/libtimercommandlinetools.a(KevlarJournalEditor.o):(.data.rel.ro._ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_15program_options16validation_errorEEEEE[_ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_15program_options16validation_errorEEEEE]+0x38): undefined reference to boost::program_options::error_with_option_name::substitute_placeholders(std::string const&) const'/home/rhel8/allan/dev/timer/lib/linux5_64_DBG/libtimercommandlinetools.a(KevlarJournalEditor.o):(.data.rel.ro._ZTVN5boost16exception_detail19error_info_injectorINS_15program_options16validation_errorEEE[_ZTVN5boost16exception_detail19error_info_injectorINS_15program_options16validation_errorEEE]+0x30): undefined reference to boost::program_options::error_with_option_name::substitute_placeholders(std::string const&) const'/home/rhel8/allan/dev/timer/lib/linux5_64_DBG/libtimercommandlinetools.a(KevlarShmDatabaseUtility.o): In function KevlarShmDatabaseUtility::KevlarShmDatabaseUtility()':/home/rhel8/allan/dev/timer/commandLineTools/KevlarShmDatabaseUtility.cpp:38: undefined reference to boost::program_options::options_description::options_description(std::string const&, unsigned int, unsigned int)'/home/rhel8/allan/dev/timer/commandLineTools/KevlarShmDatabaseUtility.cpp:38: undefined reference to boost::program_options::options_description::options_description(std::string const&, unsigned int, unsigned int)'/home/rhel8/allan/dev/timer/commandLineTools/KevlarShmDatabaseUtility.cpp:38: undefined reference to boost::program_options::options_description::options_description(std::string const&, unsigned int, unsigned int)'/home/rhel8/allan/dev/timer/lib/linux5_64_DBG/libtimercommandlinetools.a(KevlarShmEditor.o): In function KevlarShmEditor::KevlarShmEditor(CureApplication*)':/home/rhel8/allan/dev/timer/commandLineTools/KevlarShmEditor.cpp:278: undefined reference to boost::program_options::options_description::options_description(std::string const&, unsigned int, unsigned int)'/home/rhel8/allan/dev/timer/commandLineTools/KevlarShmEditor.cpp:278: undefined reference to boost::program_options::options_description::options_description(std::string const&, unsigned int, unsigned int)'/home/rhel8/allan/dev/timer/lib/linux5_64_DBG/libtimercommandlinetools.a(KevlarLogQueryTool.o):/home/rhel8/allan/dev/timer/commandLineTools/KevlarLogQueryTool.cpp:113: more undefined references to boost::program_options::options_description::options_description(std::string const&, unsigned int, unsigned int)' follow/home/rhel8/allan/dev/timer/lib/linux5_64_DBG/libtimercommandlinetools.a(KevlarLogQueryTool.o):(.data.rel.ro._ZTVN5boost15program_options11typed_valueIjcEE[_ZTVN5boost15program_options11typed_valueIjcEE]+0x38): undefined reference to boost::program_options::value_semantic_codecvt_helper<char>::parse(boost::any&, std::vector<std::string, std::allocator<std::string> > const&, bool) const'/home/rhel8/allan/dev/timer/lib/linux5_64_DBG/libtimercommandlinetools.a(KevlarLogQueryTool.o): In function boost::program_options::typed_value<unsigned int, char>::name() const':/usr/include/boost/program_options/detail/value_semantic.hpp:22: undefined reference to boost::program_options::arg'/home/rhel8/allan/dev/timer/lib/linux5_64_DBG/libtimercommandlinetools.a(KevlarLogQueryTool.o): In function void boost::program_options::validate<unsigned int, char>(boost::any&, std::vector<std::basic_string<char, std::char_traits, std::allocator >, std::allocator<std::basic_string<char, std::char_traits, std::allocator > > > const&, unsigned int*, long)':/usr/include/boost/program_options/detail/value_semantic.hpp:95: undefined reference to `boost::program_options::invalid_option_value::invalid_option_value(std::string const&)'collect2: error: ld returned 1 exit status
I am trying to get Boost 1.72 release ready to use in my C++ project. OS is Windows 10. I use Clion as an IDE and CMake 3.17 and gcc 8.1.0 as toolchain. I tried to follow lots of different instruction on the web trying to "install" Boost properly, and I ended up with these steps (all italic folders names are valid full-qualified paths):
Unpack Boost source code, go to boost-sources-dir/tools/build, run bootstrap.bat gcc
Then run b2 install --prefix="provided-boost-build-folder"
Then add provided-boost-build-folder/bin to PATH variable.
Go back to boost-sources-dir and run b2 --build-dir="boost-sources-dir\build" --prefix="boost-install-dir" toolset=gcc install --build-type=complete -j 4
Now I have "include" and "lib" folders in boost-install-dir. I open Clion and add parameters for CMake in Clion settings:
-DBOOST_INCLUDEDIR="boost-install-dir\include"
-DBOOST_LIBRARYDIR="boost-install-dir\lib"
-DBOOST_ROOT="boost-install-dir"
And my CMakeLists.txt is below:
cmake_minimum_required(VERSION 3.14)
project(DBMSProject)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_FLAGS "--coverage")
find_package(Boost)
# I also tried to use the line below instead of a line above, but it gave me a strange error
# "Could NOT find Boost (missing: regex) (found version "1.72.0")"
# find_package(Boost REQUIRED COMPONENTS regex)
include_directories(${Boost_INCLUDE_DIRS})
add_executable(DBMSProject main.cpp /* some other stuff */)
target_link_libraries(DBMSProject -static)
#target_link_libraries(DBMSProject ${Boost_LIBRARIES}) # that didn't work
target_link_libraries(DBMSProject Boost::boost ${Boost_REGEX_LIBRARY}) # neither that does
Just some sample code in main.cpp to see if compiling and linking work:
/* Other headers */
#include <boost/regex.hpp>
. . .
int main() {
std::string line;
boost::regex pat( "^Subject: (Re: |Aw: )*(.*)" );
while (std::cin)
{
std::getline(std::cin, line);
boost::smatch matches;
if (boost::regex_match(line, matches, pat))
std::cout << matches[2] << std::endl;
}
}
After trying to run this program, it gives lots of link errors:
[100%] Linking CXX executable DBMSProject.exe
CMakeFiles\DBMSProject.dir/objects.a(main.cpp.obj): In function `boost::re_detail_107200::cpp_regex_traits_char_layer<char>::cpp_regex_traits_char_layer(boost::re_detail_107200::cpp_regex_traits_base<char> const&)':
C:/Users/Documents/Programs/boost/include/boost-1_72/boost/regex/v4/cpp_regex_traits.hpp:370: undefined reference to `boost::re_detail_107200::cpp_regex_traits_char_layer<char>::init()'
CMakeFiles\DBMSProject.dir/objects.a(main.cpp.obj): In function `boost::re_detail_107200::raw_storage::extend(unsigned long long)':
C:/Users/Documents/Programs/boost/include/boost-1_72/boost/regex/v4/regex_raw_buffer.hpp:131: undefined reference to `boost::re_detail_107200::raw_storage::resize(unsigned long long)'
CMakeFiles\DBMSProject.dir/objects.a(main.cpp.obj): In function `boost::re_detail_107200::save_state_init::save_state_init(boost::re_detail_107200::saved_state**, boost::re_detail_107200::saved_state**)':
C:/Users//Douments/Programs/boost/include/boost-1_72/boost/regex/v4/perl_matcher_non_recursive.hpp:110: undefined reference to `boost::re_detail_107200::get_mem_block()'
CMakeFiles\DBMSProject.dir/objects.a(main.cpp.obj): In function `boost::re_detail_107200::save_state_init::~save_state_init()':
C:/Users/Documents/Programs/boost/include/boost-1_72/boost/regex/v4/perl_matcher_non_recursive.hpp:118: undefined reference to `boost::re_detail_107200::put_mem_block(void*)'
CMakeFiles\DBMSProject.dir/objects.a(main.cpp.obj): In function `boost::re_detail_107200::perl_matcher<__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::match_imp()':
C:/Users//ocuments/Programs/boost/include/boost-1_72/boost/regex/v4/perl_matcher_common.hpp:221: undefined reference to `boost::re_detail_107200::verify_options(unsigned int, boost::regex_constants::_match_flags)'
CMakeFiles\DBMSProject.dir/objects.a(main.cpp.obj): In function `boost::re_detail_107200::perl_matcher<__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::unwind_extra_block(bool)':
C:/Users/Documents/Programs/boost/include/boost-1_72/boost/regex/v4/perl_matcher_non_recursive.hpp:1371: undefined reference to `boost::re_detail_107200::put_mem_block(void*)'
CMakeFiles\DBMSProject.dir/objects.a(main.cpp.obj): In function `void boost::re_detail_107200::raise_error<boost::regex_traits_wrapper<boost::regex_traits<char, boost::cpp_regex_traits<char> > > >(boost::regex_traits_wrapper<boost::regex_traits<char, boost::cpp_regex_traits<char> > > const&, boost::regex_constants::error_type)':
C:/Users/Documents/Programs/boost/include/boost-1_72/boost/regex/pattern_except.hpp:75: undefined reference to `boost::re_detail_107200::raise_runtime_error(std::runtime_error const&)'
CMakeFiles\DBMSProject.dir/objects.a(main.cpp.obj): In function `boost::re_detail_107200::perl_matcher<__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::extend_stack()':
C:/Users/Documents/Programs/boost/include/boost-1_72/boost/regex/v4/perl_matcher_non_recursive.hpp:236: undefined reference to `boost::re_detail_107200::get_mem_block()'
CMakeFiles\DBMSProject.dir/objects.a(main.cpp.obj): In function `boost::re_detail_107200::basic_regex_parser<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::fail(boost::regex_constants::error_type, long long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, long long)':
C:/Users/Documents/Programs/boost/include/boost-1_72/boost/regex/v4/basic_regex_parser.hpp:241: undefined reference to `boost::regex_error::regex_error(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, boost::regex_constants::error_type, long long)'
C:/Users/Documents/Programs/boost/include/boost-1_72/boost/regex/v4/basic_regex_parser.hpp:242: undefined reference to `boost::regex_error::raise() const'
C:/Users//Douments/Programs/boost/include/boost-1_72/boost/regex/v4/basic_regex_parser.hpp:241: undefined reference to `boost::regex_error::~regex_error()'
C:/Users//v4/basic_regex_parser.hpp:241: undefined reference to `boost::regex_error::~regex_error()'
CMakeFiles\DBMSProject.dir/objects.a(main.cpp.obj): In function `boost::re_dtail_107200::basic_regex_creator<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::fixup_recursions(boost::re_detail_107200::re_syntax_base*)':
C:/Users//Documents/Programs/boost/include/boost-1_72/boost/regex/v4/basic_regex_creator.hpp:785: undefined reference to `boost::regex_error::regex_error(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, boost::regex_constants::error_type, long long)'
C:/Users//v4/basic_regex_creator.hpp:785: undefined reference to `boost::regex_error::~regex_error()'
C:/Users//Documents/Programs/boost/include/boost-1_72/boost/regex/v4/basic_regex_creator.hpp:874: undefined reference to `boost::regex_error::regex_error(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, boost::regex_constants::error_type, long long)'
C:/Users//Documents/Programs/boost/include/boost-1_72/boost/regex/v4/basic_regex_creator.hpp:875: undefined reference to `boost::/Documents/Programs/boost/include/boost-1_72/boost/regex/v4/basic_regex_creator.hpp:874: undefined reference to `boost::regex_error::~regex_error()'
C:/Users//Documents/Programs/boost/include/boost-1_72/boost/regex/v4/basic_regex_creator.hpp:785: undefined reference to `boost::regex_error::~regex_error()'
C:/Users//Documents/Programs/boost/include/boost-1_72/boost/regex/v4/basic_regex_creator.hpp:874: undefined reference to `boost::regex_error::~regex_error()'
CMakeFiles\DBMSProject.dir/objects.a(main.cpp.obj): In function `boost::re_detail_107200::basic_regex_creator<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::create_startmaps(boost::re_detail_107200::re_syntax_base*)':
C:/Users//Documents/Programs/boost/include/boost-1_72/boost/regex/v4/basic_regex_creator.hpp:940: undefined reference to `boost::regex_error::regex_error(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, boost::regex_constants::error_type, long long)'
C:/Users//Documents/Programs/boost/include/boost-1_72/boost/regex/v4/basic_regex_creator.hpp:941: undefined reference to `boost::regex_error::raise() const'
C:/Users//Documents/Programs/boost/include/boost-1_72/boost/regex/v4/basic_regex_creator.hpp:940: undefined reference to `boost::re
But I can clearly see with my eyes the definitions of "absent" symbols in the same .hpp file as where the errors are! What am I doing wrong?
I finally got it to work. My CMakeLists.txt now looks as follows:
cmake_minimum_required(VERSION 3.14)
project(DBMSProject)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_FLAGS "--coverage")
set(CMAKE_PREFIX_PATH ${BOOST_LIBRARYDIR}\\cmake)
find_package(Boost CONFIG REQUIRED COMPONENTS regex)
include_directories(${Boost_INCLUDE_DIRS})
add_executable(DBMSProject main.cpp /* stuff */)
target_link_libraries(DBMSProject -static)
#target_link_libraries(DBMSProject ${Boost_LIBRARIES}) # haven't tried that but I think it might work as well
target_link_libraries(DBMSProject Boost::regex)
It also turned out that I don't need -DBOOST... parameters for CMake if I don't use them in CMakeLists.txt, so I excluded -DBOOST_INCLUDEDIR and -DBOOST_ROOT from them.
I'm cross compiling project with following toolset:
cmake
Toolchain is arm-linux-gnueabihf
sysroot (which is actually rsync of necessary stuff from Raspberry Pi 2 and contains all of headers and libraries I need)
and list of find_package
Boost configured in following manner:
set(CMAKE_CXX_FLAGS ${CMAKE_CPU_FLAGS} "-DBOOST_ALL_DYN_LINK -fPIC -std=gnu++14 ${CMAKE_ARCH}")
set(Boost_DEBUG OFF)
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
set(BOOST_ALL_DYN_LINK ON) # force dynamic linking for all libraries
set(BOOST_COMPONENTS
system
thread
program_options
regex
filesystem
unit_test_framework
date_time
chrono
log_setup
log
)
set(BOOST_ROOT ${CMAKE_SYSROOT})
set(BOOST_INCLUDEDIR ${BOOST_ROOT}/usr/inc)
set(BOOST_LIBRARYDIR ${BOOST_ROOT}/usr/lib/arm-linux-gnueabihf)
find_package(Boost 1.54.0 REQUIRED COMPONENTS ${BOOST_COMPONENTS})
Under the OS X compilation and linking just goes fine and I'm able send application to the RPI2 and run it.
The problem is in linking process under Ubuntu. It unable to find couple of symbols related to boost.log:
logger/liblogger.a(logger.cpp.o): In function `boost::log::v2_mt_posix::basic_formatting_ostream<char, std::char_traits<char>, std::allocator<char> >& boost::log::v2_mt_posix::basic_formatting_ostream<char, std::char_traits<char>, std::allocator<char> >::formatted_write<wchar_t>(wchar_t const*, int)':
logger.cpp:(.text._ZN5boost3log11v2_mt_posix24basic_formatting_ostreamIcSt11char_traitsIcESaIcEE15formatted_writeIwEERS6_PKT_i[_ZN5boost3log11v2_mt_posix24basic_formatting_ostreamIcSt11char_traitsIcESaIcEE15formatted_writeIwEERS6_PKT_i]+0x76): undefined reference to `boost::log::v2_mt_posix::aux::code_convert(wchar_t const*, unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::locale const&)'
logger/liblogger.a(logger.cpp.o): In function `void boost::log::v2_mt_posix::basic_formatting_ostream<char, std::char_traits<char>, std::allocator<char> >::aligned_write<wchar_t>(wchar_t const*, int)':
logger.cpp:(.text._ZN5boost3log11v2_mt_posix24basic_formatting_ostreamIcSt11char_traitsIcESaIcEE13aligned_writeIwEEvPKT_i[_ZN5boost3log11v2_mt_posix24basic_formatting_ostreamIcSt11char_traitsIcESaIcEE13aligned_writeIwEEvPKT_i]+0x6c): undefined reference to `boost::log::v2_mt_posix::aux::code_convert(wchar_t const*, unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::locale const&)'
logger.cpp:(.text._ZN5boost3log11v2_mt_posix24basic_formatting_ostreamIcSt11char_traitsIcESaIcEE13aligned_writeIwEEvPKT_i[_ZN5boost3log11v2_mt_posix24basic_formatting_ostreamIcSt11char_traitsIcESaIcEE13aligned_writeIwEEvPKT_i]+0xc6): undefined reference to `boost::log::v2_mt_posix::aux::code_convert(wchar_t const*, unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::locale const&)'
logger/liblogger.a(logger.cpp.o): In function `void boost::log::v2_mt_posix::sinks::basic_formatting_sink_frontend<char>::feed_record<boost::mutex, boost::log::v2_mt_posix::sinks::basic_text_ostream_backend<char> >(boost::log::v2_mt_posix::record_view const&, boost::mutex&, boost::log::v2_mt_posix::sinks::basic_text_ostream_backend<char>&)':
logger.cpp:(.text._ZN5boost3log11v2_mt_posix5sinks30basic_formatting_sink_frontendIcE11feed_recordINS_5mutexENS2_26basic_text_ostream_backendIcEEEEvRKNS1_11record_viewERT_RT0_[_ZN5boost3log11v2_mt_posix5sinks30basic_formatting_sink_frontendIcE11feed_recordINS_5mutexENS2_26basic_text_ostream_backendIcEEEEvRKNS1_11record_viewERT_RT0_]+0xda): undefined reference to `boost::log::v2_mt_posix::sinks::basic_text_ostream_backend<char>::consume(boost::log::v2_mt_posix::record_view const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
logger/liblogger.a(logger.cpp.o): In function `void boost::log::v2_mt_posix::sinks::basic_formatting_sink_frontend<char>::feed_record<boost::mutex, boost::log::v2_mt_posix::sinks::text_file_backend>(boost::log::v2_mt_posix::record_view const&, boost::mutex&, boost::log::v2_mt_posix::sinks::text_file_backend&)':
logger.cpp:(.text._ZN5boost3log11v2_mt_posix5sinks30basic_formatting_sink_frontendIcE11feed_recordINS_5mutexENS2_17text_file_backendEEEvRKNS1_11record_viewERT_RT0_[_ZN5boost3log11v2_mt_posix5sinks30basic_formatting_sink_frontendIcE11feed_recordINS_5mutexENS2_17text_file_backendEEEvRKNS1_11record_viewERT_RT0_]+0xda): undefined reference to `boost::log::v2_mt_posix::sinks::text_file_backend::consume(boost::log::v2_mt_posix::record_view const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
logger/liblogger.a(logger.cpp.o): In function `void boost::log::v2_mt_posix::sinks::basic_formatting_sink_frontend<char>::feed_record<boost::log::v2_mt_posix::aux::fake_mutex, boost::log::v2_mt_posix::sinks::basic_text_ostream_backend<char> >(boost::log::v2_mt_posix::record_view const&, boost::log::v2_mt_posix::aux::fake_mutex&, boost::log::v2_mt_posix::sinks::basic_text_ostream_backend<char>&)':
logger.cpp:(.text._ZN5boost3log11v2_mt_posix5sinks30basic_formatting_sink_frontendIcE11feed_recordINS1_3aux10fake_mutexENS2_26basic_text_ostream_backendIcEEEEvRKNS1_11record_viewERT_RT0_[_ZN5boost3log11v2_mt_posix5sinks30basic_formatting_sink_frontendIcE11feed_recordINS1_3aux10fake_mutexENS2_26basic_text_ostream_backendIcEEEEvRKNS1_11record_viewERT_RT0_]+0xda): undefined reference to `boost::log::v2_mt_posix::sinks::basic_text_ostream_backend<char>::consume(boost::log::v2_mt_posix::record_view const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
logger/liblogger.a(logger.cpp.o): In function `void boost::log::v2_mt_posix::sinks::basic_formatting_sink_frontend<char>::feed_record<boost::log::v2_mt_posix::aux::fake_mutex, boost::log::v2_mt_posix::sinks::text_file_backend>(boost::log::v2_mt_posix::record_view const&, boost::log::v2_mt_posix::aux::fake_mutex&, boost::log::v2_mt_posix::sinks::text_file_backend&)':
logger.cpp:(.text._ZN5boost3log11v2_mt_posix5sinks30basic_formatting_sink_frontendIcE11feed_recordINS1_3aux10fake_mutexENS2_17text_file_backendEEEvRKNS1_11record_viewERT_RT0_[_ZN5boost3log11v2_mt_posix5sinks30basic_formatting_sink_frontendIcE11feed_recordINS1_3aux10fake_mutexENS2_17text_file_backendEEEvRKNS1_11record_viewERT_RT0_]+0xda): undefined reference to `boost::log::v2_mt_posix::sinks::text_file_backend::consume(boost::log::v2_mt_posix::record_view const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
with:
make VERBOSE=1
seems all of libraries up there
/usr/local/gcc-linaro-5.1-2015.08-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++ --sysroot=/home/amr/iot_hub/3rd-party/rpi2_sysroot -DBOOST_ALL_DYN_LINK -fPIC -std=gnu++14 -march=armv7-a -mtune=cortex-a7 -mfpu=vfp -mfloat-abi=hard -Wl,-rpath-link=/home/amr/iot_hub/3rd-party/rpi2_sysroot/lib/arm-linux-gnueabihf -Wl,-rpath-link=/home/amr/iot_hub/3rd-party/rpi2_sysroot/usr/lib/arm-linux-gnueabihf CMakeFiles/hub.dir/main/main.cpp.o -o hub -L/home/amr/iot_hub/3rd-party/rpi2_sysroot/lib/arm-linux-gnueabihf -L/home/amr/iot_hub/3rd-party/rpi2_sysroot/lib -L/home/amr/iot_hub/3rd-party/rpi2_sysroot/usr/lib -L/home/amr/iot_hub/3rd-party/rpi2_sysroot/usr/lib/arm-linux-gnueabihf -L/home/amr/iot_hub/3rd-party/rpi2_sysroot/usr/lib/gcc/arm-linux-gnueabihf/5 -rdynamic sensor-framework/libsensor-framework.a transport-framework/libtransport-framework.a tools/libtools.a logger/liblogger.a database-connector/libdb-conn.a -lbluetooth /home/amr/iot_hub/3rd-party/rpi2_sysroot/usr/lib/arm-linux-gnueabihf/libsoci_core.so /home/amr/iot_hub/3rd-party/rpi2_sysroot/usr/lib/arm-linux-gnueabihf/libsoci_postgresql.so -lpq -lpthread /home/amr/iot_hub/3rd-party/rpi2_sysroot/usr/lib/arm-linux-gnueabihf/libboost_program_options.so /home/amr/iot_hub/3rd-party/rpi2_sysroot/usr/lib/arm-linux-gnueabihf/libboost_system.so /home/amr/iot_hub/3rd-party/rpi2_sysroot/usr/lib/arm-linux-gnueabihf/libboost_thread.so /home/amr/iot_hub/3rd-party/rpi2_sysroot/usr/lib/arm-linux-gnueabihf/libboost_regex.so /home/amr/iot_hub/3rd-party/rpi2_sysroot/usr/lib/arm-linux-gnueabihf/libboost_filesystem.so /home/amr/iot_hub/3rd-party/rpi2_sysroot/usr/lib/arm-linux-gnueabihf/libboost_unit_test_framework.so /home/amr/iot_hub/3rd-party/rpi2_sysroot/usr/lib/arm-linux-gnueabihf/libboost_date_time.so /home/amr/iot_hub/3rd-party/rpi2_sysroot/usr/lib/arm-linux-gnueabihf/libboost_chrono.so /home/amr/iot_hub/3rd-party/rpi2_sysroot/usr/lib/arm-linux-gnueabihf/libboost_log.so /home/amr/iot_hub/3rd-party/rpi2_sysroot/usr/lib/arm-linux-gnueabihf/libboost_log_setup.so /home/amr/iot_hub/3rd-party/rpi2_sysroot/usr/lib/arm-linux-gnueabihf/libssl.so /home/amr/iot_hub/3rd-party/rpi2_sysroot/usr/lib/arm-linux-gnueabihf/libcrypto.so /home/amr/iot_hub/3rd-party/rpi2_sysroot/usr/lib/arm-linux-gnueabihf/libglib-2.0.a /home/amr/iot_hub/3rd-party/rpi2_sysroot/usr/lib/arm-linux-gnueabihf/libgthread-2.0.so /home/amr/iot_hub/3rd-party/rpi2_sysroot/usr/lib/arm-linux-gnueabihf/libgmodule-2.0.so sensor-framework/libsensor-framework.a -Wl,-rpath,/lib/arm-linux-gnueabihf:/lib:/usr/lib:/usr/lib/arm-linux-gnueabihf:/usr/lib/gcc/arm-linux-gnueabihf/5:
What can be root cause of that issue?
Found some workaround.
I use different toolchains on OS X (4.9) and Ubuntu (5.1) which seems produces some difference in linking process (or there is no binary compatibility). Installing linaro toolchain on Ubuntu with same version as OS X have fixed the issue.
I have installed opencv recently . I am trying to do a bit if image processing using opencv and cuda. but I am getting an error like this
nvcc -o reference_hw1 reference_main.o student_func.o compare.o reference_calc.o -arch=sm_20 -Xcompiler -Wall -Xcompiler -Wextra -m64 -L /usr/lib
reference_main.o: In function `preProcess(uchar4**, unsigned char**, uchar4**, unsigned char**, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
reference_main.cpp:(.text+0xc4): undefined reference to `cv::imread(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
reference_main.cpp:(.text+0x1b7): undefined reference to `cv::_OutputArray::_OutputArray(cv::Mat&)'
reference_main.cpp:(.text+0x1cd): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
reference_main.cpp:(.text+0x1ea): undefined reference to `cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int)'
reference_main.o: In function `postProcess(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned char*)':
reference_main.cpp:(.text+0x45a): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
reference_main.cpp:(.text+0x4a2): undefined reference to `cv::imwrite(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&, std::vector<int, std::allocator<int> > const&)'
reference_main.o: In function `generateReferenceImage(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
reference_main.cpp:(.text+0x5b2): undefined reference to `cv::imread(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
reference_main.cpp:(.text+0x5d4): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
reference_main.cpp:(.text+0x5ee): undefined reference to `cv::imwrite(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&, std::vector<int, std::allocator<int> > const&)'
reference_main.o: In function `cv::Mat::~Mat()':
reference_main.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x39): undefined reference to `cv::fastFree(void*)'
reference_main.o: In function `cv::Mat::operator=(cv::Mat const&)':
reference_main.cpp:(.text._ZN2cv3MataSERKS0_[cv::Mat::operator=(cv::Mat const&)]+0x111): undefined reference to `cv::Mat::copySize(cv::Mat const&)'
reference_main.o: In function `cv::Mat::create(int, int, int)':
reference_main.cpp:(.text._ZN2cv3Mat6createEiii[cv::Mat::create(int, int, int)]+0x96): undefined reference to `cv::Mat::create(int, int const*, int)'
reference_main.o: In function `cv::Mat::release()':
reference_main.cpp:(.text._ZN2cv3Mat7releaseEv[cv::Mat::release()]+0x47): undefined reference to `cv::Mat::deallocate()'
compare.o: In function `compareImages(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, double, double)':
compare.cpp:(.text+0x4e): undefined reference to `cv::imread(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
compare.cpp:(.text+0x6c): undefined reference to `cv::imread(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
compare.cpp:(.text+0x8c): undefined reference to `cv::operator-(cv::Mat const&, cv::Mat const&)'
compare.cpp:(.text+0xa5): undefined reference to `cv::abs(cv::MatExpr const&)'
compare.cpp:(.text+0x15a): undefined reference to `cv::Mat::reshape(int, int) const'
compare.cpp:(.text+0x15f): undefined reference to `cv::noArray()'
compare.cpp:(.text+0x17b): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
compare.cpp:(.text+0x1a9): undefined reference to `cv::minMaxLoc(cv::_InputArray const&, double*, double*, cv::Point_<int>*, cv::Point_<int>*, cv::_InputArray const&)'
compare.cpp:(.text+0x20c): undefined reference to `cv::operator-(cv::Mat const&, cv::Scalar_<double> const&)'
compare.cpp:(.text+0x22d): undefined reference to `cv::operator*(cv::MatExpr const&, double)'
compare.cpp:(.text+0x2d2): undefined reference to `cv::Mat::reshape(int, int) const'
compare.cpp:(.text+0x33d): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
compare.cpp:(.text+0x375): undefined reference to `cv::imwrite(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&, std::vector<int, std::allocator<int> > const&)'
collect2: ld returned 1 exit status
make: *** [student] Error 1
I don't know why the error is like this. My Makefile is
NVCC= nvcc
###################################
# These are the default install #
# locations on most linux distros #
###################################
OPENCV_LIBPATH=/usr/lib
OPENCV_INCLUDEPATH=/usr/local/include
OPENCV_TROUBLE=
CUDA_INCLUDEPATH=/usr/local/cuda/include
NVCC_OPTS = -arch=sm_20 -Xcompiler -Wall -Xcompiler -Wextra -m64
GCC_OPTS = -Wall -Wextra -m64
student: reference_main.o student_func.o compare.o reference_calc.o Makefile
$(NVCC) -o reference_hw1 reference_main.o student_func.o compare.o reference_calc.o $(NVCC_OPTS) -L $(OPENCV_LIBPATH) $(OPENCV_TROUBLE)
reference_main.o: reference_main.cpp timer.h utils.h reference_calc.cpp compare.cpp reference_hw1.cpp
g++ -c reference_main.cpp $(GCC_OPTS) -I $(OPENCV_INCLUDEPATH) -I $(CUDA_INCLUDEPATH) $(OPENCV_LIBPATH) $(OPENCV_TROUBLE)
student_func.o: student_func.cu utils.h
nvcc -c student_func.cu $(NVCC_OPTS)
compare.o: compare.cpp compare.h
g++ -c compare.cpp -I $(CUDA_INCLUDEPATH) $(GCC_OPTS) -I $(OPENCV_INCLUDEPATH) $(OPENCV_LIBPATH) $(OPENCV_TROUBLE)
reference_calc.o: reference_calc.cpp reference_calc.h
g++ -c reference_calc.cpp -I $(CUDA_INCLUDEPATH) $(GCC_OPTS) -I $(OPENCV_INCLUDEPATH) $(OPENCV_LIBPATH) $(OPENCV_TROUBLE)
clean:
rm -f *.o *.png hw
In the directory of /usr/local/include
there are two folders opencv and opencv2 , so everything is fine according to the arrangements .
Now how to solve the problem ?
yesterday whole day got used in solution for this problem.
Please anybody help me.. Thanks in advance...
I tried all the methods.....