Hi,
I have tried to find a good guide for how to set Boost up with MinGW, but there seems to be no good one. So I've tried a little on my own. Before I downloaded boost to my computer, my system looked like this:
Windows 7 x86 (32 bit)
MinGW 5.1.6
MSYS 1.0
The steps I took to set Boost up were the following:
1. Downloading Boost 1.42.0 from sourceforge.net
2. Extracting the archive to C:\Program1\
3. Downloading a prebuilt executable of bjam 3.1.18 and putting it into a folder in my PATH
4. Opening a command prompt window and typing the following:
Code:
cd C:\Program1\boost_1_42_0
bjam --prefix=C:\Program1\boost_1_42_0 --toolset=gcc link=static install
The last line here I basically just compiled from a number of very different looking (although doing the same thing) command lines I found on the web.
After that I tried to compile an example program I found at the boost getting started guide, which looked like this:
main.cpp
Code:
#include <boost/lambda/lambda.hpp>
#include <iostream>
#include <iterator>
#include <algorithm>
int main()
{
using namespace boost::lambda;
typedef std::istream_iterator<int> in;
std::for_each(
in(std::cin), in(), std::cout << (_1 * 3) << " " );
}
The Makefile I wrote my self (since they didn't have any guide for how to make it compile with mingw), and it looks like this:
Makefile
Code:
CC=g++
CCFLAGS= -Wall -Wextra -pedantic -g -std=c++98
CCFLAGS+=-IC:/Program1/boost_1_42_0 #$(BOOST_ROOT)
CCFLAGS+=-lmingw32
FILES=main.x
SRC=$(FILES:.x=.cpp)
OBJ=$(FILES:.x=.o)
OUT=boost_test.exe
all: $(OUT)
rm $(OBJ) #Remove .o files
$(OBJ) :
$(CC) $(SRC) $(CCFLAGS) -c #Create .o files
$(OUT) : $(OBJ)
$(CC) $(OBJ) $(CCFLAGS) -o $@ #Link .o files
Compiling with "make -k" gave me the following output:
Code:
-*- mode: compilation; default-directory: "d:/Work/Programs/Test_programs/boost_test/" -*-
Compilation started at Wed May 05 23:37:27
make -k
g++ main.cpp -Wall -Wextra -pedantic -g -std=c++98 -IC:/Program1/boost_1_42_0 -lmingw32 -c #Create .o files
In file included from c:\program1\qt\2010.02.1\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/bits/postypes.h:42,
from c:\program1\qt\2010.02.1\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/iosfwd:42,
from c:\program1\qt\2010.02.1\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/ios:39,
from c:\program1\qt\2010.02.1\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/ostream:40,
from c:\program1\qt\2010.02.1\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/iterator:65,
from C:/Program1/boost_1_42_0/boost/detail/iterator.hpp:54,
from C:/Program1/boost_1_42_0/boost/iterator/iterator_traits.hpp:8,
from C:/Program1/boost_1_42_0/boost/indirect_reference.hpp:15,
from C:/Program1/boost_1_42_0/boost/lambda/detail/operator_return_type_traits.hpp:17,
from C:/Program1/boost_1_42_0/boost/lambda/lambda.hpp:23,
from main.cpp:7:
c:\program1\qt\2010.02.1\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/cwchar:159: error: '::swprintf' has not been declared
c:\program1\qt\2010.02.1\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/cwchar:166: error: '::vswprintf' has not been declared
make: *** [main.o] Error 1
make: Target `all' not remade because of errors.
Compilation exited abnormally with code 2 at Wed May 05 23:37:30
"error: '::swprintf' has not been declared", why do I get that message? (The only thing I can find about it is that it seems to be a bug in mingw, which have been corrected now - even though it still affects me.) Didn't my boost build properly for mingw; have I maybe used the wrong arguments for bjam, or have I forgot something? I think it's so strange that there is really no good guide for how to build boost for mingw. I mean, mingw's g++ must be one of the most common compilers used when writing c++ applications, at least if you prefer using your own text editor to visual studio.
I would really appreciate help with this problem so I can get the code to compile. Thank you very much in advance.