简体   繁体   中英

Boost example doesn't compile on VS2010?

I was trying to get one of the boost examples from the website to work:

http://www.boost.org/doc/libs/1_47_0/doc/html/boost_asio/example/http/client/async_client.cpp

but whenever I built and tried to execute, I kept getting the following from VS2010:

1>------ Build started: Project: highfreqdemo, Configuration: Debug Win32 ------
1>Build started 24/10/2011 18:41:08.
1>InitializeBuildStatus:
1>  Touching "Debug\highfreqdemo.unsuccessfulbuild".
1>ClCompile:
1>  All outputs are up-to-date.
1>  highfreqdemo.cpp
1>c:\users\x\documents\visual studio 2010\projects\highfreqdemo\highfreqdemo\highfreqdemo.cpp(4): warning C4627: '#include <iostream>': skipped when looking for precompiled header use
1>          Add directive to 'StdAfx.h' or rebuild precompiled header
1>c:\users\x\documents\visual studio 2010\projects\highfreqdemo\highfreqdemo\highfreqdemo.cpp(5): warning C4627: '#include <istream>': skipped when looking for precompiled header use
1>          Add directive to 'StdAfx.h' or rebuild precompiled header
1>c:\users\x\documents\visual studio 2010\projects\highfreqdemo\highfreqdemo\highfreqdemo.cpp(6): warning C4627: '#include <ostream>': skipped when looking for precompiled header use
1>          Add directive to 'StdAfx.h' or rebuild precompiled header
1>c:\users\x\documents\visual studio 2010\projects\highfreqdemo\highfreqdemo\highfreqdemo.cpp(7): warning C4627: '#include <string>': skipped when looking for precompiled header use
1>          Add directive to 'StdAfx.h' or rebuild precompiled header
1>c:\users\x\documents\visual studio 2010\projects\highfreqdemo\highfreqdemo\highfreqdemo.cpp(8): warning C4627: '#include <boost/asio.hpp>': skipped when looking for precompiled header use
1>          Add directive to 'StdAfx.h' or rebuild precompiled header
1>c:\users\x\documents\visual studio 2010\projects\highfreqdemo\highfreqdemo\highfreqdemo.cpp(9): warning C4627: '#include <boost/bind.hpp>': skipped when looking for precompiled header use
1>          Add directive to 'StdAfx.h' or rebuild precompiled header
1>c:\users\x\documents\visual studio 2010\projects\highfreqdemo\highfreqdemo\highfreqdemo.cpp(199): fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "StdAfx.h"' to your source?
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.76
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I am a little unsure what exactly to do to remedy this?

 Add directive to 'StdAfx.h' or rebuild precompiled header 

Your project is configured with precompiled header support but you have not included the precompiled header in your source file.

The precompiled header file (in this case, StdAfx.h ) needs to be included at the very top of every source file that is configured to use the precompiled header.

Either include this file or disable precompiled headers (In the project properties, under C/C++ -> Precompiled Headers, set the Precompiled Header property to "Not Using Precompiled Headers;" this can be set for individual source files as well).

The warnings and errors are pretty clear; you need to add #include "StdAfx.h" to your highfreqdemo.cpp file, before including the standard and Boost headers.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM