c++ - Linker errors when trying to statically linking Boost -


i trying include boost library in program, having difficulties statically linking program. bunch of linker errors though have added -l/usr/include/boost/ -lboost_filesystem makefile.

e.g., during compilation undefined reference boost::iostreams::detail::gzip_footer::reset()'

my version of boost 1.61.0.2, running ubuntu 16.10 (64 bit) , gcc version 6.2.0 20161005. boost libraries such accumulators, algorithms, ... located in /usr/include/boost, makefile looks this:

cxx = g++ cxxflags = -static -std=c++11 -wall ldflags  = -l/usr/include/boost/ -lboost_filesystem depflags = -mm   src_dir = ./src obj_dir = ./obj src_ext = .cpp obj_ext = .o  target = main  srcs := $(wildcard $(src_dir)/*$(src_ext)) objs := $(srcs:$(src_dir)/%$(src_ext)=$(obj_dir)/%$(obj_ext)) dep = depend.main   .phony: clean depend  all: $(target)  $(target): $(objs)     @echo "-> linking $@"     @$(cxx) $^ $(ldflags) -o $@  $(obj_dir)/%$(obj_ext) : $(src_dir)/%$(src_ext)     @echo "-> compiling $@"     @$(cxx) $(cxxflags) -o $@ -c $<  clean:     @echo "removing objects , main file"     @rm -f $(objs) $(target)  *.out    $(src_dir)/%.$(src_ext):      $(cxx) $(depflags) -mt \     "$(subst $(src_dir),$(obj_dir),$(subst $(src_ext),$(obj_ext),$@))" \     $(addprefix ,$@) >> $(dep);  clear_dependencies:     @echo "-> (re-)building dependencies";     @$(rm) $(dep)  depend: clear_dependencies $(srcs)   -include $(dep) 

i'm trying compile following file (an example found online)

#include <fstream> #include <iostream>  #include <boost/iostreams/filtering_stream.hpp>     #include <boost/iostreams/filtering_streambuf.hpp> #include <boost/iostreams/copy.hpp> #include <boost/iostreams/filter/gzip.hpp>  namespace bo = boost::iostreams;  int main()  {     {     std::ofstream ofile("hello.gz", std::ios_base::out | std::ios_base::binary);     bo::filtering_ostream out;     out.push(bo::gzip_compressor());      out.push(ofile);      out << "this gz file\n";     }      {     std::ifstream ifile("hello.gz", std::ios_base::in | std::ios_base::binary);     bo::filtering_streambuf<bo::input> in;     in.push(bo::gzip_decompressor());     in.push(ifile);     boost::iostreams::copy(in, std::cout);     } } 

your program not use libboost_filesystem @ all. boost library depends on liboost_iostreams.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -