I think i'm getting crazy, im trying to compile a simple project to understand how to work with io_service and I cant compile it.
#include <iostream>
#include <boost/asio.hpp>
#include <boost/bind.hpp>
class testClass
{
unsigned int other_number;
unsigned int main_number;
boost::asio::io_service& io_serv;
public:
testClass(boost::asio::io_service& io) : other_number(0), io_serv(io), main_number(0){io_serv.post(boost::bind(&testClass::printNumbers, this));}
void changeNumber(int num)
{
开发者_如何学C io_serv.post(boost::bind(&testClass::doChangeNumber, this, num));
}
private:
void doChangeNumber(int num)
{
main_number = num;
}
void printNumbers()
{
std::cout<<"Main number is: "<<main_number<<" Other number is:"<<other_number<<std::endl;
other_number++;
Sleep(1000);
io_serv.post(boost::bind(&testClass::printNumbers, this));
}
};
void main()
{
boost::asio::io_service io_serv;
testClass tc(io_serv);
io_serv.run();
int num = 0;
while (true)
{
tc.changeNumber(num++);
Sleep(2000);
}
}
I did add in "project property->c/c++->general->additional include directories" the line: "C:\Program Files (x86)\boost_1_44_0";
And I did add in "project property->linker->additional library directories" the line: "C:\Program Files (x86)\boost_1_44_0\libs";
but nothing seems to work...
I'm using visual studio 2010..
there are no .lib files in boost_1_44_0\libs... I downloaded it 2 times from boost's site just to make sure..
no matter what I do, I always get LINK : fatal error LNK1104: cannot open file 'libboost_system-vc100-mt-gd-1_44.lib'
You can build the Boost libs on your local system using bjam as described here (Section 5.2). Once you have done that you should be good to go - use this from a Visual Studio command prompt and make sure your project has the correct LIB path.
The prebuilt libs will only be there by default if you use the installer from Boost Pro Computing, I believe.
精彩评论