GTest linker errors on Ubuntu 20.10 - c++

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.

Related

How to get Tesseract working with CGO on Windows?

I've been trying to get otiai10/gosseract (Go package for Tesseract C++ library) working on Windows without success. As a requirement, gosseract requires the installation of "tesseract-ocr, including library and headers".
The Tesseract Windows compiling documentation mentions the usage of SW and Vcpkg, which to my understanding relies on MSVC and is hence not compatible with Go.
The documentation also mentions the existence of Cygwin packages. I have tried leveraging them by installing tesseract-ocr (5.2.0-1), tesseract-ocr-devel (5.2.0-1), tesseract-ocr-eng (5.00-1) as well as mingw64-x86_64-gcc-g++ and mingw64-x86_64-gcc-core after which I defined the following environment variables:
CGO_CFLAGS=-IC:\cygwin64\usr\include
CGO_CPPFLAGS=-IC:\cygwin64\usr\include
CGO_LDFLAGS=-LC:\cygwin64\lib
PATH=C:\cygwin64\bin;...
CC=C:\cygwin64\bin\x86_64-w64-mingw32-gcc.exe
CXX=C:\cygwin64\bin\x86_64-w64-mingw32-g++.exe
However, trying to compile (through GoLand) an example project (otiai10/ocrserver) still results in linker errors:
GOROOT=C:\Users\REDACTED\go\go1.18rc1 #gosetup
GOPATH=C:\Users\REDACTED\go #gosetup
C:\Users\REDACTED\go\go1.18rc1\bin\go.exe build -o C:\Users\REDACTED\AppData\Local\Temp\GoLand\___go_build_github_com_otiai10_ocrserver.exe github.com/otiai10/ocrserver #gosetup
# github.com/otiai10/gosseract/v2
/usr/lib/gcc/x86_64-w64-mingw32/11/../../../../x86_64-w64-mingw32/bin/ld: $WORK\b133\_x003.o: in function `tesseract::TessBaseAPI::Init(char const*, char const*)':
/cygdrive/c/Users/REDACTED/go/pkg/mod/github.com/otiai10/gosseract/v2#v2.3.1/C:/cygwin64/usr/include/tesseract/baseapi.h:215: undefined reference to `tesseract::TessBaseAPI::Init(char const*, char const*, tesseract::OcrEngineMode, char**, int, 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*, 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*, bool)'
/usr/lib/gcc/x86_64-w64-mingw32/11/../../../../x86_64-w64-mingw32/bin/ld: /cygdrive/c/Users/REDACTED/go/pkg/mod/github.com/otiai10/gosseract/v2#v2.3.1/C:/cygwin64/usr/include/tesseract/baseapi.h:215: undefined reference to `tesseract::TessBaseAPI::Init(char const*, char const*, tesseract::OcrEngineMode, char**, int, 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*, 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*, bool)'
/usr/lib/gcc/x86_64-w64-mingw32/11/../../../../x86_64-w64-mingw32/bin/ld: /cygdrive/c/Users/REDACTED/go/pkg/mod/github.com/otiai10/gosseract/v2#v2.3.1/C:/cygwin64/usr/include/tesseract/baseapi.h:215: undefined reference to `tesseract::TessBaseAPI::Init(char const*, char const*, tesseract::OcrEngineMode, char**, int, 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*, 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*, bool)'
collect2: error: ld returned 1 exit status
How can one get "tesseract-ocr, including library and headers" properly set up on a Windows machine for CGO compatibility?
> go version
go version go1.17 windows/amd64
> C:\cygwin64\bin\x86_64-w64-mingw32-gcc.exe --version
x86_64-w64-mingw32-gcc (GCC) 11.3.0
> C:\cygwin64\bin\x86_64-w64-mingw32-g++.exe --version
x86_64-w64-mingw32-g++ (GCC) 11.3.0
> C:\cygwin64\bin\x86_64-w64-mingw32-ld.exe --version
GNU ld (GNU Binutils) 2.38

How to solve PCL linking errors?

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.

faild to link protobuf

I'm trying to link protobuf but I'm getting an undefined reference:
this is my CMAKE file:
I also see in the error code it has a problem with the std::string of the ABI of CPP11 but I don't know if this is the main problem or not because I'm building from a source using GCC 7.3.1
cmake_minimum_required(VERSION 3.17)
project(cpp_server_side_objects)
set(CMAKE_CXX_STANDARD 17)
SET(BOOST_LIB boost_system boost_thread)
INCLUDE(FindProtobuf)
FIND_PACKAGE(Protobuf REQUIRED)
if(Protobuf_VERBOSE)
message(STATUS "Using Protocol Buffers ${Protobuf_VERSION}")
else()
message(STATUS "cant find protobuf ${Protobuf_VERSION}")
endif()
INCLUDE_DIRECTORIES(${PROTOBUF_INCLUDE_DIR})
PROTOBUF_GENERATE_CPP(PROTO_SRC PROTO_HEADER SREXOrderRequest.proto)
ADD_LIBRARY(proto ${PROTO_HEADER} ${PROTO_SRC})
add_executable(cpp_server_side_objects main.cpp request.cpp request.h)
target_link_libraries(cpp_server_side_objects proto ${PROTOBUF_LIBRARY} ${BOOST_LIB} )
but I'm getting this error messages:
====================[ Build | cpp_server_side_objects | Debug ]=================
/home/yaodav/clion-2019.1.4/bin/cmake/linux/bin/cmake --build /home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/cmake-build-debug --target cpp_server_side_objects -- -j 4
[ 25%] Linking CXX executable cpp_server_side_objects
CMakeFiles/cpp_server_side_objects.dir/main.cpp.o: In function `server_side_order::SREXOrderRequest::set__symbol(char const*)':
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/SREXOrderRequest.proc.pb.h:618: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&&, google::protobuf::Arena*)'
CMakeFiles/cpp_server_side_objects.dir/main.cpp.o: In function `server_side_order::SREXOrderRequest::set__myid(char const*)':
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/SREXOrderRequest.proc.pb.h:691: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&&, google::protobuf::Arena*)'
CMakeFiles/cpp_server_side_objects.dir/main.cpp.o: In function `server_side_order::SREXOrderRequest::set__exdest(char const*)':
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/SREXOrderRequest.proc.pb.h:764: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&&, google::protobuf::Arena*)'
CMakeFiles/cpp_server_side_objects.dir/main.cpp.o: In function `server_side_order::SREXOrderRequest::set__userinfo(char const*)':
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/SREXOrderRequest.proc.pb.h:837: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&&, google::protobuf::Arena*)'
CMakeFiles/cpp_server_side_objects.dir/main.cpp.o: In function `server_side_order::SREXOrderRequest::set__dest(char const*)':
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/SREXOrderRequest.proc.pb.h:910: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&&, google::protobuf::Arena*)'
CMakeFiles/cpp_server_side_objects.dir/SREXOrderRequest.proc.pb.cc.o: In function `server_side_order::SREXOrderRequest::SREXOrderRequest(server_side_order::SREXOrderRequest const&)':
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/SREXOrderRequest.proc.pb.cc:155: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, google::protobuf::Arena*)'
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/SREXOrderRequest.proc.pb.cc:160: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, google::protobuf::Arena*)'
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/SREXOrderRequest.proc.pb.cc:165: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, google::protobuf::Arena*)'
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/SREXOrderRequest.proc.pb.cc:170: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, google::protobuf::Arena*)'
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/SREXOrderRequest.proc.pb.cc:175: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, google::protobuf::Arena*)'
CMakeFiles/cpp_server_side_objects.dir/SREXOrderRequest.proc.pb.cc.o: In function `server_side_order::SREXOrderRequest::_InternalParse(char const*, google::protobuf::internal::ParseContext*)':
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/SREXOrderRequest.proc.pb.cc:325: undefined reference to `google::protobuf::internal::InlineGreedyStringParser(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, char const*, google::protobuf::internal::ParseContext*)'
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/SREXOrderRequest.proc.pb.cc:336: undefined reference to `google::protobuf::internal::InlineGreedyStringParser(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, char const*, google::protobuf::internal::ParseContext*)'
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/SREXOrderRequest.proc.pb.cc:347: undefined reference to `google::protobuf::internal::InlineGreedyStringParser(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, char const*, google::protobuf::internal::ParseContext*)'
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/SREXOrderRequest.proc.pb.cc:358: undefined reference to `google::protobuf::internal::InlineGreedyStringParser(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, char const*, google::protobuf::internal::ParseContext*)'
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/SREXOrderRequest.proc.pb.cc:369: undefined reference to `google::protobuf::internal::InlineGreedyStringParser(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, char const*, google::protobuf::internal::ParseContext*)'
CMakeFiles/cpp_server_side_objects.dir/SREXOrderRequest.proc.pb.cc.o: In function `google::protobuf::internal::ArenaStringPtr::Swap(google::protobuf::internal::ArenaStringPtr*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const*, google::protobuf::Arena*)':
/usr/local/include/google/protobuf/arenastring.h:326: undefined reference to `google::protobuf::internal::ArenaStringPtr::Mutable[abi:cxx11](google::protobuf::internal::ArenaStringPtr::EmptyDefault, google::protobuf::Arena*)'
/usr/local/include/google/protobuf/arenastring.h:327: undefined reference to `google::protobuf::internal::ArenaStringPtr::Mutable[abi:cxx11](google::protobuf::internal::ArenaStringPtr::EmptyDefault, google::protobuf::Arena*)'
/usr/local/include/google/protobuf/arenastring.h:326: undefined reference to `google::protobuf::internal::ArenaStringPtr::Mutable[abi:cxx11](google::protobuf::internal::ArenaStringPtr::EmptyDefault, google::protobuf::Arena*)'
/usr/local/include/google/protobuf/arenastring.h:327: undefined reference to `google::protobuf::internal::ArenaStringPtr::Mutable[abi:cxx11](google::protobuf::internal::ArenaStringPtr::EmptyDefault, google::protobuf::Arena*)'
/usr/local/include/google/protobuf/arenastring.h:326: undefined reference to `google::protobuf::internal::ArenaStringPtr::Mutable[abi:cxx11](google::protobuf::internal::ArenaStringPtr::EmptyDefault, google::protobuf::Arena*)'
CMakeFiles/cpp_server_side_objects.dir/SREXOrderRequest.proc.pb.cc.o:/usr/local/include/google/protobuf/arenastring.h:327: more undefined references to `google::protobuf::internal::ArenaStringPtr::Mutable[abi:cxx11](google::protobuf::internal::ArenaStringPtr::EmptyDefault, google::protobuf::Arena*)' follow
CMakeFiles/cpp_server_side_objects.dir/SREXOrderRequest.proc.pb.cc.o: In function `google::protobuf::io::EpsCopyOutputStream::WriteStringMaybeAliased(unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned char*)':
/usr/local/include/google/protobuf/io/coded_stream.h:719: undefined reference to `google::protobuf::io::EpsCopyOutputStream::WriteStringMaybeAliasedOutline(unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned char*)'
CMakeFiles/cpp_server_side_objects.dir/SREXOrderRequest.proc.pb.cc.o: In function `server_side_order::SREXOrderRequest::_internal_set__symbol(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/cmake-build-debug/SREXOrderRequest.proc.pb.h:607: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, google::protobuf::Arena*)'
CMakeFiles/cpp_server_side_objects.dir/SREXOrderRequest.proc.pb.cc.o: In function `server_side_order::SREXOrderRequest::_internal_mutable__symbol[abi:cxx11]()':
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/cmake-build-debug/SREXOrderRequest.proc.pb.h:630: undefined reference to `google::protobuf::internal::ArenaStringPtr::Mutable[abi:cxx11](google::protobuf::internal::ArenaStringPtr::EmptyDefault, google::protobuf::Arena*)'
CMakeFiles/cpp_server_side_objects.dir/SREXOrderRequest.proc.pb.cc.o: In function `server_side_order::SREXOrderRequest::_internal_set__myid(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/cmake-build-debug/SREXOrderRequest.proc.pb.h:680: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, google::protobuf::Arena*)'
CMakeFiles/cpp_server_side_objects.dir/SREXOrderRequest.proc.pb.cc.o: In function `server_side_order::SREXOrderRequest::_internal_mutable__myid[abi:cxx11]()':
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/cmake-build-debug/SREXOrderRequest.proc.pb.h:703: undefined reference to `google::protobuf::internal::ArenaStringPtr::Mutable[abi:cxx11](google::protobuf::internal::ArenaStringPtr::EmptyDefault, google::protobuf::Arena*)'
CMakeFiles/cpp_server_side_objects.dir/SREXOrderRequest.proc.pb.cc.o: In function `server_side_order::SREXOrderRequest::_internal_set__exdest(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/cmake-build-debug/SREXOrderRequest.proc.pb.h:753: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, google::protobuf::Arena*)'
CMakeFiles/cpp_server_side_objects.dir/SREXOrderRequest.proc.pb.cc.o: In function `server_side_order::SREXOrderRequest::_internal_mutable__exdest[abi:cxx11]()':
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/cmake-build-debug/SREXOrderRequest.proc.pb.h:776: undefined reference to `google::protobuf::internal::ArenaStringPtr::Mutable[abi:cxx11](google::protobuf::internal::ArenaStringPtr::EmptyDefault, google::protobuf::Arena*)'
CMakeFiles/cpp_server_side_objects.dir/SREXOrderRequest.proc.pb.cc.o: In function `server_side_order::SREXOrderRequest::_internal_set__userinfo(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/cmake-build-debug/SREXOrderRequest.proc.pb.h:826: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, google::protobuf::Arena*)'
CMakeFiles/cpp_server_side_objects.dir/SREXOrderRequest.proc.pb.cc.o: In function `server_side_order::SREXOrderRequest::_internal_mutable__userinfo[abi:cxx11]()':
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/cmake-build-debug/SREXOrderRequest.proc.pb.h:849: undefined reference to `google::protobuf::internal::ArenaStringPtr::Mutable[abi:cxx11](google::protobuf::internal::ArenaStringPtr::EmptyDefault, google::protobuf::Arena*)'
CMakeFiles/cpp_server_side_objects.dir/SREXOrderRequest.proc.pb.cc.o: In function `server_side_order::SREXOrderRequest::_internal_set__dest(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/cmake-build-debug/SREXOrderRequest.proc.pb.h:899: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, google::protobuf::Arena*)'
CMakeFiles/cpp_server_side_objects.dir/SREXOrderRequest.proc.pb.cc.o: In function `server_side_order::SREXOrderRequest::_internal_mutable__dest[abi:cxx11]()':
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/cmake-build-debug/SREXOrderRequest.proc.pb.h:922: undefined reference to `google::protobuf::internal::ArenaStringPtr::Mutable[abi:cxx11](google::protobuf::internal::ArenaStringPtr::EmptyDefault, google::protobuf::Arena*)'
CMakeFiles/cpp_server_side_objects.dir/SREXOrderRequest.proc.pb.cc.o:(.rodata._ZTVN17server_side_order16SREXOrderRequestE[_ZTVN17server_side_order16SREXOrderRequestE]+0x20): undefined reference to `google::protobuf::Message::GetTypeName[abi:cxx11]() const'
CMakeFiles/cpp_server_side_objects.dir/SREXOrderRequest.proc.pb.cc.o:(.rodata._ZTVN17server_side_order16SREXOrderRequestE[_ZTVN17server_side_order16SREXOrderRequestE]+0x48): undefined reference to `google::protobuf::Message::InitializationErrorString[abi:cxx11]() const'
collect2: error: ld returned 1 exit status
gmake[3]: *** [cpp_server_side_objects] Error 1
gmake[2]: *** [CMakeFiles/cpp_server_side_objects.dir/all] Error 2
gmake[1]: *** [CMakeFiles/cpp_server_side_objects.dir/rule] Error 2
gmake: *** [cpp_server_side_objects] Error 2
how to fix it?
tried using this and this and this and with this also with no luck.
I had a similar problem. The protobuf_generate_cpp command in CMake seems to cause a problem in linking the source and header files created from the *.proto file with the necessary libraries.
My workaround was as follows. After obtaining the files created from the proto file, it was to close it so that it would not be created again.
# ---------------------------------------------------------------
## Protocol Buffers
set(CMAKE_PREFIX_PATH "C:\\DevTools\\vcpkg\\packages\\protobuf_x64-windows" "${CMAKE_PREFIX_PATH}")
set(PROTOBUF_INCLUDE_DIR "C:\\DevTools\\vcpkg\\packages\\protobuf_x64-windows\\include")
include(FindProtobuf)
find_package(Protobuf CONFIG REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIR})
include_directories(${CMAKE_CURRENT_BINARY_DIR})
#protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS src/protocolbuffers/person.proto) # this line
# copy the generated files to the build directory
file(COPY ${PROTO_HDRS} DESTINATION src/protocolbuffers)
file(COPY ${PROTO_SRCS} DESTINATION src/protocolbuffers)
message(STATUS "debug protobuf lib location:${PROTOBUF_LIBRARY}")
message(STATUS "debug protobuf include location:${PROTOBUF_INCLUDE_DIR}")
message(STATUS "proto source files:${PROTO_SRCS}")
message(STATUS "proto header files:${PROTO_HDRS}")
# ---------------------------------------------------------------
...
add_executable(${PROJECT_NAME}
${SOURCE_FILES}
${HEADER_FILES}
${PROTO_SRCS} ${PROTO_HDRS}
)
...
target_link_libraries(${PROJECT_NAME} PRIVATE
...
${Protobuf_LIBRARIES}
protobuf::libprotobuf
)

CMake failing to link Boost regex library in Clion

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.

Unresolved symbols during cross compilation linking with Boost log

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.