Undefined References to boost while making uhd in Ubuntu 16.04 - boost

My first attempt to build uhd was to use a script I had written that had worked in the past on two laptops running 14.04. After that, I went back here:
http://files.ettus.com/manual/page_build_guide.html#build_instructions_unix
After that, I went here:
https://kb.ettus.com/Building_and_Installing_the_USRP_Open-Source_Toolchain_(UHD_and_GNU_Radio)_on_Linux
I get the following compile errors. I'm at a loss, as I have install all of libboost, so I'm not sure what is missing. I'm building on the maint branch. I am on a new computer running 16.04.
[ 61%] Built target uhd
[ 61%] Linking CXX executable sync_to_gps
CMakeFiles/sync_to_gps.dir/sync_to_gps.cpp.o: In function `_main(int, char**)':
sync_to_gps.cpp:(.text+0x6de): undefined reference to `boost::program_options::options_description::options_description(std::string const&, unsigned int, unsigned int)'
CMakeFiles/sync_to_gps.dir/sync_to_gps.cpp.o: In function `boost::program_options::typed_value<std::string, char>::xparse(boost::any&, std::vector<std::string, std::allocator<std::string> > const&) const':
sync_to_gps.cpp:(.text._ZNK5boost15program_options11typed_valueISscE6xparseERNS_3anyERKSt6vectorISsSaISsEE[_ZNK5boost15program_options11typed_valueISscE6xparseERNS_3anyERKSt6vectorISsSaISsEE]+0x1f): undefined reference to `boost::program_options::validate(boost::any&, std::vector<std::string, std::allocator<std::string> > const&, std::string*, int)'
CMakeFiles/sync_to_gps.dir/sync_to_gps.cpp.o: In function `std::vector<std::string, std::allocator<std::string> > boost::program_options::to_internal<std::string>(std::vector<std::string, std::allocator<std::string> > const&)':
sync_to_gps.cpp:(.text._ZN5boost15program_options11to_internalISsEESt6vectorISsSaISsEERKS2_IT_SaIS5_EE[_ZN5boost15program_options11to_internalISsEESt6vectorISsSaISsEERKS2_IT_SaIS5_EE]+0x7d): undefined reference to `boost::program_options::to_internal(std::string const&)'
CMakeFiles/sync_to_gps.dir/sync_to_gps.cpp.o: In function `boost::program_options::basic_parsed_options<char> boost::program_options::parse_command_line<char>(int, char const* const*, boost::program_options::options_description const&, int, boost::function1<std::pair<std::string, std::string>, std::string const&>)':
sync_to_gps.cpp:(.text._ZN5boost15program_options18parse_command_lineIcEENS0_20basic_parsed_optionsIT_EEiPKPKS3_RKNS0_19options_descriptionEiNS_9function1ISt4pairISsSsERKSsEE[_ZN5boost15program_options18parse_command_lineIcEENS0_20basic_parsed_optionsIT_EEiPKPKS3_RKNS0_19options_descriptionEiNS_9function1ISt4pairISsSsERKSsEE]+0x15e): undefined reference to `boost::program_options::detail::cmdline::cmdline(std::vector<std::string, std::allocator<std::string> > const&)'
sync_to_gps.cpp:(.text._ZN5boost15program_options18parse_command_lineIcEENS0_20basic_parsed_optionsIT_EEiPKPKS3_RKNS0_19options_descriptionEiNS_9function1ISt4pairISsSsERKSsEE[_ZN5boost15program_options18parse_command_lineIcEENS0_20basic_parsed_optionsIT_EEiPKPKS3_RKNS0_19options_descriptionEiNS_9function1ISt4pairISsSsERKSsEE]+0x1ef): undefined reference to `boost::program_options::detail::cmdline::set_additional_parser(boost::function1<std::pair<std::string, std::string>, std::string const&>)'
CMakeFiles/sync_to_gps.dir/sync_to_gps.cpp.o: In function `boost::program_options::typed_value<std::string, char>::name() const':
sync_to_gps.cpp:(.text._ZNK5boost15program_options11typed_valueISscE4nameEv[_ZNK5boost15program_options11typed_valueISscE4nameEv]+0x29): undefined reference to `boost::program_options::arg'
CMakeFiles/sync_to_gps.dir/sync_to_gps.cpp.o:(.rodata._ZTVN5boost15program_options11typed_valueISscEE[_ZTVN5boost15program_options11typed_valueISscEE]+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'
../lib/libuhd.so.003.010: undefined reference to `boost::archive::text_iarchive_impl<boost::archive::text_iarchive>::load(std::string&)'
../lib/libuhd.so.003.010: undefined reference to `boost::match_results<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > > >::maybe_assign(boost::match_results<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > > > const&)'
../lib/libuhd.so.003.010: undefined reference to `boost::filesystem::path_traits::dispatch(boost::filesystem::directory_entry const&, std::string&)'
../lib/libuhd.so.003.010: undefined reference to `boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::construct_init(boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > > const&, boost::regex_constants::_match_flags)'
../lib/libuhd.so.003.010: undefined reference to `boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::save(std::string const&)'
collect2: error: ld returned 1 exit status
examples/CMakeFiles/sync_to_gps.dir/build.make:107: recipe for target 'examples/sync_to_gps' failed
make[2]: *** [examples/sync_to_gps] Error 1
CMakeFiles/Makefile2:393: recipe for target 'examples/CMakeFiles/sync_to_gps.dir/all' failed
make[1]: *** [examples/CMakeFiles/sync_to_gps.dir/all] Error 2
Makefile:160: recipe for target 'all' failed
make: *** [all] Error 2

I had a similar issue which turned out to be an older version of GCC still installed on my Ubuntu system being called. Look at /usr/bin/gcc and /usr/bin/g++ and see if they're linked to /usr/bin/gcc-5 and /usr/bin/g++-5 respectively.

Related

undefined reference to `(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)' when using tensorflow_cc.so

I am working on linking Tensorflow2 shared libraries (*.so) files into my C++ program. The libtensorflow_cc and libtensorflow_framework.so use bazel-3.7.2 and gcc7.3 and is linked to another library I have ‘libmyproj.so’. I want to link this libmyproj.so to my main program which are built with the same gcc7.3. I have tried using the -D_GLIBCXX_USE_CXX11_ABI=0 flag for ABI compatibility (from https://www.tensorflow.org/install/source and Converting std::__cxx11::string to std::string) but without any success. I am stuck at the following error:
undefined reference to ml_model::ml_model(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)' undefined reference to ml_model::preprocess_data(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<float, std::allocator<float> >, int&, int&, std::vector<int, std::allocator<int> >&)' undefined reference to ml_model::get_predictions(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > int, std::vector<int, std::allocator<int> >)'
in function std::__cxx11::basic_string<char, std::char_traits,
std::allocator >* tensorflow::internal::MakeCheckOpString<long,
int>(long const&, int const&, char const*)': undefined reference to tensorflow::internal::CheckOpMessageBuilder::NewString[abi:cxx11]()'
Any suggestions on why this is happening?
Check if the libstdc++ version is correct。 Your problem may be the tensorflow_cc.so compiler with higher libstdc++ version, but your build env libstdc++ is lower, so some symbols will not be found.
Get libstdc++ version:
bash$ /sbin/ldconfig -p | grep stdc++
libstdc++.so.6 (libc6,x86_64) => /lib/x86_64-linux-gnu/libstdc++.so.6
bash$ ls -l /lib/x86_64-linux-gnu/libstdc++.so.6
lrwxrwxrwx 1 root root 19 Jan 10 2021 /lib/x86_64-linux-gnu/libstdc++.so.6 -> libstdc++.so.6.0.28
The symlink points to a versioned file, in this case 6.0.28.
Update libstdc++; how to do this exactly depends on your distro, but instructions should not be hard to find in Google.

Boost undefined symbol issue while linking with static library with memory sanitizer

I am getting below error while building static library uhd-types and linking with boost libraries v1.74 with memory sanitizer flag -fsanitize=memory.
[ 63%] Built target uhd-types
[ 65%] Linking CXX executable ../../bin/unit_tests
/usr/bin/ld: ../../lib/libuhd-types.a(device_addr.cpp.o): in function `boost::re_detail_107400::cpp_regex_traits_implementation<char>::lookup_collatename(char const*, char const*) const':
/root/include/boost/regex/v4/cpp_regex_traits.hpp:680: undefined reference to `boost::re_detail_107400::lookup_default_collate_name(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)'
/usr/bin/ld: ../../lib/libuhd-types.a(device_addr.cpp.o): in function `boost::re_detail_107400::basic_regex_parser<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::fail(boost::regex_constants::error_type, long, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, long)':
/root/include/boost/regex/v4/basic_regex_parser.hpp:245: undefined reference to `boost::regex_error::regex_error(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, boost::regex_constants::error_type, long)'
/usr/bin/ld: ../../lib/libuhd-types.a(device_addr.cpp.o): in function `boost::re_detail_107400::basic_regex_creator<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::fixup_recursions(boost::re_detail_107400::re_syntax_base*)':
/root/include/boost/regex/v4/basic_regex_creator.hpp:788: undefined reference to `boost::regex_error::regex_error(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, boost::regex_constants::error_type, long)'
/usr/bin/ld: /root//include/boost/regex/v4/basic_regex_creator.hpp:877: undefined reference to `boost::regex_error::regex_error(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, boost::regex_constants::error_type, long)'
/usr/bin/ld: ../../lib/libuhd-types.a(device_addr.cpp.o): in function `boost::re_detail_107400::basic_regex_creator<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::create_startmaps(boost::re_detail_107400::re_syntax_base*)':
/root/include/boost/regex/v4/basic_regex_creator.hpp:943: undefined reference to `boost::regex_error::regex_error(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, boost::regex_constants::error_type, long)'
/usr/bin/ld: ../../lib/libuhd-types.a(device_addr.cpp.o): in function `boost::re_detail_107400::basic_regex_creator<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::create_startmap(boost::re_detail_107400::re_syntax_base*, unsigned char*, unsigned int*, unsigned char)':
/root/include/boost/regex/v4/basic_regex_creator.hpp:1156: undefined reference to `boost::regex_error::regex_error(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, boost::regex_constants::error_type, long)'
clang-10: error: linker command failed with exit code 1 (use -v to see invocation)
I already linking uhd-types to boost libraries using target_link_libraries.

undefined reference to `google::protobuf::Message::DebugString[abi:cxx11]() const

I am trying to build DeepLabv2's version of caffe.
I am using anaconda2 for package management.
I get the following errors:
CXX/LD -o .build_release/tools/upgrade_net_proto_text.bin
/usr/bin/ld: warning: libhdf5.so.10, needed by /home/asim/anaconda2/lib/libmatio.so, not found (try using -rpath or -rpath-link)
.build_release/lib/libcaffe.so: undefined reference to `google::protobuf::Message::DebugString[abi:cxx11]() const'
.build_release/lib/libcaffe.so: undefined reference to `google::protobuf::MessageFactory::InternalRegisterGeneratedFile(char const*, void (*)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&))'
.build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, google::protobuf::io::CodedOutputStream*)'
.build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::WireFormatLite::ReadBytes(google::protobuf::io::CodedInputStream*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)'
.build_release/lib/libcaffe.so: undefined reference to `google::protobuf::MessageLite::ParseFromString(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
.build_release/lib/libcaffe.so: undefined reference to `google::protobuf::Message::GetTypeName[abi:cxx11]() const'
.build_release/lib/libcaffe.so: undefined reference to `google::protobuf::io::CodedOutputStream::WriteStringWithSizeToArray(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned char*)'
.build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::fixed_address_empty_string[abi:cxx11]'
.build_release/lib/libcaffe.so: undefined reference to `google::protobuf::Message::InitializationErrorString[abi:cxx11]() const'
.build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::NameOfEnum[abi:cxx11](google::protobuf::EnumDescriptor const*, int)'
.build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::WireFormatLite::WriteBytesMaybeAliased(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, google::protobuf::io::CodedOutputStream*)'
.build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::AssignDescriptors(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, google::protobuf::internal::MigrationSchema const*, google::protobuf::Message const* const*, unsigned int const*, google::protobuf::MessageFactory*, google::protobuf::Metadata*, google::protobuf::EnumDescriptor const**, google::protobuf::ServiceDescriptor const**)'
.build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::WireFormatLite::WriteString(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, google::protobuf::io::CodedOutputStream*)'
/home/asim/anaconda2/lib/libmatio.so: undefined reference to `H5Rdereference'
.build_release/lib/libcaffe.so: undefined reference to `google::protobuf::MessageLite::SerializeToString(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*) const'
.build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::ArenaStringPtr::AssignWithDefault(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const*, google::protobuf::internal::ArenaStringPtr)'
collect2: error: ld returned 1 exit status
Makefile:621: recipe for target '.build_release/tools/upgrade_net_proto_text.bin' failed
make: *** [.build_release/tools/upgrade_net_proto_text.bin] Error 1
I tried to add Library Directories to the Makefile.
Specifically
LIBRARY_DIRS += /home/asim/anaconda2/lib /lib/x86_64-linux-gnu/
But it is not working.

Building Caffe cpp_classification example in external context

I have already configured and built Caffe from the ground up in CPU_ONLY and GPU_ONLY modes (with the respective samples and tools); and fairly satisfied with the out-of-the-box results.
However, I am starting my own project derived from the cpp_classification example, and having difficulties in building it independent of the overall Caffe build system. As such, I have gone back to the cpp_classification example and have been working to build that as a standalone (just to ensure that I am not leaving anything out) and encountering similar errors.
I sharing the contents of my build-errors output and the CMakeLists.txt with you in the hopes that someone else who has successfully hoisted the cpp_classification example can provide guidance.
I have narrowed down the build-errors I am getting to the following:
Scanning dependencies of target cpp_classification
[ 50%] Building CXX object CMakeFiles/cpp_classification.dir/classification.cpp.o
[100%] Linking CXX executable cpp_classification
CMakeFiles/cpp_classification.dir/classification.cpp.o: In function `Classifier::Classifier(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&, 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&)':
/home/rudycazabon/caffe/examples/cpp_classification/classification.cpp:62: undefined reference to `caffe::Net<float>::Net(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, caffe::Phase, 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*, caffe::Net<float> const*)'
/home/rudycazabon/caffe/examples/cpp_classification/classification.cpp:63: undefined reference to `caffe::Net<float>::CopyTrainedLayersFrom(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
CMakeFiles/cpp_classification.dir/classification.cpp.o: In function `Classifier::SetMean(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/home/rudycazabon/caffe/examples/cpp_classification/classification.cpp:124: undefined reference to `caffe::BlobProto::BlobProto()'
/home/rudycazabon/caffe/examples/cpp_classification/classification.cpp:129: undefined reference to `caffe::Blob<float>::FromProto(caffe::BlobProto const&, bool)'
/home/rudycazabon/caffe/examples/cpp_classification/classification.cpp:135: undefined reference to `caffe::Blob<float>::mutable_cpu_data()'
/home/rudycazabon/caffe/examples/cpp_classification/classification.cpp:124: undefined reference to `caffe::BlobProto::~BlobProto()'
/home/rudycazabon/caffe/examples/cpp_classification/classification.cpp:124: undefined reference to `caffe::BlobProto::~BlobProto()'
CMakeFiles/cpp_classification.dir/classification.cpp.o: In function `Classifier::Predict(cv::Mat const&)':
/home/rudycazabon/caffe/examples/cpp_classification/classification.cpp:156: undefined reference to `caffe::Blob<float>::Reshape(int, int, int, int)'
/home/rudycazabon/caffe/examples/cpp_classification/classification.cpp:158: undefined reference to `caffe::Net<float>::Reshape()'
/home/rudycazabon/caffe/examples/cpp_classification/classification.cpp:165: undefined reference to `caffe::Net<float>::Forward(float*)'
/home/rudycazabon/caffe/examples/cpp_classification/classification.cpp:169: undefined reference to `caffe::Blob<float>::cpu_data() const'
CMakeFiles/cpp_classification.dir/classification.cpp.o: In function `Classifier::WrapInputLayer(std::vector<cv::Mat, std::allocator<cv::Mat> >*)':
/home/rudycazabon/caffe/examples/cpp_classification/classification.cpp:184: undefined reference to `caffe::Blob<float>::mutable_cpu_data()'
CMakeFiles/cpp_classification.dir/classification.cpp.o: In function `Classifier::Preprocess(cv::Mat const&, std::vector<cv::Mat, std::allocator<cv::Mat> >*)':
/home/rudycazabon/caffe/examples/cpp_classification/classification.cpp:227: undefined reference to `caffe::Blob<float>::cpu_data() const'
CMakeFiles/cpp_classification.dir/classification.cpp.o: In function `caffe::Caffe::set_mode(caffe::Caffe::Brew)':
/home/rudycazabon/caffe/distribute/include/caffe/common.hpp:148: undefined reference to `caffe::Caffe::Get()'
CMakeFiles/cpp_classification.dir/classification.cpp.o: In function `caffe::ReadProtoFromBinaryFileOrDie(char const*, google::protobuf::Message*)':
/home/rudycazabon/caffe/distribute/include/caffe/util/io.hpp:78: undefined reference to `caffe::ReadProtoFromBinaryFile(char const*, google::protobuf::Message*)'
collect2
My corresponding CMakeList.txt is as follows:
cmake_minimum_required(VERSION 3.6)
project(cpp_classification)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
set(CAFFE_HOME ~/caffe/distribute)
find_package(OpenCV REQUIRED)
find_package(Caffe REQUIRED)
find_package(GTest REQUIRED)
find_package(glog REQUIRED)
find_package(Boost REQUIRED COMPONENTS system)
find_package(Protobuf REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(SOURCE_FILES classification.cpp)
include_directories(${CAFFE_HOME}/include ${Boost_INCLUDE_DIRS} )
link_directories(${CAFFE_HOME}/lib ${Boost_LIBRARY_DIRS})
add_executable(cpp_classification
${SOURCE_FILES}
${GLOG_INCLUDE_DIR}
${Caffe_INCLUDE_DIR}
${Protobuf_INCLUDE_DIR})
TARGET_LINK_LIBRARIES(cpp_classification
${OpenCV_LIBS}
${Boost_LIBRARIES}
${GLOG_LIBRARY}
${CAFFE_LIBRARY}
${Protobuf_LIBRARY})
try with
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")
It tells gcc to use the old ABI for <string>.

compiling litecoin OSX 10.9.1

I'm trying to compile the Litecoin source (https://github.com/litecoin-project/litecoin.git). Doing this in windows with VmWare OSX 10.9.1(64bit).
I cloned it and in terminal ran:
make -f makefile.osx USE_UPNP=-
It spits out this error:
Undefined symbols for architecture x86_64:
"boost::program_options::to_internal(std::string const&)", referenced from:
boost::program_options::detail::basic_config_file_iterator<char>::getline(std::string&) in util.o
"boost::program_options::detail::common_config_file_iterator::common_config_file_iterator(std::set<std::string, std::less<std::string>, std::allocator<std::string> > const&, bool)", referenced from:
boost::program_options::detail::basic_config_file_iterator<char>::basic_config_file_iterator(std::istream&, std::set<std::string, std::less<std::string>, std::allocator<std::string> > const&, bool) in util.o
"Db::verify(char const*, char const*, std::ostream*, unsigned int)", referenced from:
CDBEnv::Verify(std::string, bool (*)(CDBEnv&, std::string)) in db.o
CDBEnv::Salvage(std::string, bool, std::vector<std::pair<std::vector<unsigned char, std::allocator<unsigned char> >, std::vector<unsigned char, std::allocator<unsigned char> > >, std::allocator<std::pair<std::vector<unsigned char, std::allocator<unsigned char> >, std::vector<unsigned char, std::allocator<unsigned char> > > > >&) in db.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [litecoind] Error 1
I've been googling like crazy but can't seem to find a proper solution.

Resources