|
Boost Users : |
From: Ragnar Ouchterlony (ragnar_at_[hidden])
Date: 2004-07-28 02:50:11
I have tried compiled boost::thread for windows using visual c++ from the
visual studio .net 2003 suite. It compiles fine and I can compile things
with the created libraries. However, when I move my program and the
boost::thread dll:s from windows 2000 to another machine running windows XP,
the program just prints out a blank line and exits without any other
message.
Attached is a program I have used to test out that it is this that is wrong.
What have I done wrong? Is it impossible to compile the boost libraries on
windows 2000 and then expect the created dll:s to work on windows XP? If
this is the case, where can I get hold of the boost::thread libraries for
vc71 compiled specifically for windows XP? If not, what could be wrong?
/Ragnar Ouchterlony
#pragma warning(disable:4275)
#include <boost/thread/thread.hpp>
#include <boost/ref.hpp>
#include <fstream>
#include <string>
#include <iostream>
using namespace std;
class Writer
{
public:
Writer(const string& f) : wfile(f) {}
void operator()()
{
this->file.open(wfile.c_str(), ios_base::trunc);
this->file << "A nice little string." << endl;
this->file.close();
}
private:
string wfile;
ofstream file;
};
int main(int argc, char* argv)
{
Writer* wrtr;
cout << "testning, testning" << endl;
wrtr = new Writer("test.txt");
cout << "Writer created" << endl;
// Ccomment out either the first or second variant.
// First variant, using a boost thread. Doesn't work
boost::thread thrd(boost::ref(*wrtr));
cout << "Thread started" << endl;
thrd.join();
cout << "Threads joined" << endl;
// Second variant, without boost. Works
(*wrtr)();
cout << "Writer has been run" << endl;
delete wrtr;
cout << "Writer deleted" << endl;
return 0;
}
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net