Error while linking libvorbisfile.dylib into Mac application - oggvorbis

I'm working on a program that loads sounds from Ogg Vorbis files, but whatever I do, the XCode project just doesn't seem to want to link libvorbisfile.a into my program. I keep getting linking errors:
"_ov_read", referenced from:
GSound::GSound(GWorld*, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)in GSound.o
GSound::GSound(GWorld*, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)in GSound.o
"_ov_clear", referenced from:
GSound::GSound(GWorld*, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)in GSound.o
GSound::GSound(GWorld*, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)in GSound.o
"_ov_info", referenced from:
GSound::GSound(GWorld*, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)in GSound.o
GSound::GSound(GWorld*, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)in GSound.o
"_ov_open", referenced from:
GSound::GSound(GWorld*, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)in GSound.o
GSound::GSound(GWorld*, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)in GSound.o
ld: symbol(s) not found

I found the problem. I had to compile Vorbis as a framework.

Related

Build boost from source with manually built gcc compiler in cluster

I am trying to compile Boost 1.79.0 in a cluster using the GCC compiler version 12.1.0 that I have compiled manually since the GCC version of the cluster is very old.
After compiling GCC, I have exported the following paths in a shell script that I source every time in the terminal before installing or running a program. I have manually installed CMake and several programs.
However, I am still struggling with compiling Boost. It is complaining about undefined references in C++11 so I guess there is something that is linked wrongly.
Could anyone provide any suggestions to overcome this issue?
Here is my exports in the shell script:
export PATH=/lustre/home/ucemkmo/Softwares/gcc-12.1.0/bin:$PATH
export CFLAGS="-I /lustre/home/ucemkmo/Softwares/gcc-12.1.0/include";
export LDFLAGS="-L /lustre/home/ucemkmo/Softwares/gcc-12.1.0/lib64";
export CPPFLAGS="-I /lustre/home/ucemkmo/Softwares/gcc-12.1.0/include";
export CXXFLAGS="-L /lustre/home/ucemkmo/Softwares/gcc-12.1.0/lib64";
export LD_LIBRARY_PATH=/lustre/home/ucemkmo/Softwares/gcc-12.1.0/lib64:$LD_LIBRARY_PATH
export LD_RUN_PATH=/lustre/home/ucemkmo/Softwares/gcc-12.1.0/lib64
export LD="/lustre/home/ucemkmo/Softwares/gcc-12.1.0/bin/g++"
export MANPATH=/lustre/home/ucemkmo/Softwares/gcc-12.1.0/share/man:$MANPATH
export INFOPATH=/lustre/home/ucemkmo/Softwares/gcc-12.1.0/share/info:$INFOPATH
export INFO_PATH=/lustre/home/ucemkmo/Softwares/gcc-12.1.0/share/info:$INFO_PATH
export AR=/lustre/home/ucemkmo/Softwares/gcc-12.1.0/bin/gcc-ar
export CC=/lustre/home/ucemkmo/Softwares/gcc-12.1.0/bin/gcc
export CXX=/lustre/home/ucemkmo/Softwares/gcc-12.1.0/bin/g++
export LD=/lustre/home/ucemkmo/Softwares/gcc-12.1.0/bin/g++
export CXXCPP="/lustre/home/ucemkmo/Softwares/gcc-12.1.0/bin/g++ -E"
export FC=/lustre/home/ucemkmo/Softwares/gcc-12.1.0/bin/gfortran
export F77=/lustre/home/ucemkmo/Softwares/gcc-12.1.0/bin/gfortran
export F90=/lustre/home/ucemkmo/Softwares/gcc-12.1.0/bin/gfortran
export COLLECT_GCC=gcc
export COLLECT_LTO_WRAPPER=/lustre/home/ucemkmo/Softwares/gcc-12.1.0/bin/../libexec/gcc/x86_64-unknown-linux-gnu/12.1.0/lto-wrapper
export PATH=/lustre/home/ucemkmo/Softwares/cmake-3.24.0/bin:$PATH
export PATH=/lustre/home/ucemkmo/Softwares/python-3.10.5/3.10.5/bin:$PATH
export PETSC_DIR=/lustre/home/ucemkmo/Softwares/petsc
export PETSC_ARCH=arch-linux-c-opt
Here are the error messages I am receiving during the compilation of Boost v1.79.0:
Building B2 engine..
###
###
### Using 'gcc' toolset.
###
###
g++ (GCC) 12.1.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
###
###
> g++ -x c++ -std=c++11 -O2 -s -DNDEBUG builtins.cpp class.cpp command.cpp compile.cpp constants.cpp cwd.cpp debug.cpp debugger.cpp execcmd.cpp execnt.cpp execunix.cpp filesys.cpp filent.cpp fileunix.cpp frames.cpp function.cpp glob.cpp hash.cpp hcache.cpp hdrmacro.cpp headers.cpp jam_strings.cpp jam.cpp jamgram.cpp lists.cpp make.cpp make1.cpp md5.cpp mem.cpp modules.cpp native.cpp object.cpp option.cpp output.cpp parse.cpp pathnt.cpp pathsys.cpp pathunix.cpp regexp.cpp rules.cpp scan.cpp search.cpp startup.cpp subst.cpp sysinfo.cpp timestamp.cpp variable.cpp w32_getreg.cpp modules/order.cpp modules/path.cpp modules/property-set.cpp modules/regex.cpp modules/sequence.cpp modules/set.cpp -o b2
/tmp/cc1S1rUW.o: In function `builtin_normalize_path(frame*, int)':
builtins.cpp:(.text+0x14ea): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_append(char const*, unsigned long)'
builtins.cpp:(.text+0x1510): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_append(char const*, unsigned long)'
/tmp/cc8w84jf.o: In function `debug_print_frame_info(_frame_info&)':
debugger.cpp:(.text+0x3d7): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::compare(char const*) const'
/tmp/cc8w84jf.o: In function `debug_frame_read(_IO_FILE*, _frame_info*)':
debugger.cpp:(.text+0x1707): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_replace(unsigned long, unsigned long, char const*, unsigned long)'
/tmp/cceSnutQ.o: In function `var_parse_to_string(VAR_PARSE_GROUP*, bool)':
function.cpp:(.text+0x1683): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_append(char const*, unsigned long)'
function.cpp:(.text+0x16b5): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_append(char const*, unsigned long)'
function.cpp:(.text+0x171c): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_append(char const*, unsigned long)'
function.cpp:(.text+0x1770): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_append(char const*, unsigned long)'
function.cpp:(.text+0x17b3): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_append(char const*, unsigned long)'
/tmp/cceSnutQ.o:function.cpp:(.text+0x17d3): more undefined references to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_append(char const*, unsigned long)' follow
/tmp/cceSnutQ.o: In function `var_parse_to_string(VAR_PARSE_VAR const*, bool)':
function.cpp:(.text+0x193f): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_replace(unsigned long, unsigned long, char const*, unsigned long)'
function.cpp:(.text+0x19b0): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_append(char const*, unsigned long)'
function.cpp:(.text+0x1a2e): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_append(char const*, unsigned long)'
function.cpp:(.text+0x1ae2): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_append(char const*, unsigned long)'
function.cpp:(.text+0x1b40): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_replace(unsigned long, unsigned long, char const*, unsigned long)'
function.cpp:(.text+0x1bf3): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_append(char const*, unsigned long)'
function.cpp:(.text+0x1c3e): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_create(unsigned long&, unsigned long)'
/tmp/ccwxFfFi.o: In function `errno_printf(char const*, ...)':
output.cpp:(.text+0x69d): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct(unsigned long, char)'
output.cpp:(.text+0x732): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_replace(unsigned long, unsigned long, char const*, unsigned long)'
output.cpp:(.text+0x7a2): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_append(char const*, unsigned long)'
output.cpp:(.text+0x8bb): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_append(char const*, unsigned long)'
output.cpp:(.text+0x8f0): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_append(char const*, unsigned long)'
output.cpp:(.text+0x92a): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_append(char const*, unsigned long)'
output.cpp:(.text+0x953): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_append(char const*, unsigned long)'
output.cpp:(.text+0x9bd): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct(unsigned long, char)'
output.cpp:(.text+0xa81): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct(unsigned long, char)'
/tmp/cc7flVRU.o: In function `void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char const*>(char const*, char const*, std::forward_iterator_tag) [clone .isra.0]':
pathsys.cpp:(.text+0x68): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_create(unsigned long&, unsigned long)'
/tmp/cc7flVRU.o: In function `b2::paths::normalize(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
pathsys.cpp:(.text+0x51d): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_append(char const*, unsigned long)'
pathsys.cpp:(.text+0x59d): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::rfind(char, unsigned long) const'
pathsys.cpp:(.text+0x5ee): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_erase(unsigned long, unsigned long)'
pathsys.cpp:(.text+0x62d): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_replace(unsigned long, unsigned long, char const*, unsigned long)'
pathsys.cpp:(.text+0x6e7): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_erase(unsigned long, unsigned long)'
pathsys.cpp:(.text+0x711): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_erase(unsigned long, unsigned long)'
pathsys.cpp:(.text+0x761): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_erase(unsigned long, unsigned long)'
/tmp/ccR9xr0R.o: In function `void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char*>(char*, char*, std::forward_iterator_tag) [clone .isra.0]':
startup.cpp:(.text+0x68): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_create(unsigned long&, unsigned long)'
/tmp/ccR9xr0R.o: In function `void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char const*>(char const*, char const*, std::forward_iterator_tag) [clone .isra.0]':
startup.cpp:(.text+0x108): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_create(unsigned long&, unsigned long)'
/tmp/ccR9xr0R.o: In function `b2::startup::builtin_boost_build(frame*, int)':
startup.cpp:(.text+0x3d2): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_append(char const*, unsigned long)'
startup.cpp:(.text+0x459): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_append(char const*, unsigned long)'
startup.cpp:(.text+0x70a): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_append(char const*, unsigned long)'
startup.cpp:(.text+0x86f): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_create(unsigned long&, unsigned long)'
startup.cpp:(.text+0x8d2): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_assign(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
startup.cpp:(.text+0x986): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_assign(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/tmp/ccR9xr0R.o: In function `b2::startup::bootstrap(frame*)':
startup.cpp:(.text+0x1045): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_append(char const*, unsigned long)'
startup.cpp:(.text+0x114d): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::rfind(char, unsigned long) const'
startup.cpp:(.text+0x14e5): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_append(char const*, unsigned long)'
startup.cpp:(.text+0x1517): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_append(char const*, unsigned long)'
startup.cpp:(.text+0x1658): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_append(char const*, unsigned long)'
startup.cpp:(.text+0x168a): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_append(char const*, unsigned long)'
startup.cpp:(.text+0x1852): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_append(char const*, unsigned long)'
/tmp/ccR9xr0R.o:startup.cpp:(.text+0x1884): more undefined references to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_append(char const*, unsigned long)' follow
/tmp/ccR9xr0R.o: In function `b2::startup::bootstrap(frame*)':
startup.cpp:(.text+0x1a46): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_create(unsigned long&, unsigned long)'
startup.cpp:(.text+0x1ba6): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_assign(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
startup.cpp:(.text+0x1c6e): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_assign(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
startup.cpp:(.text+0x1c93): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_create(unsigned long&, unsigned long)'
startup.cpp:(.text+0x1ceb): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_create(unsigned long&, unsigned long)'
startup.cpp:(.text+0x1d3e): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_assign(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/tmp/ccR9xr0R.o: In function `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > std::operator+<char, std::char_traits<char>, std::allocator<char> >(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&)':
startup.cpp:(.text._ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EERKS8_SA_[_ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EERKS8_SA_]+0x42): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_append(char const*, unsigned long)'
/tmp/cceOb6PB.o: In function `cwd_init()':
cwd.cpp:(.text+0x87): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_replace(unsigned long, unsigned long, char const*, unsigned long)'
/tmp/cceOb6PB.o: In function `_GLOBAL__sub_I__Z8cwd_initv':
cwd.cpp:(.text.startup+0xb): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
collect2: error: ld returned 1 exit status
> cp b2 bjam
cp: cannot stat ‘b2’: No such file or directory
Failed to build B2 build engine
It seems that you are facing a problem regarding Dual ABIs:
If you get linker errors about undefined references to symbols that
involve types in the std::__cxx11 namespace or the tag [abi:cxx11]
then it probably indicates that you are trying to link together object
files that were compiled with different values for the
_GLIBCXX_USE_CXX11_ABI macro. This commonly happens when linking to a third-party library that was compiled with an older version of GCC. If
the third-party library cannot be rebuilt with the new ABI then you
will need to recompile your code with the old ABI.
In other words, some of the boost dependencies has been compiled using your old gcc. See the full page in gcc documentation, here.

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.

Boost spirit x3 example calculator (calc8, calc9) linker error

I'm very new with boost spirit (and with boost). Its very interesting library.
I use qtcreator + MinGW 5.3.
I simply add every source file from git_hub_calc8 into new project and add some boost library, but i got the following error trying to build (All other examples work fine)
C:\Program Files\boost\boost\boost\spirit\home\x3\nonterminal\rule.hpp:113: ошибка: undefined reference to `bool client::parser::parse_rule<__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, boost::spirit::x3::context<boost::spirit::x3::error_handler_tag, std::reference_wrapper<boost::spirit::x3::error_handler<__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >, boost::spirit::x3::context<boost::spirit::x3::skipper_tag, boost::spirit::x3::char_class<boost::spirit::char_encoding::ascii, boost::spirit::x3::space_tag> const, boost::spirit::x3::unused_type> >, std::__cxx11::list<client::ast::statement, std::allocator<client::ast::statement> > >(boost::spirit::x3::rule<client::parser::statement_class, std::__cxx11::list<client::ast::statement, std::allocator<client::ast::statement> >, false>, __gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >&, __gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > const&, boost::spirit::x3::context<boost::spirit::x3::error_handler_tag, std::reference_wrapper<boost::spirit::x3::error_handler<__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >, boost::spirit::x3::context<boost::spirit::x3::skipper_tag, boost::spirit::x3::char_class<boost::spirit::char_encoding::ascii, boost::spirit::x3::space_tag> const, boost::spirit::x3::unused_type> > const&, std::__cxx11::list<client::ast::statement, std::allocator<client::ast::statement> >&)'
What did i wrong? How should i create project with this example?
Seems like a problem with BOOST_SPIRIT_DECLARE beacause a place pointed out by error is call for a template function connected with this define
(template <typename Iterator, typename Context, typename Attribute_>
bool parse(Iterator& first, Iterator const& last
, Context const& context, unused_type, Attribute_& attr) const
{
return parse_rule(*this, first, last, context, attr);
}
The BOOST_SPIRIT_INSTANTIATE marco is equivalent to doing
namespace client { namespace parser
{
template bool parse_rule<iterator_type, context_type, statement_type::attribute_type>(
statement_type rule_, iterator_type &first, iterator_type const &last,
context_type const &context,
statement_type ::attribute_type &attr);
;
}}
So the crucial bit is that iterator_type and context_type match exactly the ones required at the call site. Now, the unresolved symbol is (demangled):
bool client::parser::parse_rule<
__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >,
boost::spirit::x3::context<
boost::spirit::x3::error_handler_tag,
std::reference_wrapper<boost::spirit::x3::error_handler<__gnu_cxx::__normal_iterator<
char const *, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >,
boost::spirit::x3::context<
boost::spirit::x3::skipper_tag,
boost::spirit::x3::char_class<boost::spirit::char_encoding::ascii, boost::spirit::x3::space_tag> const,
boost::spirit::x3::unused_type> >,
std::__cxx11::list<client::ast::statement, std::allocator<client::ast::statement> >
>
(boost::spirit::x3::rule<client::parser::statement_class, std::__cxx11::list<client::ast::statement, std::allocator<client::ast::statement> >, false>,
__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >&,
__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > const&,
boost::spirit::x3::context<
boost::spirit::x3::error_handler_tag,
std::reference_wrapper<boost::spirit::x3::error_handler<__gnu_cxx::__normal_iterator<
char const *, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >,
boost::spirit::x3::context<
boost::spirit::x3::skipper_tag,
boost::spirit::x3::char_class<boost::spirit::char_encoding::ascii, boost::spirit::x3::space_tag> const,
boost::spirit::x3::unused_type> > const &,
std::__cxx11::list<client::ast::statement, std::allocator<client::ast::statement> >&)
This implies the iterator_type should be:
__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >,
Which is indeed what std::string::const_iterator expands to on my system. So, the mismatch is likely in the context type. By adding a forced type error above the BOOST_SPIRIT_INSTANTIATE invocation like so:
struct {} _ = *static_cast<client::parser::context_type*>(nullptr);
I was able to force the compiler to output the expanded type of context_type at the point of instantiation:
statement.cpp:12 error: conversion from ‘client::parser::context_type {aka boost::spirit::x3::context<boost::spirit::x3::error_handler_tag, const std::reference_wrapper<boost::spirit::x3::error_handler<__gnu_cxx::__normal_iterator<const char*, std::__cxx11::basic_string<char> > > >, boost::spirit::x3::context<boost::spirit::x3::skipper_tag, const boost::spirit::x3::char_class<boost::spirit::char_encoding::ascii, boost::spirit::x3::space_tag>, boost::spirit::x3::unused_type> >}’ to non-scalar type ‘client::parser::<anonymous struct>’ requested
Which tells us the context type is (formatted for legibility):
boost::spirit::x3::context<
boost::spirit::x3::error_handler_tag,
const std::reference_wrapper<boost::spirit::x3::error_handler<
__gnu_cxx::__normal_iterator<const char *, std::__cxx11::basic_string<char> > > >,
boost::spirit::x3::context<
boost::spirit::x3::skipper_tag,
boost::spirit::x3::char_class<boost::spirit::char_encoding::ascii, boost::spirit::x3::space_tag> const,
boost::spirit::x3::unused_type> >,
BUT: the linker has it as
boost::spirit::x3::context<
boost::spirit::x3::error_handler_tag,
std::reference_wrapper<boost::spirit::x3::error_handler<
__gnu_cxx::__normal_iterator<const char *, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >,
boost::spirit::x3::context<
boost::spirit::x3::skipper_tag,
boost::spirit::x3::char_class<boost::spirit::char_encoding::ascii, boost::spirit::x3::space_tag> const,
boost::spirit::x3::unused_type> >
The most conspicuous difference is in the spelling of the defaulted template arguments on std::basic_string (char_traits and the allocator), but that's not actually a difference. The difference that DOES matter, though, is the absense of const with the reference_wrapper<> type.
Fixing It
I suppose this might have been a change once upon a time in the history of X3. The easiest fix in this case is to drop the const in config.hpp:
typedef x3::context<
error_handler_tag
, std::reference_wrapper<error_handler_type>
, phrase_context_type>
context_type;
And indeed, it now compiles

linker can not find symbols but they're there?

Trying to compile this cfgparser example.
$ g++ example.cc -lcfgparser
: In function `main':
example.cc:(.text+0x6b): undefined reference to `ConfigParser_t::readFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
example.cc:(.text+0x160): undefined reference to `ConfigParser_t::getValue(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*) const'
example.cc:(.text+0x2d9): undefined reference to `ConfigParser_t::getValue(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, int*) const'
example.cc:(.text+0x43c): undefined reference to `ConfigParser_t::getValue(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, double*) const'
example.cc:(.text+0x5b1): undefined reference to `ConfigParser_t::getValue(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool*) const'
example.cc:(.text+0x78c): undefined reference to `ConfigParser_t::getValue(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, 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'
example.cc:(.text+0xa15): undefined reference to `ConfigParser_t::getValue(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*) const'
example.cc:(.text+0xba2): undefined reference to `ConfigParser_t::getValue(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*) const'
example.cc:(.text+0xd15): undefined reference to `ConfigParser_t::getValue(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*) const'
example.cc:(.text+0xe7f): undefined reference to `ConfigParser_t::getValue(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*) const'
collect2: error: ld returned 1 exit statu
But clearly those symbols are there:
$ nm -gC /usr/lib/libcfgparser.so
000000000003710 T ConfigParser_t::readFile(std::string const&)
0000000000004880 T ConfigParser_t::ConfigParser_t(std::string const&)
00000000000024c0 T ConfigParser_t::ConfigParser_t()
0000000000004ad0 T ConfigParser_t::ConfigParser_t(std::string const&)
00000000000024a0 T ConfigParser_t::ConfigParser_t()
0000000000004d20 T ConfigParser_t::getOptions(std::string const&) const
00000000000028d0 T ConfigParser_t::getSections() const
0000000000002ff0 T ConfigParser_t::getValue(std::string, std::string, bool*) const
0000000000002de0 T ConfigParser_t::getValue(std::string, std::string, double*) const
0000000000002bd0 T ConfigParser_t::getValue(std::string, std::string, int*) const
00000000000027d0 T ConfigParser_t::getValue(std::string, std::string, std::string*) const
0000000000003500 T ConfigParser_t::getValue(std::string, std::string, std::vector<std::string, std::allocator<std::string> >*) const
Unlike other similar problems on SO, this is NOT about linking order, as there is only one object file being linked. Anything I'm missing??
But clearly those symbols are there:
Clearly, they're not. Take a closer look and you will see that
there are no matches between the signatures reported by your
linker as undefined and those reported from the library by
nm.
The Standard header <string> defines std::string as typedef for:
std::basic_string<char, std::char_traits<char>, std::allocator<char>>
The GCC implementation of <string>, as of the cxx11 ABI (GCC 4.7.0)
defines std::string as a typedef for:
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>
The std::__cxx11 name space encloses types whose binary implementations are
compliant with the cxx11 ABI.
That type definition means that C++ translation unit that includes the Standard header <string> won't
compile, with GCC >= 4.7, into object code containing a symbol that demangles as std::string.
If a binary - like your libcfgparser.so - contains a symbol that demangles as std::string, then
whatever that symbol might have referred to in the sources from which it was built, it does not refer to std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>,
and cannot be linked with other binaries that were compiled with that definition of std::string.
Your libcfgparser.so is the one installed by libcfgparser0_1.1.2_amd64.deb from the
cfgparser Sourceforce project
(which was last updated three years ago). I guess this from that the fact that I
get your linkage error with same example.cc program linked against the library that is installed by that package.
The explanation for the error is revealed by:
/usr/lib$ strings -a libcfgparser.so | grep "GCC: ("
GCC: (Debian 4.3.2-1.1) 4.3.2
...
which tells us that this library was built with GCC 4.3.2 - pre the cxx11 ABI.
The std::string that appears in your nm output is a pre-cxx11 demangling abbreviation
of std::basic_string<char, std::char_traits<char>, std::allocator<char>>.
This libcfgparser.so is ABI-incompatible with your current GCC, so you
can't link it with programs that you build with that compiler. What you can do is
build libcfgparser from the source package, libcfgparser-1.1.2.tar.bz2,
with your current compiler and then link your programs with the library you have
built yourself.
That works, but not effortlessly. First you'll need to fix the broken
and antiquated autotooling of the source package to create a working ./configure
script.
Which doesn't give a reassuring impression of the proficiency of the package maintainer.
Plus the source code of the package, copyright 2008, is of amateur quality. If
what you are after is a C++ parser for INI-style files, then boost::property_tree::ini_parser would be the
goto solution. See this answer

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>.

Resources