Hi.
I'm trying to compile and link this simple program with boost::iostreams and zlib. Compilation goes well not a single error but I get lot of undefined references when linking.
Makefile:
Code:
SOCKETS_LIB = ../lib
SOCKETS_INCLUDE = ../include
BOOST_INCLUDE = C:\Boost\include\boost-1_35
BOOST_LIB = C:\Boost\lib
ZLIB_LIB = C:\zlib123
ZLIB_INCLUDE = C:\zlib123
PLATFORM = win32-cygwin
LIBS = -L $(SOCKETS_LIB) -lSockets
LIBS += -L$(BOOST_LIB)\boost_iostreams-mgw34-mt.lib
LIBS += -L $(ZLIB_LIB) -lzdll
INCLUDE = -I $(SOCKETS_INCLUDE) -I $(BOOST_INCLUDE) -I $(ZLIB_INCLUDE)
include $(SOCKETS_INCLUDE)/Makefile.version
include $(SOCKETS_INCLUDE)/Makefile.Defines.$(PLATFORM)
CPPFLAGS = $(CFLAGS)
PROGS = main
all: $(PROGS)
main: main.o
$(CXX) -o $@ $^ $(LIBS)
clean:
del -f *.o *~ slask *.d $(PROGS)
-include *.d
main.cpp - an example from here
http://www.boost.org/doc/libs/1_35_0/libs/iostreams/doc/classes/gzip.html
#include <fstream>
#include <iostream>
#include <string>
#include <boost/iostreams/filter/gzip.hpp>
#include <boost/iostreams/filtering_streambuf.hpp>
#include <boost/iostreams/copy.hpp>
#include <HttpGetSocket.h>
#include <SocketHandler.h>
using namespace std;
string url = "http://s3.travian.fi/dorf1.php";
string zipFile = "pellot.gz";
//string file = "pellot.html";
int main()
{
SocketHandler h;
HttpGetSocket s(h, url, zipFile);
h.Add(&s);
h.Select(1,0);
while (h.GetCount())
{
h.Select(1,0);
}
if (s.Complete()){
ifstream filein(zipFile.c_str(), ios_base::in | ios_base::binary);
boost::iostreams::filtering_streambuf<boost::iostreams::input> in;
in.push(boost::iostreams::gzip_decompressor());
in.push(filein);
boost::iostreams::copy(in, cout);
}
return 0;
}
Generated compile and linking commands:
Code:
g++ -Wall -g -I ../include -I C:\Boost\include\boost-1_35 -I C:\zlib123 -MD -D_VERSION='"2.2.9"' -O2 -mno-cygwin -D_WIN32 -D__CYGWIN__ -c -o main.o main.cpp
g++ -o main main.o -L ../lib -lSockets -LC:\Boost\lib\boost_iostreams-mgw34-mt.lib -L C:\zlib123 -lzdll -lws2_32
Errors:
Code:
main.o: In function `main':
C:/Sockets-2.2.9/HTMLClient/main.cpp:23: undefined reference to `boost::iostreams::zlib::default_compression'
C:/Sockets-2.2.9/HTMLClient/main.cpp:23: undefined reference to `boost::iostreams::zlib::deflated'
C:/Sockets-2.2.9/HTMLClient/main.cpp:23: undefined reference to `boost::iostreams::zlib::default_strategy'
C:/Sockets-2.2.9/HTMLClient/main.cpp:23: undefined reference to `boost::iostreams::detail::zlib_base::reset(bool, bool)'
C:/Sockets-2.2.9/HTMLClient/main.cpp:23: undefined reference to `boost::iostreams::detail::zlib_base::~zlib_base()'
C:/Sockets-2.2.9/HTMLClient/main.cpp:23: undefined reference to `boost::iostreams::detail::zlib_base::~zlib_base()'
C:/Sockets-2.2.9/HTMLClient/main.cpp:22: undefined reference to `boost::iostreams::detail::zlib_base::zlib_base()'
C:/Sockets-2.2.9/HTMLClient/main.cpp:22: undefined reference to `boost::iostreams::detail::zlib_base::do_init(boost::iostreams::zlib_params const&, bool, void* (*)(void*, unsigned int, unsigned int), void (*)(void*, void*), void*)'
C:/Sockets-2.2.9/HTMLClient/main.cpp:23: undefined reference to `boost::iostreams::detail::zlib_base::~zlib_base()'
C:/Sockets-2.2.9/HTMLClient/main.cpp:22: undefined reference to `boost::iostreams::detail::zlib_base::before(char const*&, char const*, char*&, char*)'
C:/Sockets-2.2.9/HTMLClient/main.cpp:22: undefined reference to `boost::iostreams::zlib::sync_flush'
C:/Sockets-2.2.9/HTMLClient/main.cpp:22: undefined reference to `boost::iostreams::detail::zlib_base::inflate(int)'
C:/Sockets-2.2.9/HTMLClient/main.cpp:23: undefined reference to `boost::iostreams::detail::zlib_base::after(char const*&, char*&, bool)'
C:/Sockets-2.2.9/HTMLClient/main.cpp:23: undefined reference to `boost::iostreams::zlib_error::check(int)'
C:/Sockets-2.2.9/HTMLClient/main.cpp:21: undefined reference to `boost::iostreams::zlib::stream_end'
C:/Sockets-2.2.9/HTMLClient/main.cpp:21: undefined reference to `boost::iostreams::detail::zlib_base::reset(bool, bool)'
C:/Sockets-2.2.9/HTMLClient/main.cpp:26: undefined reference to `boost::iostreams::zlib::okay'
C:/Sockets-2.2.9/HTMLClient/main.cpp:25: undefined reference to `boost::iostreams::zlib::okay'
main.o: In function `main':
C:/Boost/include/boost-1_35/boost/iostreams/chain.hpp:466: undefined reference to `boost::iostreams::zlib::okay'
main.o: In function `main':
C:/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/streambuf:187: undefined reference to `boost::iostreams::zlib::okay'
main.o: In function `main':
C:/Boost/include/boost-1_35/boost/detail/sp_counted_base_gcc_x86.hpp:36: undefined reference to `boost::iostreams::zlib::okay'
main.o:C:/Sockets-2.2.9/HTMLClient/main.cpp:12: more undefined references to `boost::iostreams::zlib::okay' follow
collect2: ld returned 1 exit status
gnumake: *** [main] Error 1
I have wrestled with this last three days and can't get it to work. I've compiled boost from source with --toolset=gcc so it should work with mingw like boost::regex-lib linked succesfully. One thing that bothers me with this iostreams lib-file is that is doesn't start with "lib" like regex, but it didn't report any problems when compiling it with bjam.
If you didn't undestand or you have some questions be free to ask.
Thanks in advance.
J-M