Yay its working!!!
Thanks Anchient Dragon as although your bat file didn't fix the problem, it lead me on the right direction to find the problem. The actual problem was that the Microsoft Platform SDK was not set up correctly, so although it worked perfectly inside the Visual c++ express IDE, it didn't work from the command line.
Anyway, I'll list the steps it took for me to get Boost installed correctly for Visual C++ express 2005 so that if anyone else has similar problems, it might help them.
1. Download the boost package from http://sourceforge.net/project/showf...ackage_id=8041 . Any of the packages would work, but the .exe one is the easiest to use for windows.
2. Download the boost.jam package from http://sourceforge.net/project/showf...ckage_id=72941 . Any of the packages with an Architecture of i386 would work, but the zip file would be the easiest.
3. Unzip the boost.jam download. It should be named something like boost-jam-3.1.13-1-ntx86.zip if you chose the .zip package. Copy the bjam.exe file in the zip file to the c:\windows folder.
4. Install the Microsoft Platform SDK package. You have two choices:
a) With a web install from http://www.microsoft.com/downloads/d...displaylang=en
Choose the PSDK-x86.exe download which is near the bottom of page unless you have a 64 bit processor.
b) With an iso image from http://www.microsoft.com/downloads/d...displaylang=en
Then burn the iso onto a cd using your favourite cd burning program (like http://www.deepburner.com/?r=download).
The web install is easier, but you don't get to keep the install files so if you need to reinstall it you have to download it again.
5. Set up Visual C++ express for SDK
I'm assuming it was installed at its default location (for me it was C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2) If not just adjust all the paths to your settings.
a) Open the environmental variables dialog (control panel/system/advanced/environmental variables). Then find the INCLUDE system variable, edit it and add to the end of it ";C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include" without quotes (the ';' is used to separate different entries). If there is no INCLUDE system variable, create one and set its value to "C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include".
Do the same for the LIB system variable but use the path "C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Lib".
b) Do steps 3 to 5 on the website http://msdn.microsoft.com/vstudio/ex...alc/usingpsdk/
6) Extract the boost libraries (or if you chose the .exe file in step 1, just launch it and click extract).
7) Open the boost folder. It should be called something like boost_1_33_1
8) Create a new text file and paste this in
Code:
bjam "--prefix=c:\cpp libraries\boost" "-sTOOLS=vc-8_0" install > msgs.txt
The directory after prefix is where the libraries are installed. Change this to where you want it. Note that the complete libraries take about 1GB of disk space.
The rename the file boost.bat
9) Open a command prompt at the folder your currently at.
eg start - run - cmd - cd "c:/installs/boost_1_33_1" or whatever.
10) type boost.bat and hit enter!
This will take about 10 minutes and during that you will see hundreds of warning like
Code:
cl : Command line warning D9035 : option 'Og' has been deprecated and will be re
moved in a future release
This is normal. If you get any failures but, something has gone wrong!
11) Once finished, open visual c++ express, go to tools-options-projects and solutions-VC++ directories. Go to include files and add a new entry for "C:\cpp libraries\boost\include\boost-1_33_1" (change to suit your install directory). Then create a new entry in the library file section for "C:\cpp libraries\boost\lib" (change to suit your install directory).
12) Test if it is working by using this code. It uses most of the major libraries (threads, pointers, spirit, lambda, functions, date, static_assert, tokenizer)
Code:
#include <stdio.h>
#include <tchar.h>
#include <iostream>
#include <vector>
/* Boost libraries generate a lot of warnings.
#pramga warning is used to disable them
*/
#pragma warning(push, 0)
#include <boost/lambda/lambda.hpp>
#include <boost/lambda/bind.hpp>
#include <boost/lambda/algorithm.hpp>
#include <boost/lambda/if.hpp>
#include <boost/Function.hpp>
#include <boost/tokenizer.hpp>
#include <boost/scoped_ptr.hpp>
#include <boost/thread.hpp>
#include <boost/spirit/core.hpp>
#include <boost/spirit/actor/push_back_actor.hpp>
#include <boost/assign/std/vector.hpp>
#include <boost/static_assert.hpp>
#include "boost/date_time/gregorian/gregorian.hpp"
#pragma warning(pop)
using namespace boost::lambda;
using namespace boost::assign;
using namespace boost::spirit;
void calculateDaysAlive(void);
void testFunction(void);
int adder(int x, int y);
void printNumber(double number);
void printNumber(double number) {
std::cout << number << std::endl;
}
int adder(int x, int y) {
return x + y;
}
int currentNumber;
void testFunction()
{
int x = currentNumber++;
for (int i = 0; i < 30; i++) {
std::cout << x;
}
}
int main()
{
// testing <boost/static_assert.hpp> ####################################
// note that for this macro, it is good to use double brackets
BOOST_STATIC_ASSERT((4 > 3)); // will do nothing
//BOOST_STATIC_ASSERT((4 < 3)); this line would cause a compile error
// testing <boost/thread.hpp> ########################################
std::cout << "-----thread stuff-----\n";
boost::thread_group group;
for (int i = 0; i < 10; i++) {
group.create_thread(&testFunction);
}
group.join_all();
std::cout << "\n\n";
// testing boost date/time libraries ##############################
std::cout << "-----date/time stuff-----\n";
calculateDaysAlive();
// testing boost/function.hpp #####################################
std::cout << "-----function.hpp stuff-----\n";
boost::function<int (int a, int b)> f = adder;
std::cout << f(12,23) << std::endl; // 35
// testing lambda.hpp etc #############################################
std::cout << "-----lambda stuff-----\n";
int a = 3; int b = 4; int c = 5;
std::cout << (_1 + _2) (a, b) << std::endl; // 7
//std::cout << (_1 + _2) (3, 4); compile error, you cannot use constants
// when using lambda
std::cout << bind(&adder, a, _1) (c) << std::endl; // prints 8
boost::function<int (int a)> g = bind(f, a, _1); // basically g(x) = f(3,x)
std::cout << g(10) << std::endl; // prints 13
// testing <boost/tokenizer.hpp> #################################
std::cout << "-----tokenizer stuff-----\n";
std::string s = "This is, a test";
boost::tokenizer<> tok(s);
for(boost::tokenizer<>::iterator beg=tok.begin(); beg!=tok.end();++beg){
std::cout << *beg << "\n";
}
// testing <boost/scoped_ptr.hpp> ###################################
std::cout << "-----pointer stuff-----\n";
boost::scoped_ptr<int> intPointer(new int);
*intPointer = 3;
std::cout << *intPointer << std::endl; // prints 3
// no need to call delete intPointer
// test boost/assign... ####################################
std::cout << "-----assign stuff-----\n";
std::vector<int> values;
values += 1,2,3,4,5,6,7,8,9;
values += 8,7,6,5,4,3,2,1;
std::vector<int>::iterator start = values.begin();
std::vector<int>::iterator end = values.end();
std::for_each(start, end, std::cout << _1 << ", "); // more lambda
std::cout << std::endl;
// test boost/spirit ##############################################
std::cout << "-----spirit stuff-----\n";
std::string str = "34.2, 1433, 5.443| 12.00";
std::vector<double> v;
/*
Defines a parser that starts with a real number (real_p) which is
used in a function call to printNumber ([&printNumber]) and is
followed (>>) by any number (*) of sub statements ((substatement))
that start with a comma (',') and is followed (>>) by a real number (real_p)
which is pushed onto vector v ([push_back_a(v)]). It is then followed by
a '|' and another real number that the square of it is printed. It ignores
spaces between elements (space_p in second argument)
*/
bool boolean = parse(str.c_str(),
// Begin grammar
(
real_p[&printNumber] >> *(',' >> real_p[push_back_a(v)])
>> '|' >> real_p[std::cout << (_1 * _1) << "\n"]
)
,
// End grammar
space_p).full;
std::for_each(v.begin(), v.end(), std::cout << _1 << ", ");
std::cout << std::endl;
std::cin.get();
std::cin.get();
return 0;
}
//tests <boost/date_time>
void calculateDaysAlive() {
using namespace boost::gregorian;
std::string s;
std::cout << "Enter birth day YYYY-MM-DD (eg: 2002-02-01): ";
std::cin >> s;
try {
date birthday(from_simple_string(s));
date today = day_clock::local_day();
days days_alive = today - birthday;
days one_day(1);
if (days_alive == one_day) {
std::cout << "Born yesterday, very funny" << std::endl;
}
else if (days_alive < days(0)) {
std::cout << "Not born yet, hmm: " << days_alive.days()
<< " days" <<std::endl;
}
else {
std::cout << "Days alive: " << days_alive.days() << std::endl;
}
}
catch(...) {
std::cout << "Bad date entered: " << s << std::endl;
}
}
It should output something similar to:
Code:
-----thread stuff-----
00000001111111111111111022222222222222220111111111111110000002333333333333333320
44444444444444440235555555555555555320466666666666666664023555555555555553333204
67777777777777777640238888888888888888320467999999999999999976402388888888888888
333320467999999999999997777640222204677777776400004666666444
-----date/time stuff-----
Enter birth day YYYY-MM-DD (eg: 2002-02-01): 2000-01-01
Days alive: 2423
-----function.hpp stuff-----
35
-----lambda stuff-----
7
8
13
-----tokenizer stuff-----
This
is
a
test
-----pointer stuff-----
3
-----assign stuff-----
1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1,
-----spirit stuff-----
34.2
144
1433, 5.443,
The thread test's output depends on the timing of your computer and will change every time. The date test will also change obviously.