我在win7中使用visual c ++ 2010 我有以下代码
#include <iostream>
#include <boost/asio.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
int main(){
boost::asio::io_service io;
boost::asio::deadline_timer t(io,boost::posix_time::seconds(5));
t.wait();
std::cout<<"hello world";
return 0;
}
但我有错误
1>------ Build started: Project: networking, Configuration: Debug Win32 ------
1> networking.cpp
1> Please define _WIN32_WINNT or _WIN32_WINDOWS appropriately. For example:
1> - add -D_WIN32_WINNT=0x0501 to the compiler command line; or
1> - add _WIN32_WINNT=0x0501 to your project's Preprocessor Definitions.
1> Assuming _WIN32_WINNT=0x0501 (i.e. Windows XP target).
1>LINK : fatal error LNK1104: cannot open file 'libboost_system-vc100-mt-gd-1_44.lib'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
答案 0 :(得分:2)
好了,现在您使用Visual C ++,Boost库将自动链接,但您需要先构建它们。在这种情况下,您只需要构建Boost.System。然后将必要的目录添加为附加库目录以使其正常工作。有关详细信息,请参阅此处:http://www.boost.org/doc/libs/1_44_0/more/getting_started/index.html