Those of you who know me know I am constantly running into problems with linking to other libraries. Right now though I am at the end of my strings because after all the hours of research and testing I've done I still can't link boost.
I'm using MinGW 4.8.1 and Boost 1.54.0 on Windows 7. I've tried build boost both with and without the std=c++11 flag (the program I am trying to build uses the std=C++11 flag) but even with a simple test program that doesn't use C++11 I still can't link.
Here are the steps I take:
0. I install a fresh installation of MinGW 4.8.1 with the automatic installer using the latest packages option and test that it works.
1. I download Boost 1.54.0 and extract the archive to C:/Users/Nicholas/Code/ and rename the extracted folder to just be "boost"
2. In C:/MinGW/include/ I create a symbolic link to boost/boost so that #include <> can find the boost headers.
3. I run the command
bootstrap mingw as instructed by this StackOverflow link:
http://stackoverflow.com/a/13257930/1959975
4. I run the command
b2 toolset=gcc cxxflags=-std=c++11 --build-type=complete target-os=windows as instructed by the above SO link and these two:
http://stackoverflow.com/a/2895784/1959975 and
http://stackoverflow.com/a/6659916/1959975
5. I verify that library files have been written to boost/stage/lib/ and then use this as my command line for compiling my test program:
c++ -std=c++11 src/*.cpp -LC:/Users/Nicholas/Code/boost/stage/lib/ -lboost_iostreams-mgw48-s-1_54 -o test.exe |
I've tried every one of the available library files in the commandline, the files are:
- libboost_iostreams-mgw48-1_54.a
- libboost_iostreams-mgw48-d-1_54.a
- libboost_iostreams-mgw48-mt-1_54.a
- libboost_iostreams-mgw48-mt-d-1_54.a
- libboost_iostreams-mgw48-mt-s-1_54.a
- libboost_iostreams-mgw48-mt-sd-1_54.a
- libboost_iostreams-mgw48-s-1_54.a
- libboost_iostreams-mgw48-sd-1_54.a
There is also a .dll and a .dll.a for -mt-d-
No matter which I link to I always get this exact same set of linker errors:
C:\Users\Nicholas\AppData\Local\Temp\ccwBfgVQ.o:test.cpp:(.text$_ZN5boost9iostre
ams10gzip_errorC1Ei[__ZN5boost9iostreams10gzip_errorC1Ei]+0x6a): undefined refer
ence to `boost::iostreams::zlib::okay'
C:\Users\Nicholas\AppData\Local\Temp\ccwBfgVQ.o:test.cpp:(.text$_ZN5boost9iostre
ams6detail11gzip_headerC1Ev[__ZN5boost9iostreams6detail11gzip_headerC1Ev]+0x27):
undefined reference to `boost::iostreams::detail::gzip_header::reset()'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: C:\Users\N
icholas\AppData\Local\Temp\ccwBfgVQ.o: bad reloc address 0x27 in section `.text$
_ZN5boost9iostreams6detail11gzip_headerC1Ev[__ZN5boost9iostreams6detail11gzip_he
aderC1Ev]'
collect2.exe: error: ld returned 1 exit status |
This is the program I am trying to compile:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
#include <iostream>
#include <fstream>
#include <sstream>
#include <limits>
//#include "NamedBinaryTag.hpp"
#include <boost/iostreams/filtering_streambuf.hpp>
#include <boost/iostreams/filter/gzip.hpp>
#include <boost/iostreams/copy.hpp>
int main(int nargs, char const *const *args)
{
if(nargs != 2) return 1;
std::ifstream compressed (args[1], std::ios::in|std::ios::binary);
if(!compressed) return 2;
std::stringstream decompressed;
boost::iostreams::filtering_istreambuf fis;
fis.push(boost::iostreams::gzip_decompressor());
fis.push(compressed);
boost::iostreams::copy(fis, decompressed);
decompressed.seekg(std::ios::beg);
// auto nbt = NBT::Tag::read(decompressed);
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
}
|
I've done a lot of searching and I can't find what I am doing wrong, nobody else seems to have these problems. Could someone help me?