I'm trying to work with the Boost Serialization libraries for some experimenting on upcoming projects
I know that the Boost Serialization library must be compiled separately from the rest of the projects/headers. I've installed a package for this on Ubuntu 10.04 including boost1.40-dev and the Serialization library, libboost-serialization1.40.0.
In my new Net Beans project, I tried a simple example to see if I could get things running. Here's the example:
/*
* File: main.C
* Author: Doug Swain
*
* Created on January 20, 2011, 11:05 AM
*/
#include <fstream>
#include <iostream>
#include <boost/archive/xml_iarchive.hpp>
#include <boost/archive/xml_oarchive.hpp>
int main() {
std::ofstream ofs("filename.xml");
boost::archive::xml_oarchive oa(ofs);
return 0;
}
And then here are the compiler errors:
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `/home/doug/BoostSerialization'
"/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux-x86/boostserialization
make[2]: Entering directory `/home/doug/BoostSerialization'
mkdir -p build/Debug/GNU-Linux-x86
rm -f build/Debug/GNU-Linux-x86/main.o.d
g++ -c -g -I/usr/include/boost/serialization -I/usr/include/boost -I/usr/include/boost/archive -MMD -MP -MF build/Debug/GNU-Linux-x86/main.o.d -o build/Debug/GNU-Linux-x86/main.o main.C
mkdir -p dist/Debug/GNU-Linux-x86
g++ -o dist/Debug/GNU-Linux-x86/boostserialization build/Debug/GNU-Linux-x86/main.o -L/usr/include/boost/serialization -L/usr/include/boost -L/usr/include/boost/archive
build/Debug/GNU-Linux-x86/main.o: In function `xml_oarchive':
/usr/include/boost/archive/xml_oarchive.hpp:100: undefined reference to `boost::archive::xml_oarchive_impl<boost::archive::xml_oarchive>::xml_oarchive_impl(std::basic_ostream<char, std::char_traits<char> >&, unsigned int)'
build/Debug/GNU-Linux-x86/main.o: In function `~xml_oarchive_impl':
/usr/include/boost/archive/xml_oarchive.hpp:73: undefined reference to `boost::archive::basic_xml_oarchive<boost::archive::xml_oarchive>::~basic_xml_oarchive()'
/usr/include/boost/archive/xml_oarchive.hpp:73: undefined reference to `boost::archive::basic_text_oprimitive<std::basic_ostream<char, std::char_traits<char> > >::~basic_text_oprimitive()'
/usr/include/boost/archive/xml_oarchive.hpp:73: undefined reference to `boost::archive::basic_text_oprimitive<std::basic_ostream<char, std::char_traits<char> > >::~basic_text_oprimitive()'
/usr/include/boost/archive/xml_oarchive.hpp:73: undefined reference to `boost::archive::basic_xml_oarchive<boost::archive::xml_oarchive>::~basic_xml_oarchive()'
/usr/include/boost/archive/xml_oarchive.hpp:73: undefined reference to `boost::archive::basic_text_oprimitive<std::basic_ostream<char, std::char_traits<char> > >::~basic_text_oprimitive()'
/usr/include/boost/archive/xml_oarchive.hpp:73: undefined reference to `boost::archive::basic_text_oprimitive<std::basic_ostream<char, std::char_traits<char> > >::~basic_text_oprimitive()'
/usr/include/boost/archive/xml_oarchive.hpp:73: undefined reference to `boost::archive::basic_xml_oarchive<boost::archive::xml_oarchive>::~basic_xml_oarchive()'
/usr/include/boost/archive/xml_oarchive.hpp:73: undefined reference to `boost::archive::basic_text_oprimitive<std::basic_ostream<char, std::char_traits<char> > >::~basic_text_oprimitive()'
/usr/include/boost/archive/xml_oarchive.hpp:73: undefined reference to `boost::archive::basic_text_oprimitive<std::basic_ostream<char, std::char_traits<char> > >::~basic_text_oprimitive()'
build/Debug/GNU-Linux-x86/main.o:(.rodata._ZTIN5boost7archive6detail15common_oarchiveINS0_12xml_oarchiveEEE[typeinfo for boost::archive::detail::common_oarchive<boost::archive::xml_oarchive>]+0x10): undefined reference to `typeinfo for boost::archive::detail::basic_oarchive'
build/Debug/GNU-Linux-x86/main.o: In function `boost::archive::xml_oarchive& boost::archive::detail::interface_oarchive<boost::archive::xml_oarchive>::operator<< <boost::archive::version_type const>(boost::archive::version_type const&)':
/usr/include/boost/archive/detail/interface_oarchive.hpp:64: undefined reference to `boost::archive::basic_xml_oarchive<boost::archive::xml_oarchive>::save_override(boost::archive::version_type const&, int)'
make[2]: Leaving directory `/home/doug/BoostSerialization'
make[1]: Leaving directory `/home/doug/BoostSerialization'
build/Debug/GNU-Linux-x86/main.o: In function `boost::archive::xml_oarchive& boost::archive::detail::interface_oarchive<boost::archive::xml_oarchive>::operator<< <boost::archive::object_id_type const>(boost::archive::object_id_type const&)':
/usr/include/boost/archive/detail/interface_oarchive.hpp:64: undefined reference to `boost::archive::basic_xml_oarchive<boost::archive::xml_oarchive>::save_override(boost::archive::object_id_type const&, int)'
build/Debug/GNU-Linux-x86/main.o: In function `boost::archive::xml_oarchive& boost::archive::detail::interface_oarchive<boost::archive::xml_oarchive>::operator<< <boost::archive::object_reference_type const>(boost::archive::object_reference_type const&)':
/usr/include/boost/archive/detail/interface_oarchive.hpp:64: undefined reference to `boost::archive::basic_xml_oarchive<boost::archive::xml_oarchive>::save_override(boost::archive::object_reference_type const&, int)'
build/Debug/GNU-Linux-x86/main.o: In function `boost::archive::xml_oarchive& boost::archive::detail::interface_oarchive<boost::archive::xml_oarchive>::operator<< <boost::archive::class_id_type const>(boost::archive::class_id_type const&)':
/usr/include/boost/archive/detail/interface_oarchive.hpp:64: undefined reference to `boost::archive::basic_xml_oarchive<boost::archive::xml_oarchive>::save_override(boost::archive::class_id_type const&, int)'
build/Debug/GNU-Linux-x86/main.o: In function `boost::archive::xml_oarchive& boost::archive::detail::interface_oarchive<boost::archive::xml_oarchive>::operator<< <boost::archive::class_id_optional_type const>(boost::archive::class_id_optional_type const&)':
/usr/include/boost/archive/detail/interface_oarchive.hpp:64: undefined reference to `boost::archive::basic_xml_oarchive<boost::archive::xml_oarchive>::save_override(boost::archive::class_id_optional_type const&, int)'
build/Debug/GNU-Linux-x86/main.o: In function `boost::archive::xml_oarchive& boost::archive::detail::interface_oarchive<boost::archive::xml_oarchive>::operator<< <boost::archive::class_id_reference_type const>(boost::archive::class_id_reference_type const&)':
/usr/include/boost/archive/detail/interface_oarchive.hpp:64: undefined reference to `boost::archive::basic_xml_oarchive<boost::archive::xml_oarchive>::save_override(boost::archive::class_id_reference_type const&, int)'
build/Debug/GNU-Linux-x86/main.o: In function `boost::archive::xml_oarchive& boost::archive::detail::interface_oarchive<boost::archive::xml_oarchive>::operator<< <boost::archive::class_name_type const>(boost::archive::class_name_type const&)':
/usr/include/boost/archive/detail/interface_oarchive.hpp:64: undefined reference to `boost::archive::basic_xml_oarchive<boost::archive::xml_oarchive>::save_override(boost::archive::class_name_type const&, int)'
build/Debug/GNU-Linux-x86/main.o: In function `boost::archive::xml_oarchive& boost::archive::detail::interface_oarchive<boost::archive::xml_oarchive>::operator<< <boost::archive::tracking_type const>(boost::archive::tracking_type const&)':
/usr/include/boost/archive/detail/interface_oarchive.hpp:64: undefined reference to `boost::archive::basic_xml_oarchive<boost::archive::xml_oarchive>::save_override(boost::archive::tracking_type const&, int)'
collect2: ld returned 1 exit status
make[2]: *** [dist/Debug/GNU-Linux-x86/boostserialization] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
I've verified that the headers do in fact exist (and NetBeans can find it prior to trying to build them). I've also made sure to update the include directories and the library directories to the best of my knowledge:
These are not compiler errors, but linker errors. You need to link in the Boost serialization library, probably called libboost_serialization.a or something along those lines.
More than including headers file from boost, you have to link to boost libraries to be able to use its functions.
Related
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.)
I am trying to test tesseract from opencv 3.0 using the test code from here
However, when I try to compile it, I get the following error
undefined reference to `cv::text::loadClassifierNM1(std::string const&)'
Any idea how I can fix this? Your help is much appreciated.
UPDATE 1
The complete error is
CMakeFiles/text_recog.dir/text_recog.o: In function `main':
text_recog.cpp:(.text+0x37b): undefined reference to `cv::text::loadClassifierNM1(std::string const&)'
text_recog.cpp:(.text+0x3bb): undefined reference to `cv::text::createERFilterNM1(cv::Ptr<cv::text::ERFilter::Callback> const&, int, float, float, float, bool, float)'
text_recog.cpp:(.text+0x42b): undefined reference to `cv::text::loadClassifierNM2(std::string const&)'
text_recog.cpp:(.text+0x44c): undefined reference to `cv::text::createERFilterNM2(cv::Ptr<cv::text::ERFilter::Callback> const&, float)'
text_recog.cpp:(.text+0x9c1): undefined reference to `cv::text::erGrouping(cv::_InputArray const&, cv::_InputArray const&, std::vector<std::vector<cv::text::ERStat, std::allocator<cv::text::ERStat> >, std::allocator<std::vector<cv::text::ERStat, std::allocator<cv::text::ERStat> > > >&, std::vector<std::vector<cv::Vec<int, 2>, std::allocator<cv::Vec<int, 2> > >, std::allocator<std::vector<cv::Vec<int, 2>, std::allocator<cv::Vec<int, 2> > > > >&, std::vector<cv::Rect_<int>, std::allocator<cv::Rect_<int> > >&, int, std::string const&, float)'
text_recog.cpp:(.text+0xa95): undefined reference to `cv::text::OCRTesseract::create(char const*, char const*, char const*, int, int)'
collect2: error: ld returned 1 exit status
make[2]: *** [text_recog] Error 1
make[1]: *** [CMakeFiles/text_recog.dir/all] Error 2
make: *** [all] Error 2
Does this help ?
It is a linker error. Look at an existing answer here
You need to compile it as g++ -o output input.cpp pkg-config opencv --cflags --libs if you are on Linux.
However if you have compiled OpenCV from source on Linux, use ldconfig to avoid linking issues.
You should use library -lopencv_text
LIBS += -lopencv_text
OR
g++ -o output input.cpp -lopencv_text
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.
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.
Newbie question... I'm trying out Boost for the first time because I want to test drive the Boost Log library. I built this test program...
#include <boost/log/trivial.hpp>
#include <iostream>
int fibonacci(int num) {
int i;
int a = 1;
int b = 1;
for (i = 2; i <= num; ++i) {
BOOST_LOG_TRIVIAL(info) << "Iteration " << i << " (a = " << a << ", b = " << b << ")...";
b = a + b;
a = b - a;
}
return a;
}
int main() {
std::cout << "8th fibonacci number: " << fibonacci(8) << std::endl;
return 0;
}
Compile data:
**** Build of configuration Debug for project LoggingCpp ****
make all
Building file: ../main.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -lpthread -MMD -MP -MF"main.d" -MT"main.d" -o"main.o" "../main.cpp"
Finished building: ../main.cpp
Building target: LoggingCpp
Invoking: GCC C++ Linker
g++ -lpthread -o"LoggingCpp" ./main.o
./main.o: In function `~basic_logger':
/usr/include/boost/log/sources/basic_logger.hpp:90: undefined reference to `boost::log_mt_posix::basic_attribute_set<char>::~basic_attribute_set()'
./main.o: In function `boost::log_mt_posix::trivial::logger::construct_logger()':
/usr/include/boost/log/trivial.hpp:102: undefined reference to `boost::log_mt_posix::trivial::aux::init()'
./main.o: In function `void boost::call_once<void (*)()>(boost::once_flag&, void (*)())':
/usr/include/boost/thread/pthread/once.hpp:51: undefined reference to `boost::detail::get_once_per_thread_epoch()'
/usr/include/boost/thread/pthread/once.hpp:55: undefined reference to `boost::detail::once_epoch_mutex'
/usr/include/boost/thread/pthread/once.hpp:66: undefined reference to `boost::detail::once_epoch_mutex'
/usr/include/boost/thread/pthread/once.hpp:77: undefined reference to `boost::detail::once_global_epoch'
/usr/include/boost/thread/pthread/once.hpp:77: undefined reference to `boost::detail::once_global_epoch'
/usr/include/boost/thread/pthread/once.hpp:77: undefined reference to `boost::detail::once_global_epoch'
/usr/include/boost/thread/pthread/once.hpp:78: undefined reference to `boost::detail::once_epoch_cv'
/usr/include/boost/thread/pthread/once.hpp:84: undefined reference to `boost::detail::once_epoch_mutex'
/usr/include/boost/thread/pthread/once.hpp:84: undefined reference to `boost::detail::once_epoch_cv'
/usr/include/boost/thread/pthread/once.hpp:88: undefined reference to `boost::detail::once_global_epoch'
/usr/include/boost/thread/pthread/once.hpp:73: undefined reference to `boost::detail::once_epoch_cv'
./main.o: In function `record_pump':
/usr/include/boost/log/sources/record_ostream.hpp:293: undefined reference to `boost::log_mt_posix::aux::stream_provider<char>::allocate_compound(boost::log_mt_posix::basic_record<char> const&)'
./main.o: In function `~auto_release':
/usr/include/boost/log/sources/record_ostream.hpp:280: undefined reference to `boost::log_mt_posix::aux::stream_provider<char>::release_compound(boost::log_mt_posix::aux::stream_provider<char>::stream_compound*)'
./main.o: In function `boost::log_mt_posix::sources::aux::logger_singleton<boost::log_mt_posix::trivial::logger>::init_instance()':
/usr/include/boost/log/sources/global_logger_storage.hpp:126: undefined reference to `boost::log_mt_posix::sources::aux::global_storage<char>::get_or_init(std::type_info const&, boost::function0<boost::shared_ptr<boost::log_mt_posix::sources::aux::logger_holder_base> > const&)'
/usr/include/boost/log/sources/global_logger_storage.hpp:147: undefined reference to `boost::log_mt_posix::odr_violation::throw_(char const*, unsigned long, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
./main.o: In function `boost::log_mt_posix::sources::aux::severity_level<boost::log_mt_posix::trivial::severity_level>::set_value(boost::log_mt_posix::trivial::severity_level)':
/usr/include/boost/log/sources/severity_feature.hpp:95: undefined reference to `boost::log_mt_posix::sources::aux::set_severity_level(int)'
./main.o: In function `boost::log_mt_posix::basic_record<char> boost::log_mt_posix::sources::basic_logger<char, boost::log_mt_posix::sources::severity_logger_mt<boost::log_mt_posix::trivial::severity_level>, boost::log_mt_posix::sources::multi_thread_model<boost::log_mt_posix::aux::light_rw_mutex> >::open_record_unlocked<boost::parameter::aux::tagged_argument<boost::log_mt_posix::keywords::tag::severity, boost::log_mt_posix::trivial::severity_level const> >(boost::parameter::aux::tagged_argument<boost::log_mt_posix::keywords::tag::severity, boost::log_mt_posix::trivial::severity_level const> const&)':
/usr/include/boost/log/sources/basic_logger.hpp:269: undefined reference to `boost::log_mt_posix::basic_core<char>::open_record(boost::log_mt_posix::basic_attribute_set<char> const&)'
./main.o: In function `boost::log_mt_posix::sources::basic_logger<char, boost::log_mt_posix::sources::severity_logger_mt<boost::log_mt_posix::trivial::severity_level>, boost::log_mt_posix::sources::multi_thread_model<boost::log_mt_posix::aux::light_rw_mutex> >::push_record_unlocked(boost::log_mt_posix::basic_record<char> const&)':
/usr/include/boost/log/sources/basic_logger.hpp:280: undefined reference to `boost::log_mt_posix::basic_core<char>::push_record(boost::log_mt_posix::basic_record<char> const&)'
./main.o: In function `basic_logger<boost::parameter::aux::tagged_argument<boost::log_mt_posix::keywords::tag::severity, const boost::log_mt_posix::trivial::severity_level> >':
/usr/include/boost/log/sources/basic_logger.hpp:145: undefined reference to `boost::log_mt_posix::basic_core<char>::get()'
/usr/include/boost/log/sources/basic_logger.hpp:145: undefined reference to `boost::log_mt_posix::basic_attribute_set<char>::basic_attribute_set()'
./main.o: In function `~pair':
/usr/include/c++/4.5/bits/stl_pair.h:72: undefined reference to `boost::log_mt_posix::basic_slim_string<char, std::char_traits<char> >::~basic_slim_string()'
/usr/include/c++/4.5/bits/stl_pair.h:72: undefined reference to `boost::log_mt_posix::basic_slim_string<char, std::char_traits<char> >::~basic_slim_string()'
./main.o: In function `basic_logger':
/usr/include/boost/log/sources/basic_logger.hpp:135: undefined reference to `boost::log_mt_posix::basic_core<char>::get()'
/usr/include/boost/log/sources/basic_logger.hpp:135: undefined reference to `boost::log_mt_posix::basic_attribute_set<char>::basic_attribute_set(boost::log_mt_posix::basic_attribute_set<char> const&)'
./main.o: In function `boost::log_mt_posix::basic_attribute_set<char>::reference_proxy::operator=(boost::shared_ptr<boost::log_mt_posix::attribute> const&) const':
/usr/include/boost/log/attributes/attribute_set.hpp:121: undefined reference to `boost::log_mt_posix::basic_slim_string<char, std::char_traits<char> >::basic_slim_string(char const*, unsigned long)'
/usr/include/boost/log/attributes/attribute_set.hpp:121: undefined reference to `boost::log_mt_posix::basic_attribute_set<char>::insert(boost::log_mt_posix::basic_slim_string<char, std::char_traits<char> > const&, boost::shared_ptr<boost::log_mt_posix::attribute> const&)'
/usr/include/boost/log/attributes/attribute_set.hpp:121: undefined reference to `boost::log_mt_posix::basic_slim_string<char, std::char_traits<char> >::~basic_slim_string()'
/usr/include/boost/log/attributes/attribute_set.hpp:121: undefined reference to `boost::log_mt_posix::basic_slim_string<char, std::char_traits<char> >::~basic_slim_string()'
./main.o: In function `pair<std::basic_string<char>, boost::shared_ptr<boost::log_mt_posix::attribute> >':
/usr/include/c++/4.5/bits/stl_pair.h:116: undefined reference to `boost::log_mt_posix::basic_slim_string<char, std::char_traits<char> >::basic_slim_string(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
./main.o: In function `boost::log_mt_posix::basic_attribute_set<char>::insert(std::pair<boost::log_mt_posix::basic_slim_string<char, std::char_traits<char> > const, boost::shared_ptr<boost::log_mt_posix::attribute> > const&)':
/usr/include/boost/log/attributes/attribute_set.hpp:507: undefined reference to `boost::log_mt_posix::basic_attribute_set<char>::insert(boost::log_mt_posix::basic_slim_string<char, std::char_traits<char> > const&, boost::shared_ptr<boost::log_mt_posix::attribute> const&)'
./main.o: In function `boost::log_mt_posix::sources::aux::severity_level<boost::log_mt_posix::trivial::severity_level>::dispatch(boost::log_mt_posix::type_dispatcher&)':
/usr/include/boost/log/sources/severity_feature.hpp:105: undefined reference to `boost::log_mt_posix::sources::aux::get_severity_level()'
./main.o: In function `boost::log_mt_posix::sources::aux::severity_level<boost::log_mt_posix::trivial::severity_level>::detach_from_thread()':
/usr/include/boost/log/sources/severity_feature.hpp:118: undefined reference to `boost::log_mt_posix::sources::aux::get_severity_level()'
collect2: ld returned 1 exit status
make: *** [LoggingCpp] Error 1
About Boost Log syntax
Did I install Boost Log incorrectly? Am I missing crucial libraries? Did I omit necessary linker flags?
You need to add something like -lboost-log-mt to your link line.
It looks like you haven't built log?
Once you've copied the log header files, etc into the corresponding folders in your boost distro (keep the same structure i.e. merge the headers to the headers, the libs folder into the libs folder of your boost distro, etc), you still need to build boost and then like John mentioned, link against it. That's why the link you referred to above points you to the standard boost build instructions.
It's a while ago, but AFAIR on linux you simply run ./bjam in the root of your boost folder.
Maybe switch unright version of the boost_log.
I have the same issue for undefined reference to "boost::log::v2_mt_posix::core::push_record_move(boost::log::v2_mt_posix::record&)"
I build the libboost_log by myself. And I use the nm to grep the push_record_move found that, "boost::log::v2s_mt_posix::core::push_record_move(boost::log::v2s_mt_posix::record&)"
From the experience of before, should add some cflag in the Makefile.