Undefined reference to symbol 'exp##GLIBC_2.2.5' [duplicate] - c++

This question already has answers here:
What is an undefined reference/unresolved external symbol error and how do I fix it?
(39 answers)
Closed 6 years ago.
I am trying to compile Bavieca (for a few weeks now tbh), at the same time becoming accustomed with compiling in Linux, learning about static and dynamic libraries etc, so I'm a little new to this area. Bavieca depends on the BLAS/LAPACK libraries. I am using the atlas respective libraries after unsuccessfully trying the dependent ones.
I can compile successfully the first two parts of the distribution (api & common), but compilation fails in the third (tools).
Makefile:
include ../Makefile.defines
INC = -I./algebra -I./alignment -I./audio -I./base -I./decoding -I./dynamicdecoder -I./estimation -I./config -I./hmm \
-I./io -I./other -I./param -I./text -I./transform -I./wfsadecoder ${INCS_DIR_CBLAS} ${INCS_DIR_LAPACK}
SRC_DIR = ../common
OBJ_DIR = ../../obj/$(ARCH)-$(OS)/common
LIB_DIR = ../../lib/$(ARCH)-$(OS)
OBJFILES_BASE = $(patsubst $(SRC_DIR)/%,$(OBJ_DIR)/%,$(patsubst %.cpp,%.o,$(wildcard $(SRC_DIR)/*/*.cpp)))
static: CPPFLAGS_ = $(CPPFLAGS)
pic: CPPFLAGS_ = $(CPPFLAGS_SHARED)
# targets (pic stands for position independent code)
static: createDirectories libcommon.a
pic: createDirectories libcommon_pic.a
clean:
rm -rf $(OBJ_DIR)
rm -rf $(LIB_DIR)/libcommon.a
rm -rf $(LIB_DIR)/libcommon_pic.a
createDirectories:
(mkdir -p $(LIB_DIR))
(mkdir -p $(OBJ_DIR)/algebra)
(mkdir -p $(OBJ_DIR)/alignment)
(mkdir -p $(OBJ_DIR)/audio)
(mkdir -p $(OBJ_DIR)/base)
(mkdir -p $(OBJ_DIR)/config)
(mkdir -p $(OBJ_DIR)/decoding)
(mkdir -p $(OBJ_DIR)/dynamicdecoder)
(mkdir -p $(OBJ_DIR)/estimation)
(mkdir -p $(OBJ_DIR)/hmm)
(mkdir -p $(OBJ_DIR)/io)
(mkdir -p $(OBJ_DIR)/other)
(mkdir -p $(OBJ_DIR)/param)
(mkdir -p $(OBJ_DIR)/sadmodule)
(mkdir -p $(OBJ_DIR)/text)
(mkdir -p $(OBJ_DIR)/transform)
(mkdir -p $(OBJ_DIR)/vtlestimator)
(mkdir -p $(OBJ_DIR)/wfsabuilder)
(mkdir -p $(OBJ_DIR)/wfsadecoder)
# ----------------------------------------------
# create the static library
#-----------------------------------------------
libcommon.a: $(OBJFILES_BASE)
$(AR) $# $?
(mv libcommon.a $(LIB_DIR))
rm -rf $(OBJ_DIR)
libcommon_pic.a: $(OBJFILES_BASE)
$(AR) $# $?
(mv libcommon_pic.a $(LIB_DIR))
rm -rf $(OBJ_DIR)
# ----------------------------------------------
# create the object files from the source files
# ----------------------------------------------
$(OBJ_DIR)/algebra/%.o: $(SRC_DIR)/algebra/%.cpp
$(XCC) $(CPPFLAGS_) $(INC) -c $< -o $#
$(OBJ_DIR)/alignment/%.o: $(SRC_DIR)/alignment/%.cpp
$(XCC) $(CPPFLAGS_) $(INC) -c $< -o $#
$(OBJ_DIR)/audio/%.o: $(SRC_DIR)/audio/%.cpp
$(XCC) $(CPPFLAGS_) $(INC) -c $< -o $#
$(OBJ_DIR)/base/%.o: $(SRC_DIR)/base/%.cpp
$(XCC) $(CPPFLAGS_) $(INC) -c $< -o $#
$(OBJ_DIR)/config/%.o: $(SRC_DIR)/config/%.cpp
$(XCC) $(CPPFLAGS_) $(INC) -c $< -o $#
$(OBJ_DIR)/decoding/%.o: $(SRC_DIR)/decoding/%.cpp
$(XCC) $(CPPFLAGS_) $(INC) -c $< -o $#
$(OBJ_DIR)/dynamicdecoder/%.o: $(SRC_DIR)/dynamicdecoder/%.cpp
$(XCC) $(CPPFLAGS_) $(INC) -c $< -o $#
$(OBJ_DIR)/estimation/%.o: $(SRC_DIR)/estimation/%.cpp
$(XCC) $(CPPFLAGS_) $(INC) -c $< -o $#
$(OBJ_DIR)/hmm/%.o: $(SRC_DIR)/hmm/%.cpp
$(XCC) $(CPPFLAGS_) $(INC) -c $< -o $#
$(OBJ_DIR)/io/%.o: $(SRC_DIR)/io/%.cpp
$(XCC) $(CPPFLAGS_) $(INC) -c $< -o $#
$(OBJ_DIR)/other/%.o: $(SRC_DIR)/other/%.cpp
$(XCC) $(CPPFLAGS_) $(INC) -c $< -o $#
$(OBJ_DIR)/param/%.o: $(SRC_DIR)/param/%.cpp
$(XCC) $(CPPFLAGS_) $(INC) -c $< -o $#
$(OBJ_DIR)/sadmodule/%.o: $(SRC_DIR)/sadmodule/%.cpp
$(XCC) $(CPPFLAGS_) $(INC) -c $< -o $#
$(OBJ_DIR)/text/%.o: $(SRC_DIR)/text/%.cpp
$(XCC) $(CPPFLAGS_) $(INC) -c $< -o $#
$(OBJ_DIR)/transform/%.o: $(SRC_DIR)/transform/%.cpp
$(XCC) $(CPPFLAGS_) $(INC) -c $< -o $#
$(OBJ_DIR)/vtlestimator/%.o: $(SRC_DIR)/vtlestimator/%.cpp
$(XCC) $(CPPFLAGS_) $(INC) -c $< -o $#
$(OBJ_DIR)/wfsabuilder/%.o: $(SRC_DIR)/wfsabuilder/%.cpp
$(XCC) $(CPPFLAGS_) $(INC) -c $< -o $#
$(OBJ_DIR)/wfsadecoder/%.o: $(SRC_DIR)/wfsadecoder/%.cpp
$(XCC) $(CPPFLAGS_) $(INC) -c $< -o $#
Makefile.defines:
# ---------------------------------------
# Arch and Operating System settings
# ---------------------------------------
MAKE = make --quiet -w
ARCH := $(shell uname -m | sed s/' '//g)
OS := $(shell uname -s)
# ---------------------------------------
# Linux compile options
# ---------------------------------------
XCC = gcc
# SIMD flags (vector based arithmetic operations)
#SIMD_FLAGS =
# SSE is enabled by default on gcc-4.0 and higher. If SSE is enabled, the C preprocessor symbol __SSE__ is defined
SIMD_FLAGS = -msse3
# AVX is available on Sandy Bridge and later Intel and AMD architectures. If AVX is enabled the C preprocessor symbol __AVX__ is defined
#SIMD_FLAGS = -march=corei7-avx
#CPPFLAGS = -g -Wno-deprecated -Wall -O2 -finline-functions $(SIMD_FLAGS)
CPPFLAGS = -g -Wno-deprecated -O2 -finline-functions $(SIMD_FLAGS)
# -fPIC generates Position Independent Code, which is needed to build shared libraries
# so they can be dynamically relocated, however it may slowdown the code, for this reason
# it should be avoided for object files that build executables or static libraries
CPPFLAGS_SHARED = $(CPPFLAGS) -fPIC
AR = ar rs
# ---------------------------------------
# CBLAS and LAPACK includes/libraries
# ---------------------------------------
BASE = /usr
INCS_DIR_CBLAS = -I$(BASE)/include/atlas
INCS_DIR_LAPACK = -I$(BASE)/include/atlas
LIBS_DIR_CBLAS = -L$(BASE)/lib/atlas-base
LIBS_DIR_LAPACK = -L$(BASE)/lib/atlas-base/atlas
LIB_CBLAS = -lcblas -lblas -lgfortran -lf2c
LIB_LAPACK = -llapack
# ----------------------------------------------------
# Java JNI (Java Native Interface) includes/libraries
# ----------------------------------------------------
JAVA_BASE = /usr/lib/jvm/java-1.7.0-openjdk-amd64
INCS_DIR_JNI = -I$(JAVA_BASE)/include -I$(JAVA_BASE)/include/linux
The output is the following:
(mkdir -p ../../obj/x86_64-Linux/tools)
(mkdir -p ../../bin/x86_64-Linux)
gcc -g -Wno-deprecated -O2 -finline-functions -msse3 -L../../lib/x86_64-Linux/ -L/usr/lib/atlas-base -L/usr/lib/atlas-base/atlas -o ../../bin/x86_64-Linux/aligner ../../obj/x86_64-Linux/tools/mainAligner.o -lcommon -llapack -lcblas -lblas -lgfortran -lf2c
/usr/bin/ld: ../../lib/x86_64-Linux//libcommon.a(HMMStateDecoding.o): undefined reference to symbol 'exp##GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libm.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make: *** [aligner] Error 1
Now, I've googled and searched and found out that I need to append -lm to the linker phase. Which I did, resulting in multiple undefined references. This is a small sample of the output in this case:
../../lib/x86_64-Linux//libcommon.a(ConfigurationFeatures.o): In function `ParameterValue':
/home/spgeo/Desktop/bavieca/bavieca-code/src/common/./config/ParameterManager.h:92: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&)'
/home/spgeo/Desktop/bavieca/bavieca-code/src/common/./config/ParameterManager.h:92: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&)'
../../lib/x86_64-Linux//libcommon.a(ConfigurationFeatures.o): In function `std::string::_Rep::_M_dispose(std::allocator<char> const&)':
/usr/include/c++/4.8/bits/basic_string.h:240: undefined reference to `std::string::_Rep::_S_empty_rep_storage'
/usr/include/c++/4.8/bits/basic_string.h:240: undefined reference to `std::string::_Rep::_S_empty_rep_storage'
../../lib/x86_64-Linux//libcommon.a(ConfigurationFeatures.o): In function `std::_Rb_tree_iterator<std::pair<std::string const, std::string> >::operator++()':
/usr/include/c++/4.8/bits/stl_tree.h:189: undefined reference to `std::_Rb_tree_increment(std::_Rb_tree_node_base*)'
../../lib/x86_64-Linux//libcommon.a(ConfigurationFeatures.o): In function `_Alloc_hider':
/usr/include/c++/4.8/bits/basic_string.h:275: undefined reference to `std::string::_Rep::_S_empty_rep_storage'
/usr/include/c++/4.8/bits/basic_string.h:275: undefined reference to `std::string::_Rep::_S_empty_rep_storage'
../../lib/x86_64-Linux//libcommon.a(ConfigurationFeatures.o): In function `std::string::operator=(std::string const&)':
/usr/include/c++/4.8/bits/basic_string.h:547: undefined reference to `std::string::assign(std::string const&)'
/usr/include/c++/4.8/bits/basic_string.h:547: undefined reference to `std::string::assign(std::string const&)'
../../lib/x86_64-Linux//libcommon.a(ConfigurationFeatures.o): In function `std::string::_Rep::_M_dispose(std::allocator<char> const&)':
/usr/include/c++/4.8/bits/basic_string.h:240: undefined reference to `std::string::_Rep::_S_empty_rep_storage'
/usr/include/c++/4.8/bits/basic_string.h:240: undefined reference to `std::string::_Rep::_S_empty_rep_storage'
../../lib/x86_64-Linux//libcommon.a(ConfigurationFeatures.o): In function `__gnu_cxx::new_allocator<Bavieca::ParameterValue>::deallocate(Bavieca::ParameterValue*, unsigned long)':
/usr/include/c++/4.8/ext/new_allocator.h:110: undefined reference to `operator delete(void*)'
../../lib/x86_64-Linux//libcommon.a(ConfigurationFeatures.o): In function `std::string::_Rep::_M_dispose(std::allocator<char> const&)':
/usr/include/c++/4.8/bits/basic_string.h:249: undefined reference to `std::string::_Rep::_M_destroy(std::allocator<char> const&)'
/usr/include/c++/4.8/bits/basic_string.h:249: undefined reference to `std::string::_Rep::_M_destroy(std::allocator<char> const&)'
/usr/include/c++/4.8/bits/basic_string.h:249: undefined reference to `std::string::_Rep::_M_destroy(std::allocator<char> const&)'
/usr/include/c++/4.8/bits/basic_string.h:249: undefined reference to `std::string::_Rep::_M_destroy(std::allocator<char> const&)'
../../lib/x86_64-Linux//libcommon.a(ConfigurationFeatures.o): In function `Bavieca::ConfigurationFeatures::load()':
/home/spgeo/Desktop/bavieca/bavieca-code/src/common/../common/param/ConfigurationFeatures.cpp:110: undefined reference to `__cxa_get_exception_ptr'
../../lib/x86_64-Linux//libcommon.a(ConfigurationFeatures.o): In function `runtime_error':
/usr/include/c++/4.8/stdexcept:112: undefined reference to `vtable for std::runtime_error'
/usr/include/c++/4.8/stdexcept:112: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&)'
../../lib/x86_64-Linux//libcommon.a(ConfigurationFeatures.o): In function `Bavieca::ConfigurationFeatures::load()':
/home/spgeo/Desktop/bavieca/bavieca-code/src/common/../common/param/ConfigurationFeatures.cpp:110: undefined reference to `__cxa_begin_catch'
/home/spgeo/Desktop/bavieca/bavieca-code/src/common/../common/param/ConfigurationFeatures.cpp:111: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/home/spgeo/Desktop/bavieca/bavieca-code/src/common/../common/param/ConfigurationFeatures.cpp:110: undefined reference to `std::runtime_error::~runtime_error()'
/home/spgeo/Desktop/bavieca/bavieca-code/src/common/../common/param/ConfigurationFeatures.cpp:110: undefined reference to `__cxa_end_catch'
/home/spgeo/Desktop/bavieca/bavieca-code/src/common/../common/param/ConfigurationFeatures.cpp:110: undefined reference to `std::runtime_error::~runtime_error()'
/home/spgeo/Desktop/bavieca/bavieca-code/src/common/../common/param/ConfigurationFeatures.cpp:110: undefined reference to `__cxa_end_catch'
../../lib/x86_64-Linux//libcommon.a(ConfigurationFeatures.o): In function `runtime_error':
/usr/include/c++/4.8/stdexcept:112: undefined reference to `std::exception::~exception()'
../../lib/x86_64-Linux//libcommon.a(ConfigurationFeatures.o): In function `Bavieca::ConfigurationFeatures::load()':
/home/spgeo/Desktop/bavieca/bavieca-code/src/common/../common/param/ConfigurationFeatures.cpp:110: undefined reference to `std::terminate()'
../../lib/x86_64-Linux//libcommon.a(ConfigurationFeatures.o): In function `~basic_string':
/usr/include/c++/4.8/bits/basic_string.h:539: undefined reference to `std::string::_Rep::_M_dispose(std::allocator<char> const&)'
../../lib/x86_64-Linux//libcommon.a(ConfigurationFeatures.o):(.gcc_except_table+0xe4): undefined reference to `typeinfo for std::runtime_error'
../../lib/x86_64-Linux//libcommon.a(ConfigurationFeatures.o): In function `__static_initialization_and_destruction_0':
/usr/include/c++/4.8/iostream:74: undefined reference to `std::ios_base::Init::Init()'
/usr/include/c++/4.8/iostream:74: undefined reference to `std::ios_base::Init::~Init()'
../../lib/x86_64-Linux//libcommon.a(ConfigurationFeatures.o):(.eh_frame+0x13): undefined reference to `__gxx_personality_v0'
../../lib/x86_64-Linux//libcommon.a(AudioFile.o): In function `Bavieca::AudioFile::load(char const*, int*)':
/home/spgeo/Desktop/bavieca/bavieca-code/src/common/../common/audio/AudioFile.cpp:48: undefined reference to `operator new[](unsigned long)'
/home/spgeo/Desktop/bavieca/bavieca-code/src/common/../common/audio/AudioFile.cpp:53: undefined reference to `__cxa_get_exception_ptr'
../../lib/x86_64-Linux//libcommon.a(AudioFile.o): In function `runtime_error':
/usr/include/c++/4.8/stdexcept:112: undefined reference to `vtable for std::runtime_error'
/usr/include/c++/4.8/stdexcept:112: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&)'
../../lib/x86_64-Linux//libcommon.a(AudioFile.o): In function `Bavieca::AudioFile::load(char const*, int*)':
/home/spgeo/Desktop/bavieca/bavieca-code/src/common/../common/audio/AudioFile.cpp:53: undefined reference to `__cxa_begin_catch'
/home/spgeo/Desktop/bavieca/bavieca-code/src/common/../common/audio/AudioFile.cpp:54: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/home/spgeo/Desktop/bavieca/bavieca-code/src/common/../common/audio/AudioFile.cpp:54: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/home/spgeo/Desktop/bavieca/bavieca-code/src/common/../common/audio/AudioFile.cpp:53: undefined reference to `std::runtime_error::~runtime_error()'
/home/spgeo/Desktop/bavieca/bavieca-code/src/common/../common/audio/AudioFile.cpp:53: undefined reference to `__cxa_end_catch'
/home/spgeo/Desktop/bavieca/bavieca-code/src/common/../common/audio/AudioFile.cpp:53: undefined reference to `std::runtime_error::~runtime_error()'
/home/spgeo/Desktop/bavieca/bavieca-code/src/common/../common/audio/AudioFile.cpp:53: undefined reference to `__cxa_end_catch'
../../lib/x86_64-Linux//libcommon.a(AudioFile.o): In function `runtime_error':
/usr/include/c++/4.8/stdexcept:112: undefined reference to `std::exception::~exception()'
../../lib/x86_64-Linux//libcommon.a(AudioFile.o): In function `Bavieca::AudioFile::load(char const*, int*)':
/home/spgeo/Desktop/bavieca/bavieca-code/src/common/../common/audio/AudioFile.cpp:53: undefined reference to `std::terminate()'
../../lib/x86_64-Linux//libcommon.a(AudioFile.o):(.gcc_except_table+0x48): undefined reference to `typeinfo for std::runtime_error'
../../lib/x86_64-Linux//libcommon.a(AudioFile.o): In function `__static_initialization_and_destruction_0':
/usr/include/c++/4.8/iostream:74: undefined reference to `std::ios_base::Init::Init()'
/usr/include/c++/4.8/iostream:74: undefined reference to `std::ios_base::Init::~Init()'
../../lib/x86_64-Linux//libcommon.a(AudioFile.o):(.eh_frame+0x53): undefined reference to `__gxx_personality_v0'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `basic_ios':
/usr/include/c++/4.8/bits/basic_ios.h:456: undefined reference to `std::ios_base::ios_base()'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `basic_ostream':
/usr/include/c++/4.8/ostream:385: undefined reference to `VTT for std::basic_ofstream<char, std::char_traits<char> >'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `basic_ios':
/usr/include/c++/4.8/bits/basic_ios.h:456: undefined reference to `vtable for std::basic_ios<char, std::char_traits<char> >'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `basic_ostream':
/usr/include/c++/4.8/ostream:385: undefined reference to `VTT for std::basic_ofstream<char, std::char_traits<char> >'
/usr/include/c++/4.8/ostream:385: undefined reference to `std::basic_ios<char, std::char_traits<char> >::init(std::basic_streambuf<char, std::char_traits<char> >*)'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `basic_ofstream':
/usr/include/c++/4.8/fstream:625: undefined reference to `vtable for std::basic_ofstream<char, std::char_traits<char> >'
/usr/include/c++/4.8/fstream:625: undefined reference to `vtable for std::basic_ofstream<char, std::char_traits<char> >'
/usr/include/c++/4.8/fstream:625: undefined reference to `std::basic_filebuf<char, std::char_traits<char> >::basic_filebuf()'
/usr/include/c++/4.8/fstream:626: undefined reference to `std::basic_ios<char, std::char_traits<char> >::init(std::basic_streambuf<char, std::char_traits<char> >*)'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `_Alloc_hider':
/usr/include/c++/4.8/bits/basic_string.h:275: undefined reference to `std::string::_Rep::_S_empty_rep_storage'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `std::string::assign(char const*)':
/usr/include/c++/4.8/bits/basic_string.h:1131: undefined reference to `std::string::assign(char const*, unsigned long)'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `~basic_ios':
/usr/include/c++/4.8/bits/basic_ios.h:276: undefined reference to `vtable for std::basic_ios<char, std::char_traits<char> >'
/usr/include/c++/4.8/bits/basic_ios.h:276: undefined reference to `std::ios_base::~ios_base()'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `~basic_string':
/usr/include/c++/4.8/bits/basic_string.h:539: undefined reference to `std::string::_Rep::_M_dispose(std::allocator<char> const&)'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `Bavieca::FileOutput::FileOutput(char const*, bool)':
/home/spgeo/Desktop/bavieca/bavieca-code/src/common/../common/io/FileOutput.cpp:26: undefined reference to `std::basic_ofstream<char, std::char_traits<char> >::~basic_ofstream()'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `basic_ofstream':
/usr/include/c++/4.8/fstream:625: undefined reference to `std::basic_filebuf<char, std::char_traits<char> >::~basic_filebuf()'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `~basic_ostream':
/usr/include/c++/4.8/ostream:93: undefined reference to `VTT for std::basic_ofstream<char, std::char_traits<char> >'
/usr/include/c++/4.8/ostream:93: undefined reference to `VTT for std::basic_ofstream<char, std::char_traits<char> >'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `std::string::_Rep::_M_dispose(std::allocator<char> const&)':
/usr/include/c++/4.8/bits/basic_string.h:240: undefined reference to `std::string::_Rep::_S_empty_rep_storage'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `~basic_ofstream':
/usr/include/c++/4.8/fstream:674: undefined reference to `vtable for std::basic_ofstream<char, std::char_traits<char> >'
/usr/include/c++/4.8/fstream:674: undefined reference to `vtable for std::basic_ofstream<char, std::char_traits<char> >'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `~basic_filebuf':
/usr/include/c++/4.8/fstream:220: undefined reference to `vtable for std::basic_filebuf<char, std::char_traits<char> >'
/usr/include/c++/4.8/fstream:220: undefined reference to `std::basic_filebuf<char, std::char_traits<char> >::close()'
/usr/include/c++/4.8/fstream:220: undefined reference to `std::__basic_file<char>::~__basic_file()'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `~basic_streambuf':
/usr/include/c++/4.8/streambuf:198: undefined reference to `vtable for std::basic_streambuf<char, std::char_traits<char> >'
/usr/include/c++/4.8/streambuf:198: undefined reference to `std::locale::~locale()'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `~basic_ostream':
/usr/include/c++/4.8/ostream:93: undefined reference to `VTT for std::basic_ofstream<char, std::char_traits<char> >'
/usr/include/c++/4.8/ostream:93: undefined reference to `VTT for std::basic_ofstream<char, std::char_traits<char> >'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `~basic_ios':
/usr/include/c++/4.8/bits/basic_ios.h:276: undefined reference to `vtable for std::basic_ios<char, std::char_traits<char> >'
/usr/include/c++/4.8/bits/basic_ios.h:276: undefined reference to `std::ios_base::~ios_base()'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `std::string::_Rep::_M_dispose(std::allocator<char> const&)':
/usr/include/c++/4.8/bits/basic_string.h:249: undefined reference to `std::string::_Rep::_M_destroy(std::allocator<char> const&)'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `~basic_streambuf':
/usr/include/c++/4.8/streambuf:198: undefined reference to `vtable for std::basic_streambuf<char, std::char_traits<char> >'
/usr/include/c++/4.8/streambuf:198: undefined reference to `std::locale::~locale()'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `~basic_ostream':
/usr/include/c++/4.8/ostream:93: undefined reference to `VTT for std::basic_ofstream<char, std::char_traits<char> >'
/usr/include/c++/4.8/ostream:93: undefined reference to `VTT for std::basic_ofstream<char, std::char_traits<char> >'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `~basic_ios':
/usr/include/c++/4.8/bits/basic_ios.h:276: undefined reference to `vtable for std::basic_ios<char, std::char_traits<char> >'
/usr/include/c++/4.8/bits/basic_ios.h:276: undefined reference to `std::ios_base::~ios_base()'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `~basic_filebuf':
/usr/include/c++/4.8/fstream:220: undefined reference to `std::__basic_file<char>::~__basic_file()'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `std::basic_ofstream<char, std::char_traits<char> >::open(char const*, std::_Ios_Openmode)':
/usr/include/c++/4.8/fstream:716: undefined reference to `std::basic_filebuf<char, std::char_traits<char> >::open(char const*, std::_Ios_Openmode)'
/usr/include/c++/4.8/fstream:721: undefined reference to `std::basic_ios<char, std::char_traits<char> >::clear(std::_Ios_Iostate)'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `std::basic_filebuf<char, std::char_traits<char> >::is_open() const':
/usr/include/c++/4.8/fstream:228: undefined reference to `std::__basic_file<char>::is_open() const'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `operator<< <std::char_traits<char> >':
/usr/include/c++/4.8/ostream:535: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long)'
/usr/include/c++/4.8/ostream:535: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long)'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `std::basic_ios<char, std::char_traits<char> >::setstate(std::_Ios_Iostate)':
/usr/include/c++/4.8/bits/basic_ios.h:152: undefined reference to `std::basic_ios<char, std::char_traits<char> >::clear(std::_Ios_Iostate)'
/usr/include/c++/4.8/bits/basic_ios.h:152: undefined reference to `std::basic_ios<char, std::char_traits<char> >::clear(std::_Ios_Iostate)'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `std::basic_ofstream<char, std::char_traits<char> >::close()':
/usr/include/c++/4.8/fstream:755: undefined reference to `std::basic_filebuf<char, std::char_traits<char> >::close()'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `std::basic_ios<char, std::char_traits<char> >::setstate(std::_Ios_Iostate)':
/usr/include/c++/4.8/bits/basic_ios.h:152: undefined reference to `std::basic_ios<char, std::char_traits<char> >::clear(std::_Ios_Iostate)'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `__static_initialization_and_destruction_0':
/usr/include/c++/4.8/iostream:74: undefined reference to `std::ios_base::Init::Init()'
/usr/include/c++/4.8/iostream:74: undefined reference to `std::ios_base::Init::~Init()'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o):(.eh_frame+0x13): undefined reference to `__gxx_personality_v0'
collect2: error: ld returned 1 exit status
make: *** [param] Error 1
Now I am in a dead-end. I have no experience or knowledge either as to what to do next. Could it be that libm is not functioning properly? The other answers in similar questions in this site didn't apply to my case.
EDIT:
Changing in Makefile.defined the "gcc" to "g++" results in the following output error: undefined reference to cblas_sgemm(CBLAS_ORDER, CBLAS_TRANSPOSE, CBLAS_TRANSPOSE, int, int, int, float, float const*, int, float const*, int, float, float*, int) collect2: error: ld returned 1 exit status make: *** [param] Error 1
It seems unable to find the cblas library, even though I've linked both the include and lib directory.

This looks like a pretty broken makefile... You are compiling a C++ library (as it needs std::string) with a C compiler (gcc). It can't work. Try replacing gcc by g++ in Makefile.defines, and in any case report your bad experience to the developers of the library.

Related

make file error, should I specify a directory somewhere?

My MakeFile
PC++ = mpicxx
CFLAGS = -O3 -D_MPI
LIBS = -llapack -lblas -lgsl -lgslcblas
CFLAGS = $(PFLAGS) $(Fmpi_define) $(GSLINC) -D_TIME #-DAS -D_TIME #-fast -xAVX # -D_TIME #-D_LOGGING #-DAS
LIBS = $(PLIBS)
GHEADERS = assert.h complex.h random.h sblas.h sfunction.h smesh.h sutil.h zeroin.h
QHEADERS = common.h inout.h intervals.h local.h matrixm.h mpi.h bcast.h number.h operators.h state.h stateim.h segment.h svdfunc.h tanmesh.h
ctqmc : ctqmc.o SMatrix1.o
$(PC++) $(CFLAGS) -o $# ctqmc.o SMatrix1.o $(LIBS)
all : ctqmc ctqmcf
ctqmcf : ctqmcf.o SMatrix1.o
$(PC++) $(CFLAGS) -o $# ctqmcf.o SMatrix1.o $(LIBS)
ctqmcf.o : ctqmc.cc
$(PC++) $(CFLAGS) -DAS -c -o ctqmcf.o $<
SMatrix1.o : SMatrix1.cc sfunction.h
$(PC++) -c $(CFLAGS) SMatrix1.cc
ctqmc.o : ctqmc.cc $(GHEADERS) $(QHEADERS)
$(PC++) $(CFLAGS) -c ctqmc.cc
clean :
rm -f ctqmc.o ctqmcf.o ctqmcf ctqmc SMatrix1.o
.SUFFIXES : .cc
.cc.o:
$(PC++) $(CFLAGS) -c $<
.SUFFIXES : .f
.f.o:
$(F77) $(FFLAGS) -c $<
returns this error when make is launched:
mpicxx -D_TIME -c ctqmc.cc
In file included from ctqmc.cc:41:
intervals.h: In member function ‘const funProxy<dcomplex>& nIntervals::exp_direct(int, int) const’:
intervals.h:58:97: warning: no return statement in function returning non-void [-Wreturn-type]
58 | const funProxy<dcomplex>& exp_direct(int type, int i) const {cerr<<"Should not happen"<<endl; }//return NULL;}
| ^
mpicxx -c -D_TIME SMatrix1.cc
mpicxx -D_TIME -o ctqmc ctqmc.o SMatrix1.o
/usr/bin/ld: ctqmc.o: warning: relocation against `gsl_multiroot_fsolver_hybrids' in read-only section `.text._ZN8FindRootC2EmPFiPK10gsl_vectorPvP
S0_EPdS3_[_ZN8FindRootC5EmPFiPK10gsl_vectorPvPS0_EPdS3_]'
/usr/bin/ld: ctqmc.o: in function `tanmesh_f(gsl_vector const*, void*, gsl_vector*)':
ctqmc.cc:(.text+0x3ed3): undefined reference to `gsl_vector_get'
/usr/bin/ld: ctqmc.cc:(.text+0x3eed): undefined reference to `gsl_vector_get'
/usr/bin/ld: ctqmc.cc:(.text+0x3f31): undefined reference to `gsl_vector_set'
/usr/bin/ld: ctqmc.cc:(.text+0x3fa2): undefined reference to `gsl_vector_set'
/usr/bin/ld: ctqmc.o: in function `xptsv_(int const*, int const*, double*, double*, double*, int const*, int*)':
ctqmc.cc:(.text._Z6xptsv_PKiS0_PdS1_S1_S0_Pi[_Z6xptsv_PKiS0_PdS1_S1_S0_Pi]+0x4d): undefined reference to `dptsv_'
/usr/bin/ld: ctqmc.o: in function `xptsv_(int const*, int const*, double*, dcomplex*, dcomplex*, int const*, int*)':
ctqmc.cc:(.text._Z6xptsv_PKiS0_PdP8dcomplexS3_S0_Pi[_Z6xptsv_PKiS0_PdP8dcomplexS3_S0_Pi]+0x4d): undefined reference to `zptsv_'
/usr/bin/ld: ctqmc.o: in function `xgemm(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::bas
ic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, int, int, double, double const*, int, double const*, int, double, doub
le*, int)':
ctqmc.cc:(.text._Z5xgemmRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES6_iiidPKdiS8_idPdi[_Z5xgemmRKNSt7__cxx1112basic_stringIcSt11char_tr
aitsIcESaIcEEES6_iiidPKdiS8_idPdi]+0x8c): undefined reference to `dgemm_'
/usr/bin/ld: ctqmc.o: in function `xgemm(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::bas
ic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, int, int, dcomplex const&, dcomplex const*, int, dcomplex const*, int,
dcomplex const&, dcomplex*, int)':
ctqmc.cc:(.text._Z5xgemmRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES6_iiiRK8dcomplexPS8_iSA_iS9_PS7_i[_Z5xgemmRKNSt7__cxx1112basic_stri
ngIcSt11char_traitsIcESaIcEEES6_iiiRK8dcomplexPS8_iSA_iS9_PS7_i]+0x80): undefined reference to `zgemm_'
/usr/bin/ld: ctqmc.o: in function `xgetrf(int, double*, int, int*)':
ctqmc.cc:(.text._Z6xgetrfiPdiPi[_Z6xgetrfiPdiPi]+0x52): undefined reference to `dgetrf_'
/usr/bin/ld: ctqmc.o: in function `xgetrf(int, dcomplex*, int, int*)':
ctqmc.cc:(.text._Z6xgetrfiP8dcomplexiPi[_Z6xgetrfiP8dcomplexiPi]+0x52): undefined reference to `zgetrf_'
/usr/bin/ld: ctqmc.o: in function `xgetrs(int, int, double*, int, int*, double*, int)':
ctqmc.cc:(.text._Z6xgetrsiiPdiPiS_i[_Z6xgetrsiiPdiPiS_i]+0x70): undefined reference to `dgetrs_'
/usr/bin/ld: ctqmc.o: in function `xgetrs(int, int, dcomplex*, int, int*, dcomplex*, int)':
ctqmc.cc:(.text._Z6xgetrsiiP8dcomplexiPiS0_i[_Z6xgetrsiiP8dcomplexiPiS0_i]+0x70): undefined reference to `zgetrs_'
/usr/bin/ld: ctqmc.o: in function `xsyev(int, double*, int, double*, double*, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::a
llocator<char> >)':
ctqmc.cc:(.text._Z5xsyeviPdiS_S_iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_Z5xsyeviPdiS_S_iNSt7__cxx1112basic_stringIcSt11char_traitsI
cESaIcEEE]+0x87): undefined reference to `dsyev_'
/usr/bin/ld: ctqmc.o: in function `xgesdd(bool, int, int, double*, int, double*, double*, int, double*, int, double*, int, double*, int*)':
ctqmc.cc:(.text._Z6xgesddbiiPdiS_S_iS_iS_iS_Pi[_Z6xgesddbiiPdiS_S_iS_iS_iS_Pi]+0xfc): undefined reference to `dgesdd_'
/usr/bin/ld: ctqmc.o: in function `xgemv(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, int, double,
double const*, int, double const*, double, double*)':
ctqmc.cc:(.text._Z5xgemvRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiidPKdiS8_dPd[_Z5xgemvRKNSt7__cxx1112basic_stringIcSt11char_traitsIc
ESaIcEEEiidPKdiS8_dPd]+0x12e): undefined reference to `dgemv_'
/usr/bin/ld: ctqmc.o: in function `dger(double*, double, functionb<double> const&, functionb<double> const&)':
ctqmc.cc:(.text._Z4dgerPddRK9functionbIdES3_[_Z4dgerPddRK9functionbIdES3_]+0xa1): undefined reference to `dger_'
/usr/bin/ld: ctqmc.o: in function `RanGSL::RanGSL(int)':
ctqmc.cc:(.text._ZN6RanGSLC2Ei[_ZN6RanGSLC5Ei]+0x14): undefined reference to `gsl_rng_env_setup'
/usr/bin/ld: ctqmc.cc:(.text._ZN6RanGSLC2Ei[_ZN6RanGSLC5Ei]+0x1b): undefined reference to `gsl_rng_ranlux389'
/usr/bin/ld: ctqmc.cc:(.text._ZN6RanGSLC2Ei[_ZN6RanGSLC5Ei]+0x31): undefined reference to `gsl_rng_alloc'
/usr/bin/ld: ctqmc.cc:(.text._ZN6RanGSLC2Ei[_ZN6RanGSLC5Ei]+0x52): undefined reference to `gsl_rng_set'
/usr/bin/ld: ctqmc.o: in function `RanGSL::operator()()':
ctqmc.cc:(.text._ZN6RanGSLclEv[_ZN6RanGSLclEv]+0x1c): undefined reference to `gsl_rng_uniform'
/usr/bin/ld: ctqmc.o: in function `RanGSL::~RanGSL()':
ctqmc.cc:(.text._ZN6RanGSLD2Ev[_ZN6RanGSLD5Ev]+0x1c): undefined reference to `gsl_rng_free'
/usr/bin/ld: ctqmc.o: in function `FindRoot::FindRoot(unsigned long, int (*)(gsl_vector const*, void*, gsl_vector*), double*, void*)':
ctqmc.cc:(.text._ZN8FindRootC2EmPFiPK10gsl_vectorPvPS0_EPdS3_[_ZN8FindRootC5EmPFiPK10gsl_vectorPvPS0_EPdS3_]+0x44): undefined reference to `gsl_ve
ctor_alloc'
/usr/bin/ld: ctqmc.cc:(.text._ZN8FindRootC2EmPFiPK10gsl_vectorPvPS0_EPdS3_[_ZN8FindRootC5EmPFiPK10gsl_vectorPvPS0_EPdS3_]+0xb6): undefined referen
ce to `gsl_vector_set'
/usr/bin/ld: ctqmc.cc:(.text._ZN8FindRootC2EmPFiPK10gsl_vectorPvPS0_EPdS3_[_ZN8FindRootC5EmPFiPK10gsl_vectorPvPS0_EPdS3_]+0xd4): undefined referen
ce to `gsl_multiroot_fsolver_hybrids'
/usr/bin/ld: ctqmc.cc:(.text._ZN8FindRootC2EmPFiPK10gsl_vectorPvPS0_EPdS3_[_ZN8FindRootC5EmPFiPK10gsl_vectorPvPS0_EPdS3_]+0xef): undefined referen
ce to `gsl_multiroot_fsolver_alloc'
/usr/bin/ld: ctqmc.cc:(.text._ZN8FindRootC2EmPFiPK10gsl_vectorPvPS0_EPdS3_[_ZN8FindRootC5EmPFiPK10gsl_vectorPvPS0_EPdS3_]+0x11a): undefined refere
nce to `gsl_multiroot_fsolver_set'
/usr/bin/ld: ctqmc.o: in function `FindRoot::call()':
ctqmc.cc:(.text._ZN8FindRoot4callEv[_ZN8FindRoot4callEv]+0x3d): undefined reference to `gsl_multiroot_fsolver_iterate'
/usr/bin/ld: ctqmc.cc:(.text._ZN8FindRoot4callEv[_ZN8FindRoot4callEv]+0x66): undefined reference to `gsl_multiroot_test_residual'
/usr/bin/ld: ctqmc.cc:(.text._ZN8FindRoot4callEv[_ZN8FindRoot4callEv]+0xd5): undefined reference to `gsl_vector_get'
/usr/bin/ld: ctqmc.o: in function `FindRoot::~FindRoot()':
ctqmc.cc:(.text._ZN8FindRootD2Ev[_ZN8FindRootD5Ev]+0x1c): undefined reference to `gsl_multiroot_fsolver_free'
/usr/bin/ld: ctqmc.cc:(.text._ZN8FindRootD2Ev[_ZN8FindRootD5Ev]+0x2c): undefined reference to `gsl_vector_free'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status
make: *** [Makefile:23: ctqmc] Error 1
I'm not an expert in using make, so I don't understand what I'm doing wrong
halp

building c++ file with gcc throwing error while with g++ not [duplicate]

This question already has answers here:
What is the difference between g++ and gcc?
(10 answers)
Closed last year.
I am exploring vscode. when i am building file with gcc then is is throwing error while with g++ it is successfull.can anyone explain the reason.below is with g++
Starting build...
C:\MinGW\bin\g++.exe -fdiagnostics-color=always -g "C:\Users\Nikhil Kumar\VS Project\DSA_Practice\kadane.cpp" -o "C:\Users\Nikhil Kumar\VS Project\DSA_Practice\kadane.exe"
Build finished successfully...while below is with gcc
Starting build...
C:/MinGW/bin/gcc.exe -fdiagnostics-color=always -g "C:\Users\Nikhil Kumar\VS Project\DSA_Practice\kadane.cpp" -o "C:\Users\Nikhil Kumar\VS Project\DSA_Practice\kadane.exe"
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\NIKHIL~1\AppData\Local\Temp\ccsbjjAr.o: in function main': C:/Users/Nikhil Kumar/VS Project/DSA_Practice/kadane.cpp:6: undefined reference to std::cout'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:/Users/Nikhil Kumar/VS Project/DSA_Practice/kadane.cpp:6: undefined reference to std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)' c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:/Users/Nikhil Kumar/VS Project/DSA_Practice/kadane.cpp:7: undefined reference to std::cin'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:/Users/Nikhil Kumar/VS Project/DSA_Practice/kadane.cpp:7: undefined reference to std::istream::operator>>(int&)' c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:/Users/Nikhil Kumar/VS Project/DSA_Practice/kadane.cpp:9: undefined reference to std::cout'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:/Users/Nikhil Kumar/VS Project/DSA_Practice/kadane.cpp:9: undefined reference to std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)' c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:/Users/Nikhil Kumar/VS Project/DSA_Practice/kadane.cpp:11: undefined reference to std::cin'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:/Users/Nikhil Kumar/VS Project/DSA_Practice/kadane.cpp:11: undefined reference to std::istream::operator>>(int&)' c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:/Users/Nikhil Kumar/VS Project/DSA_Practice/kadane.cpp:22: undefined reference to std::cout'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:/Users/Nikhil Kumar/VS Project/DSA_Practice/kadane.cpp:22: undefined reference to std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)' c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:/Users/Nikhil Kumar/VS Project/DSA_Practice/kadane.cpp:22: undefined reference to std::ostream::operator<<(int)'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:/Users/Nikhil Kumar/VS Project/DSA_Practice/kadane.cpp:22: undefined reference to std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)' c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:/Users/Nikhil Kumar/VS Project/DSA_Practice/kadane.cpp:22: undefined reference to std::ostream::operator<<(std::ostream& (*)(std::ostream&))'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\NIKHIL~1\AppData\Local\Temp\ccsbjjAr.o: in function _tcf_0': c:/mingw/lib/gcc/mingw32/9.2.0/include/c++/iostream:74: undefined reference to std::ios_base::Init::~Init()'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\NIKHIL~1\AppData\Local\Temp\ccsbjjAr.o: in function _static_initialization_and_destruction_0': c:/mingw/lib/gcc/mingw32/9.2.0/include/c++/iostream:74: undefined reference to std::ios_base::Init::Init()'
collect2.exe: error: ld returned 1 exit status
Build finished with error(s).
can anyone explain what's going on?
gcc is not the c compiler, it is "gnu compiler collection". As this, calling gcc with a cpp file will call internally the g++ to compile the file. But as a result you get a *.o file. And now you link all the stuff with the gcc-c-compiler. This is possible at all, but it did not link to the c++stdlib.so/a file. If you link with gcc you need to manually add c++stdlib. But it is highly recommended to use g++ for compile AND link!

Error including dlib library in c++ project

I need to include dlib in a c++ project. I have properly linked the library in my Makefile. Here is the Makefile:
EXE = face_frontalization
OBJ_DIR = bin
CFLAGS = -g -w
# CXXFLAGS = -w -Wall -Wextra -g -std=c++0x
# LDFLAGS = -lSDL2 -lSDL2_image -lSDL2_ttf -lSDL2_mixer -lSDL2_gfx -lm
dummy_build_folder := $(shell mkdir -p $(OBJ_DIR))
# c++ source files of the project
CXXFILES = $(shell find src -type f -name '*.cpp')
CXXOBJ = $(patsubst src/%.cpp,bin/%.o,$(CXXFILES))
INCLUDE = -I/usr/include/dlib-18.18
LIBS = `pkg-config --libs opencv`
CXXFLAGS = `pkg-config --cflags opencv` -w -Wall -Wextra -g -std=c++0x
LDFLAGS = -lcurl
CFLAGS = `pkg-config --cflags opencv` -g -w
MKDIR = mkdir -p
ifdef V
MUTE =
VTAG = -v
else
MUTE = #
endif
###################################################################
# This is a Makefile progress indicator.
# BUILD is initially undefined
ifndef BUILD
# max equals 256 x's
sixteen := x x x x x x x x x x x x x x x x
MAX := $(foreach x,$(sixteen),$(sixteen))
# T estimates how many targets we are building by replacing BUILD with
# a special string
T := $(shell $(MAKE) -nrRf $(firstword $(MAKEFILE_LIST)) $(MAKECMDGOALS) \
BUILD="COUNTTHIS" | grep -c "COUNTTHIS")
# N is the number of pending targets in base 1, well in fact, base x
# :-)
N := $(wordlist 1,$T,$(MAX))
# auto-decrementing counter that returns the number of pending targets
# in base 10
counter = $(words $N)$(eval N := $(wordlist 2,$(words $N),$N))
# BUILD is now defined to show the progress, this also avoids
# redefining T in loop
BUILD = #echo $(counter) of $(T)
endif
###################################################################
# .PHONY: directories all
#
# directories: ${OUT_DIR}
# ${OUT_DIR}:
# ${MKDIR} ${OUT_DIR}
all: $(EXE)
# build successful
$(EXE): $(CXXOBJ)
$(CXX) $(CXXOBJ) -o $(EXE) $(LIBS) $(LDFLAGS)
$(OBJ_DIR)/%.o: src/%.cpp
$(CXX) $(CXXFLAGS) $(INCLUDE) $< -c -o $#
$(BUILD)
$(OBJ_DIR)/%.o: src/%.c
$(CC) $(CFLAGS) $(INCLUDE) $< -c -o $#
run: all
./$(EXE)
clean:
# Cleaning...
-rm -f $(EXE) $(CXXOBJ)
rmdir bin/
I dont know why but its giving errors on compilation. I have compiled the dlib library itself too and the code examples are running as they should.
The error I am getting is:
bin/fatialfeaturedetect.o: In function `fatial_feature_detector()':
/home/playroom/Desktop/face-frontalization/src/fatialfeaturedetect.cpp:20: undefined reference to `dlib::base_window::wait_until_closed() const'
/home/playroom/Desktop/face-frontalization/src/fatialfeaturedetect.cpp:18: undefined reference to `dlib::image_window::~image_window()'
/home/playroom/Desktop/face-frontalization/src/fatialfeaturedetect.cpp:18: undefined reference to `dlib::image_window::~image_window()'
bin/fatialfeaturedetect.o: In function `dlib::get_serialized_frontal_faces()':
/usr/include/dlib-18.18/dlib/image_processing/frontal_face_detector.h:115: undefined reference to `dlib::base64::base64()'
/usr/include/dlib-18.18/dlib/image_processing/frontal_face_detector.h:2358: undefined reference to `dlib::base64::decode(std::istream&, std::ostream&) const'
/usr/include/dlib-18.18/dlib/image_processing/frontal_face_detector.h:2367: undefined reference to `dlib::base64::~base64()'
/usr/include/dlib-18.18/dlib/image_processing/frontal_face_detector.h:2367: undefined reference to `dlib::base64::~base64()'
bin/fatialfeaturedetect.o: In function `dlib_check_consistent_assert_usage':
/usr/include/dlib-18.18/dlib/gui_widgets/../gui_core/../threads/threads_kernel_shared.h:44: undefined reference to `USER_ERROR__missing_dlib_all_source_cpp_file__OR__inconsistent_use_of_DEBUG_or_ENABLE_ASSERTS_preprocessor_directives_'
bin/fatialfeaturedetect.o: In function `dlib::drawable_window::drawable_window(bool, bool)':
/usr/include/dlib-18.18/dlib/gui_widgets/drawable.h:79: undefined reference to `dlib::base_window::base_window(bool, bool)'
/usr/include/dlib-18.18/dlib/gui_widgets/drawable.h:79: undefined reference to `vtable for dlib::drawable_window'
/usr/include/dlib-18.18/dlib/gui_widgets/drawable.h:79: undefined reference to `dlib::base_window::~base_window()'
bin/fatialfeaturedetect.o: In function `dlib::drawable_window::~drawable_window()':
/usr/include/dlib-18.18/dlib/gui_widgets/drawable.h:195: undefined reference to `vtable for dlib::drawable_window'
/usr/include/dlib-18.18/dlib/gui_widgets/drawable.h:195: undefined reference to `dlib::base_window::close_window()'
/usr/include/dlib-18.18/dlib/gui_widgets/drawable.h:195: undefined reference to `dlib::base_window::~base_window()'
bin/fatialfeaturedetect.o: In function `dlib::scrollable_region_style_default::draw_scrollable_region_border(dlib::canvas const&, dlib::rectangle const&, bool) const':
/usr/include/dlib-18.18/dlib/gui_widgets/style.h:527: undefined reference to `dlib::draw_sunken_rectangle(dlib::canvas const&, dlib::rectangle const&, unsigned char)'
bin/fatialfeaturedetect.o: In function `dlib::image_display::disable_overlay_editing()':
/usr/include/dlib-18.18/dlib/gui_widgets/widgets.h:3485: undefined reference to `dlib::base_window::invalidate_rectangle(dlib::rectangle const&)'
bin/fatialfeaturedetect.o: In function `dlib::compress_stream_kernel_1<dlib::entropy_encoder_model_kernel_5<257ul, dlib::entropy_encoder_kernel_2, 200000ul, 4ul>, dlib::entropy_decoder_model_kernel_5<257ul, dlib::entropy_decoder_kernel_2, 200000ul, 4ul>, dlib::crc32>::decompress(std::istream&, std::ostream&) const':
/usr/include/dlib-18.18/dlib/image_processing/../compress_stream/compress_stream_kernel_1.h:180: undefined reference to `dlib::entropy_decoder_kernel_2::entropy_decoder_kernel_2()'
/usr/include/dlib-18.18/dlib/image_processing/../compress_stream/compress_stream_kernel_1.h:181: undefined reference to `dlib::entropy_decoder_kernel_2::set_stream(std::istream&)'
/usr/include/dlib-18.18/dlib/image_processing/../compress_stream/compress_stream_kernel_1.h:196: undefined reference to `dlib::entropy_decoder_kernel_2::get_target(unsigned int)'
/usr/include/dlib-18.18/dlib/image_processing/../compress_stream/compress_stream_kernel_1.h:201: undefined reference to `dlib::entropy_decoder_kernel_2::decode(unsigned int, unsigned int)'
/usr/include/dlib-18.18/dlib/image_processing/../compress_stream/compress_stream_kernel_1.h:243: undefined reference to `dlib::entropy_decoder_kernel_2::~entropy_decoder_kernel_2()'
/usr/include/dlib-18.18/dlib/image_processing/../compress_stream/compress_stream_kernel_1.h:243: undefined reference to `dlib::entropy_decoder_kernel_2::~entropy_decoder_kernel_2()'
bin/fatialfeaturedetect.o: In function `void dlib::image_window::add_overlay<dlib::rgb_pixel>(std::vector<dlib::rectangle, std::allocator<dlib::rectangle> > const&, dlib::rgb_pixel)':
/usr/include/dlib-18.18/dlib/gui_widgets/widgets.h:3968: undefined reference to `dlib::image_window::add_overlay(std::vector<dlib::image_display::overlay_rect, std::allocator<dlib::image_display::overlay_rect> > const&)'
bin/fatialfeaturedetect.o: In function `dlib::image_window::image_window<dlib::array2d<dlib::rgb_pixel, dlib::memory_manager_stateless_kernel_1<char> > >(dlib::array2d<dlib::rgb_pixel, dlib::memory_manager_stateless_kernel_1<char> > const&)':
/usr/include/dlib-18.18/dlib/gui_widgets/widgets.h:3883: undefined reference to `vtable for dlib::image_window'
/usr/include/dlib-18.18/dlib/gui_widgets/widgets.h:3883: undefined reference to `dlib::image_display::image_display(dlib::drawable_window&)'
/usr/include/dlib-18.18/dlib/gui_widgets/widgets.h:3885: undefined reference to `dlib::image_window::on_image_clicked(dlib::vector<long, 2l> const&, bool, unsigned long)'
/usr/include/dlib-18.18/dlib/gui_widgets/widgets.h:3888: undefined reference to `dlib::base_window::show()'
/usr/include/dlib-18.18/dlib/gui_widgets/widgets.h:3883: undefined reference to `dlib::image_display::~image_display()'
bin/fatialfeaturedetect.o: In function `dlib::entropy_decoder_model_kernel_5<257ul, dlib::entropy_decoder_kernel_2, 200000ul, 4ul>::decode(unsigned long&)':
/usr/include/dlib-18.18/dlib/image_processing/../entropy_decoder_model/entropy_decoder_model_kernel_5.h:422: undefined reference to `dlib::entropy_decoder_kernel_2::get_target(unsigned int)'
/usr/include/dlib-18.18/dlib/image_processing/../entropy_decoder_model/entropy_decoder_model_kernel_5.h:456: undefined reference to `dlib::entropy_decoder_kernel_2::decode(unsigned int, unsigned int)'
/usr/include/dlib-18.18/dlib/image_processing/../entropy_decoder_model/entropy_decoder_model_kernel_5.h:503: undefined reference to `dlib::entropy_decoder_kernel_2::decode(unsigned int, unsigned int)'
/usr/include/dlib-18.18/dlib/image_processing/../entropy_decoder_model/entropy_decoder_model_kernel_5.h:551: undefined reference to `dlib::entropy_decoder_kernel_2::get_target(unsigned int)'
/usr/include/dlib-18.18/dlib/image_processing/../entropy_decoder_model/entropy_decoder_model_kernel_5.h:553: undefined reference to `dlib::entropy_decoder_kernel_2::decode(unsigned int, unsigned int)'
bin/fatialfeaturedetect.o: In function `void dlib::image_window::set_image<dlib::array2d<dlib::rgb_pixel, dlib::memory_manager_stateless_kernel_1<char> > >(dlib::array2d<dlib::rgb_pixel, dlib::memory_manager_stateless_kernel_1<char> > const&)':
/usr/include/dlib-18.18/dlib/gui_widgets/widgets.h:3930: undefined reference to `dlib::image_display::get_image_display_rect() const'
/usr/include/dlib-18.18/dlib/gui_widgets/widgets.h:3934: undefined reference to `dlib::base_window::set_size(int, int)'
bin/fatialfeaturedetect.o: In function `void dlib::load_dng<dlib::array2d<dlib::rgb_pixel, dlib::memory_manager_stateless_kernel_1<char> > >(dlib::array2d<dlib::rgb_pixel, dlib::memory_manager_stateless_kernel_1<char> >&, std::istream&)':
/usr/include/dlib-18.18/dlib/image_loader/image_loader.h:585: undefined reference to `dlib::entropy_decoder_kernel_2::entropy_decoder_kernel_2()'
/usr/include/dlib-18.18/dlib/image_loader/image_loader.h:586: undefined reference to `dlib::entropy_decoder_kernel_2::set_stream(std::istream&)'
/usr/include/dlib-18.18/dlib/image_loader/image_loader.h:757: undefined reference to `dlib::entropy_decoder_kernel_2::~entropy_decoder_kernel_2()'
/usr/include/dlib-18.18/dlib/image_loader/image_loader.h:771: undefined reference to `dlib::entropy_decoder_kernel_2::entropy_decoder_kernel_2()'
/usr/include/dlib-18.18/dlib/image_loader/image_loader.h:772: undefined reference to `dlib::entropy_decoder_kernel_2::set_stream(std::istream&)'
/usr/include/dlib-18.18/dlib/image_loader/image_loader.h:771: undefined reference to `dlib::entropy_decoder_kernel_2::~entropy_decoder_kernel_2()'
/usr/include/dlib-18.18/dlib/image_loader/image_loader.h:757: undefined reference to `dlib::entropy_decoder_kernel_2::~entropy_decoder_kernel_2()'
/usr/include/dlib-18.18/dlib/image_loader/image_loader.h:771: undefined reference to `dlib::entropy_decoder_kernel_2::~entropy_decoder_kernel_2()'
bin/fatialfeaturedetect.o: In function `void dlib::image_display::set_image<dlib::array2d<dlib::rgb_pixel, dlib::memory_manager_stateless_kernel_1<char> > >(dlib::array2d<dlib::rgb_pixel, dlib::memory_manager_stateless_kernel_1<char> > const&)':
/usr/include/dlib-18.18/dlib/gui_widgets/widgets.h:3272: undefined reference to `dlib::scrollable_region::set_total_rect_size(unsigned long, unsigned long)'
/usr/include/dlib-18.18/dlib/gui_widgets/widgets.h:3274: undefined reference to `dlib::scrollable_region::set_total_rect_size(unsigned long, unsigned long)'
/usr/include/dlib-18.18/dlib/gui_widgets/widgets.h:3278: undefined reference to `dlib::base_window::invalidate_rectangle(dlib::rectangle const&)'
/usr/include/dlib-18.18/dlib/gui_widgets/widgets.h:3283: undefined reference to `dlib::popup_menu_region::disable()'
bin/fatialfeaturedetect.o: In function `dlib::entropy_decoder_model_kernel_5<256ul, dlib::entropy_decoder_kernel_2, 200000ul, 4ul>::decode(unsigned long&)':
/usr/include/dlib-18.18/dlib/image_processing/../entropy_decoder_model/entropy_decoder_model_kernel_5.h:422: undefined reference to `dlib::entropy_decoder_kernel_2::get_target(unsigned int)'
/usr/include/dlib-18.18/dlib/image_processing/../entropy_decoder_model/entropy_decoder_model_kernel_5.h:456: undefined reference to `dlib::entropy_decoder_kernel_2::decode(unsigned int, unsigned int)'
/usr/include/dlib-18.18/dlib/image_processing/../entropy_decoder_model/entropy_decoder_model_kernel_5.h:503: undefined reference to `dlib::entropy_decoder_kernel_2::decode(unsigned int, unsigned int)'
/usr/include/dlib-18.18/dlib/image_processing/../entropy_decoder_model/entropy_decoder_model_kernel_5.h:551: undefined reference to `dlib::entropy_decoder_kernel_2::get_target(unsigned int)'
/usr/include/dlib-18.18/dlib/image_processing/../entropy_decoder_model/entropy_decoder_model_kernel_5.h:553: undefined reference to `dlib::entropy_decoder_kernel_2::decode(unsigned int, unsigned int)'
bin/fatialfeaturedetect.o: In function `dlib::entropy_decoder_model_kernel_4<256ul, dlib::entropy_decoder_kernel_2, 200000ul, 4ul>::decode(unsigned long&)':
/usr/include/dlib-18.18/dlib/image_processing/../entropy_decoder_model/entropy_decoder_model_kernel_4.h:348: undefined reference to `dlib::entropy_decoder_kernel_2::get_target(unsigned int)'
/usr/include/dlib-18.18/dlib/image_processing/../entropy_decoder_model/entropy_decoder_model_kernel_4.h:376: undefined reference to `dlib::entropy_decoder_kernel_2::decode(unsigned int, unsigned int)'
/usr/include/dlib-18.18/dlib/image_processing/../entropy_decoder_model/entropy_decoder_model_kernel_4.h:422: undefined reference to `dlib::entropy_decoder_kernel_2::decode(unsigned int, unsigned int)'
/usr/include/dlib-18.18/dlib/image_processing/../entropy_decoder_model/entropy_decoder_model_kernel_4.h:469: undefined reference to `dlib::entropy_decoder_kernel_2::get_target(unsigned int)'
/usr/include/dlib-18.18/dlib/image_processing/../entropy_decoder_model/entropy_decoder_model_kernel_4.h:471: undefined reference to `dlib::entropy_decoder_kernel_2::decode(unsigned int, unsigned int)'
collect2: error: ld returned 1 exit status
make: *** [face_frontalization] Error 1
I cant figure out what I have done in linking the library to the project. Please help.
Dlib is partially header-based and some functions need to have libdlib.a linked to a project
You have two ways how to solve your problem:
link to dlib: LDFLAGS = -ldlib (dlib should be installed or its path provided to linker)
add dlib/all/source.cpp to your project sources list(CXXFILES)
If this error is present during compilation with dLib:
/usr/bin/ld: /tmp/ccps6CPH.o: undefined reference to symbol 'pthread_create##GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status make: *** [face_frontalization] Error 1
There is a good probability that X11 is missing. I dont know what it is so if somebody does, please tell me. Solution is to just add -lX11 to the LDFLAGS in order to link with it. If you dont want it, you can also specify compiler option -DDLIB_NO_GUI_SUPPORT.
(NOTE: I haven't tested it and dont know what X11 does so better include it than exclude it.)

Error when linking with libmongoclient in c++

When I start compiling the code with clang, it seems like libmongoclient doesn't exist. However, I compile the legacy version of mongo-cxx-client on this ubuntu machine. This code is working correctly on my Mac.
clang -lstdc++ -stdlib=libc++ -lcurl -lpthread -ljsoncpp -lboost_system -lboost_regex -lmongoclient -L/usr/lib main.o qqlogin.o fetcher.o -o qq_crawler
this is the code for linking. It didn't make any difference with or without the parameter -lmongoclient. I have already make sure it is under the correct path and the compile are able to search it.
main.o: In function `main':
main.cpp:(.text+0x3b): undefined reference to `mongo::client::Options::Options()'
main.cpp:(.text+0x4b): undefined reference to `mongo::client::GlobalInstance::GlobalInstance(mongo::client::Options const&)'
main.cpp:(.text+0x2d4): undefined reference to `mongo::client::GlobalInstance::~GlobalInstance()'
main.cpp:(.text+0x310): undefined reference to `mongo::client::GlobalInstance::~GlobalInstance()'
main.o: In function `thread_main(threadtool::Threadsafe_queue<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >*)':
main.cpp:(.text+0x343): undefined reference to `mongo::DBClientConnection::DBClientConnection(bool, mongo::DBClientReplicaSet*, double)'
main.o: In function `GCC_except_table14':
main.cpp:(.gcc_except_table+0x258): undefined reference to `typeinfo for mongo::DBException'
main.o: In function `mongo::DBClientConnection::connect(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)':
main.cpp:(.text._ZN5mongo18DBClientConnection7connectERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE[_ZN5mongo18DBClientConnection7connectERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE]+0x116): undefined reference to `mongo::HostAndPort::HostAndPort(mongo::StringData const&)'
main.o: In function `mongo::DBClientConnection::~DBClientConnection()':
main.cpp:(.text._ZN5mongo18DBClientConnectionD2Ev[_ZN5mongo18DBClientConnectionD2Ev]+0x12): undefined reference to `vtable for mongo::DBClientConnection'
main.cpp:(.text._ZN5mongo18DBClientConnectionD2Ev[_ZN5mongo18DBClientConnectionD2Ev]+0x1d): undefined reference to `vtable for mongo::DBClientConnection'
main.cpp:(.text._ZN5mongo18DBClientConnectionD2Ev[_ZN5mongo18DBClientConnectionD2Ev]+0x22): undefined reference to `mongo::DBClientConnection::_numConnections'
main.cpp:(.text._ZN5mongo18DBClientConnectionD2Ev[_ZN5mongo18DBClientConnectionD2Ev]+0xc4): undefined reference to `mongo::DBClientBase::~DBClientBase()'
main.cpp:(.text._ZN5mongo18DBClientConnectionD2Ev[_ZN5mongo18DBClientConnectionD2Ev]+0x15d): undefined reference to `mongo::DBClientBase::~DBClientBase()'
main.o: In function `mongo::DBException::~DBException()':
main.cpp:(.text._ZN5mongo11DBExceptionD2Ev[_ZN5mongo11DBExceptionD2Ev]+0xc): undefined reference to `vtable for mongo::DBException'
main.o: In function `mongo::UserException::UserException(int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)':
main.cpp:(.text._ZN5mongo13UserExceptionC2EiRKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE[_ZN5mongo13UserExceptionC2EiRKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE]+0x30): undefined reference to `vtable for mongo::UserException'
main.o: In function `mongo::DBException::addContext(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)':
main.cpp:(.text._ZN5mongo11DBException10addContextERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE[_ZN5mongo11DBException10addContextERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE]+0x51): undefined reference to `mongo::causedBy(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)'
main.o: In function `mongo::DBException::DBException(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int)':
main.cpp:(.text._ZN5mongo11DBExceptionC2ERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEi[_ZN5mongo11DBExceptionC2ERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEi]+0xf): undefined reference to `vtable for mongo::DBException'
main.o:(.rodata._ZTIN5mongo16ConnectExceptionE[_ZTIN5mongo16ConnectExceptionE]+0x10): undefined reference to `typeinfo for mongo::UserException'
main.o:(.rodata._ZTVN5mongo16ConnectExceptionE[_ZTVN5mongo16ConnectExceptionE]+0x30): undefined reference to `mongo::UserException::appendPrefix(std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) const'
main.o:(.rodata._ZTVN5mongo16ConnectExceptionE[_ZTVN5mongo16ConnectExceptionE]+0x40): undefined reference to `mongo::DBException::toString() const'
main.o:(.rodata._ZTVN5mongo18AssertionExceptionE[_ZTVN5mongo18AssertionExceptionE]+0x40): undefined reference to `mongo::DBException::toString() const'
main.o:(.rodata._ZTIN5mongo18AssertionExceptionE[_ZTIN5mongo18AssertionExceptionE]+0x10): undefined reference to `typeinfo for mongo::DBException'
fetcher.o: In function `fetch::Fetcher::parsed_json(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&)':
fetcher.cpp:(.text+0x1e8c): undefined reference to `Json::Reader::parse(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, Json::Value&, bool)'
fetcher.o: In function `mongo::BSONObjBuilder::BSONObjBuilder(int)':
fetcher.cpp:(.text._ZN5mongo14BSONObjBuilderC2Ei[_ZN5mongo14BSONObjBuilderC2Ei]+0x4e): undefined reference to `mongo::BSONObjBuilderValueStream::BSONObjBuilderValueStream(mongo::BSONObjBuilder*)'
fetcher.o: In function `mongo::BSONObjBuilder::append(mongo::StringData const&, mongo::Date_t)':
fetcher.cpp:(.text._ZN5mongo14BSONObjBuilder6appendERKNS_10StringDataENS_6Date_tE[_ZN5mongo14BSONObjBuilder6appendERKNS_10StringDataENS_6Date_tE]+0x29): undefined reference to `mongo::BSONObjBuilder::appendDate(mongo::StringData const&, mongo::Date_t)'
fetcher.o: In function `mongo::BSONObjBuilder::obj()':
fetcher.cpp:(.text._ZN5mongo14BSONObjBuilder3objEv[_ZN5mongo14BSONObjBuilder3objEv]+0x4c): undefined reference to `mongo::msgasserted(int, char const*)'
fetcher.o: In function `mongo::BSONObjBuilder::_done()':
fetcher.cpp:(.text._ZN5mongo14BSONObjBuilder5_doneEv[_ZN5mongo14BSONObjBuilder5_doneEv]+0x62): undefined reference to `mongo::BSONObjBuilderValueStream::endField(mongo::StringData const&)'
fetcher.o: In function `mongo::_BufBuilder<mongo::TrivialAllocator>::claimReservedBytes(int)':
fetcher.cpp:(.text._ZN5mongo11_BufBuilderINS_16TrivialAllocatorEE18claimReservedBytesEi[_ZN5mongo11_BufBuilderINS_16TrivialAllocatorEE18claimReservedBytesEi]+0x52): undefined reference to `mongo::invariantFailed(char const*, char const*, unsigned int)'
fetcher.o: In function `mongo::_BufBuilder<mongo::TrivialAllocator>::grow_reallocate(int)':
fetcher.cpp:(.text._ZN5mongo11_BufBuilderINS_16TrivialAllocatorEE15grow_reallocateEi[_ZN5mongo11_BufBuilderINS_16TrivialAllocatorEE15grow_reallocateEi]+0x663): undefined reference to `mongo::msgasserted(int, char const*)'
fetcher.cpp:(.text._ZN5mongo11_BufBuilderINS_16TrivialAllocatorEE15grow_reallocateEi[_ZN5mongo11_BufBuilderINS_16TrivialAllocatorEE15grow_reallocateEi]+0x6ed): undefined reference to `mongo::msgasserted(int, char const*)'
fetcher.o: In function `mongo::checkFieldName(mongo::StringData)':
fetcher.cpp:(.text._ZN5mongo14checkFieldNameENS_10StringDataE[_ZN5mongo14checkFieldNameENS_10StringDataE]+0x56): undefined reference to `mongo::uasserted(int, char const*)'
fetcher.o: In function `mongo::_BufBuilder<mongo::TrivialAllocator>::_BufBuilder(int)':
fetcher.cpp:(.text._ZN5mongo11_BufBuilderINS_16TrivialAllocatorEEC2Ei[_ZN5mongo11_BufBuilderINS_16TrivialAllocatorEEC2Ei]+0x5e): undefined reference to `mongo::msgasserted(int, char const*)'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [qq_crawler] Error 1
Put your object files before the libraries:
clang -stdlib=libc++ main.o qqlogin.o fetcher.o -L/usr/lib -lcurl -lpthread
-ljsoncpp -lboost_system -lboost_regex -lmongoclient -o qq_crawler

Boost Serialization compile error

I am using netbeans to develop a simple c++ program that uses boost serialization.
However when i try to compile the program i get a bunch of exceptions and errors:
CLEAN SUCCESSFUL (total time: 203ms)
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `/home/bernd/NetBeansProjects/LVAManager'
"/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux-x86/lvamanager
make[2]: Entering directory `/home/bernd/NetBeansProjects/LVAManager'
mkdir -p build/Debug/GNU-Linux-x86
rm -f build/Debug/GNU-Linux-x86/LVA.o.d
g++ -c -g -I/usr/include/boost -MMD -MP -MF build/Debug/GNU-Linux-x86/LVA.o.d -o build/Debug/GNU-Linux-x86/LVA.o LVA.cpp
mkdir -p build/Debug/GNU-Linux-x86
rm -f build/Debug/GNU-Linux-x86/Manager.o.d
g++ -c -g -I/usr/include/boost -MMD -MP -MF build/Debug/GNU-Linux-x86/Manager.o.d -o build/Debug/GNU-Linux-x86/Manager.o Manager.cpp
mkdir -p build/Debug/GNU-Linux-x86
rm -f build/Debug/GNU-Linux-x86/main.o.d
g++ -c -g -I/usr/include/boost -MMD -MP -MF build/Debug/GNU-Linux-x86/main.o.d -o build/Debug/GNU-Linux-x86/main.o main.cpp
mkdir -p dist/Debug/GNU-Linux-x86
g++ -o dist/Debug/GNU-Linux-x86/lvamanager build/Debug/GNU-Linux-x86/LVA.o build/Debug/GNU-Linux-x86/Manager.o build/Debug/GNU-Linux-x86/main.o
build/Debug/GNU-Linux-x86/main.o: In function `boost::archive::text_oarchive::text_oarchive(std::ostream&, unsigned int)':
/usr/include/boost/archive/text_oarchive.hpp:100: undefined reference to `boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::text_oarchive_impl(std::ostream&, unsigned int)'
build/Debug/GNU-Linux-x86/main.o: In function `boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::~text_oarchive_impl()':
/usr/include/boost/archive/text_oarchive.hpp:85: undefined reference to `boost::archive::basic_text_oprimitive<std::ostream>::~basic_text_oprimitive()'
/usr/include/boost/archive/text_oarchive.hpp:85: undefined reference to `boost::archive::basic_text_oprimitive<std::ostream>::~basic_text_oprimitive()'
build/Debug/GNU-Linux-x86/main.o: In function `boost::archive::detail::common_oarchive<boost::archive::text_oarchive>::~common_oarchive()':
/usr/include/boost/archive/detail/common_oarchive.hpp:35: undefined reference to `boost::archive::detail::basic_oarchive::~basic_oarchive()'
build/Debug/GNU-Linux-x86/main.o:(.rodata._ZTIN5boost7archive6detail15common_oarchiveINS0_13text_oarchiveEEE[_ZTIN5boost7archive6detail15common_oarchiveINS0_13text_oarchiveEEE]+0x18): undefined reference to `typeinfo for boost::archive::detail::basic_oarchive'
build/Debug/GNU-Linux-x86/main.o: In function `void boost::archive::save_access::save_primitive<boost::archive::text_oarchive, boost::archive::version_type>(boost::archive::text_oarchive&, boost::archive::version_type const&)':
/usr/include/boost/archive/detail/oserializer.hpp:87: undefined reference to `boost::archive::detail::basic_oarchive::end_preamble()'
build/Debug/GNU-Linux-x86/main.o: In function `void boost::archive::save_access::save_primitive<boost::archive::text_oarchive, boost::archive::object_id_type>(boost::archive::text_oarchive&, boost::archive::object_id_type const&)':
/usr/include/boost/archive/detail/oserializer.hpp:87: undefined reference to `boost::archive::detail::basic_oarchive::end_preamble()'
build/Debug/GNU-Linux-x86/main.o: In function `void boost::archive::save_access::save_primitive<boost::archive::text_oarchive, boost::archive::object_reference_type>(boost::archive::text_oarchive&, boost::archive::object_reference_type const&)':
/usr/include/boost/archive/detail/oserializer.hpp:87: undefined reference to `boost::archive::detail::basic_oarchive::end_preamble()'
build/Debug/GNU-Linux-x86/main.o: In function `void boost::archive::save_access::save_primitive<boost::archive::text_oarchive, boost::archive::class_id_type>(boost::archive::text_oarchive&, boost::archive::class_id_type const&)':
/usr/include/boost/archive/detail/oserializer.hpp:87: undefined reference to `boost::archive::detail::basic_oarchive::end_preamble()'
build/Debug/GNU-Linux-x86/main.o: In function `void boost::archive::save_access::save_primitive<boost::archive::text_oarchive, boost::archive::class_id_reference_type>(boost::archive::text_oarchive&, boost::archive::class_id_reference_type const&)':
/usr/include/boost/archive/detail/oserializer.hpp:87: undefined reference to `boost::archive::detail::basic_oarchive::end_preamble()'
build/Debug/GNU-Linux-x86/main.o:/usr/include/boost/archive/detail/oserializer.hpp:87: more undefined references to `boost::archive::detail::basic_oarchive::end_preamble()' follow
build/Debug/GNU-Linux-x86/main.o: In function `void boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::save<boost::archive::object_id_type>(boost::archive::object_id_type const&)':
/usr/include/boost/archive/text_oarchive.hpp:60: undefined reference to `boost::archive::basic_text_oarchive<boost::archive::text_oarchive>::newtoken()'
build/Debug/GNU-Linux-x86/main.o: In function `void boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::save<boost::archive::object_reference_type>(boost::archive::object_reference_type const&)':
/usr/include/boost/archive/text_oarchive.hpp:60: undefined reference to `boost::archive::basic_text_oarchive<boost::archive::text_oarchive>::newtoken()'
build/Debug/GNU-Linux-x86/main.o: In function `void boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::save<boost::archive::class_id_type>(boost::archive::class_id_type const&)':
/usr/include/boost/archive/text_oarchive.hpp:60: undefined reference to `boost::archive::basic_text_oarchive<boost::archive::text_oarchive>::newtoken()'
build/Debug/GNU-Linux-x86/main.o: In function `void boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::save<boost::archive::class_id_reference_type>(boost::archive::class_id_reference_type const&)':
/usr/include/boost/archive/text_oarchive.hpp:60: undefined reference to `boost::archive::basic_text_oarchive<boost::archive::text_oarchive>::newtoken()'
build/Debug/GNU-Linux-x86/main.o: In function `void boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::save<boost::archive::tracking_type>(boost::archive::tracking_type const&)':
/usr/include/boost/archive/text_oarchive.hpp:60: undefined reference to `boost::archive::basic_text_oarchive<boost::archive::text_oarchive>::newtoken()'
build/Debug/GNU-Linux-x86/main.o:/usr/include/boost/archive/text_oarchive.hpp:60: more undefined references to `boost::archive::basic_text_oarchive<boost::archive::text_oarchive>::newtoken()' follow
build/Debug/GNU-Linux-x86/main.o: In function `void boost::archive::basic_text_oprimitive<std::ostream>::save<boost::archive::object_id_type>(boost::archive::object_id_type const&)':
/usr/include/boost/archive/basic_text_oprimitive.hpp:91: undefined reference to `boost::archive::archive_exception::archive_exception(boost::archive::archive_exception::exception_code, char const*, char const*)'
/usr/include/boost/archive/basic_text_oprimitive.hpp:91: undefined reference to `boost::archive::archive_exception::~archive_exception()'
/usr/include/boost/archive/basic_text_oprimitive.hpp:91: undefined reference to `boost::archive::archive_exception::~archive_exception()'
build/Debug/GNU-Linux-x86/main.o: In function `void boost::archive::basic_text_oprimitive<std::ostream>::save<boost::archive::object_reference_type>(boost::archive::object_reference_type const&)':
/usr/include/boost/archive/basic_text_oprimitive.hpp:91: undefined reference to `boost::archive::archive_exception::archive_exception(boost::archive::archive_exception::exception_code, char const*, char const*)'
/usr/include/boost/archive/basic_text_oprimitive.hpp:91: undefined reference to `boost::archive::archive_exception::~archive_exception()'
/usr/include/boost/archive/basic_text_oprimitive.hpp:91: undefined reference to `boost::archive::archive_exception::~archive_exception()'
build/Debug/GNU-Linux-x86/main.o: In function `void boost::archive::basic_text_oprimitive<std::ostream>::save<boost::archive::class_id_type>(boost::archive::class_id_type const&)':
/usr/include/boost/archive/basic_text_oprimitive.hpp:91: undefined reference to `boost::archive::archive_exception::archive_exception(boost::archive::archive_exception::exception_code, char const*, char const*)'
/usr/include/boost/archive/basic_text_oprimitive.hpp:91: undefined reference to `boost::archive::archive_exception::~archive_exception()'
/usr/include/boost/archive/basic_text_oprimitive.hpp:91: undefined reference to `boost::archive::archive_exception::~archive_exception()'
build/Debug/GNU-Linux-x86/main.o: In function `void boost::archive::basic_text_oprimitive<std::ostream>::save<boost::archive::class_id_reference_type>(boost::archive::class_id_reference_type const&)':
/usr/include/boost/archive/basic_text_oprimitive.hpp:91: undefined reference to `boost::archive::archive_exception::archive_exception(boost::archive::archive_exception::exception_code, char const*, char const*)'
/usr/include/boost/archive/basic_text_oprimitive.hpp:91: undefined reference to `boost::archive::archive_exception::~archive_exception()'
/usr/include/boost/archive/basic_text_oprimitive.hpp:91: undefined reference to `boost::archive::archive_exception::~archive_exception()'
build/Debug/GNU-Linux-x86/main.o: In function `void boost::archive::save_access::save_primitive<boost::archive::text_oarchive, std::string>(boost::archive::text_oarchive&, std::string const&)':
/usr/include/boost/archive/detail/oserializer.hpp:87: undefined reference to `boost::archive::detail::basic_oarchive::end_preamble()'
/usr/include/boost/archive/detail/oserializer.hpp:88: undefined reference to `boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::save(std::string const&)'
build/Debug/GNU-Linux-x86/main.o: In function `void boost::archive::basic_text_oprimitive<std::ostream>::save<boost::archive::tracking_type>(boost::archive::tracking_type const&)':
/usr/include/boost/archive/basic_text_oprimitive.hpp:91: undefined reference to `boost::archive::archive_exception::archive_exception(boost::archive::archive_exception::exception_code, char const*, char const*)'
/usr/include/boost/archive/basic_text_oprimitive.hpp:91: undefined reference to `boost::archive::archive_exception::~archive_exception()'
/usr/include/boost/archive/basic_text_oprimitive.hpp:91: undefined reference to `boost::archive::archive_exception::~archive_exception()'
build/Debug/GNU-Linux-x86/main.o: In function `void boost::archive::basic_text_oprimitive<std::ostream>::save<unsigned int>(unsigned int const&)':
/usr/include/boost/archive/basic_text_oprimitive.hpp:91: undefined reference to `boost::archive::archive_exception::archive_exception(boost::archive::archive_exception::exception_code, char const*, char const*)'
/usr/include/boost/archive/basic_text_oprimitive.hpp:91: undefined reference to `boost::archive::archive_exception::~archive_exception()'
/usr/include/boost/archive/basic_text_oprimitive.hpp:91: undefined reference to `boost::archive::archive_exception::~archive_exception()'
build/Debug/GNU-Linux-x86/main.o: In function `boost::archive::archive_exception::archive_exception(boost::archive::archive_exception const&)':
/usr/include/boost/archive/archive_exception.hpp:43: undefined reference to `vtable for boost::archive::archive_exception'
/usr/include/boost/archive/archive_exception.hpp:43: undefined reference to `vtable for boost::archive::archive_exception'
build/Debug/GNU-Linux-x86/main.o: In function `void boost::serialization::throw_exception<boost::archive::archive_exception>(boost::archive::archive_exception const&)':
/usr/include/boost/serialization/throw_exception.hpp:36: undefined reference to `boost::archive::archive_exception::~archive_exception()'
/usr/include/boost/serialization/throw_exception.hpp:36: undefined reference to `typeinfo for boost::archive::archive_exception'
collect2: error: ld returned 1 exit status
make[2]: *** [dist/Debug/GNU-Linux-x86/lvamanager] Error 1
make[2]: Leaving directory `/home/bernd/NetBeansProjects/LVAManager'
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory `/home/bernd/NetBeansProjects/LVAManager'
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 4s)
I read that boost serialization is no header-only library.
Has this something to do with this? Netbeans knows the boost library and gives me code assistance etc... But do i need to link it anyway?
How can i link the library in Netbeans? where can i find it.
I have a debian system and libboost-all-dev installed.
You need to add -lboost_serialization to you linker command.
It is a long time since I used netbeans but as far as I can remember it was something like Build->Linker->Libraries.
You don't need to add -l I think netbeans does this for you.