#include "stdafx.h" #include <iostream> #include <boost/asio.hpp> #include <conio.h> #include <stdio.h> #include <fstream> #include <string> using namespace std; // ... int main() { boost::asio::ip::tcp::iostream stream; stream.expires_from_now(boost::posix_time::seconds(60)); // ... system("pause"); return 0; } 

What a mistake

'Error 3 error LNK2019: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::system_category(void)" (?system_category@system@boost@@YAABVerror_category@12@XZ) referenced in function "public: __thiscall boost::system::error_code::error_code(void)" (??0error_code@system@boost@@QAE@XZ) c:\Users\Gen\documents\visual studio 2012\Projects\ConsoleApplication2\ConsoleApplication2\ConsoleApplication2.obj core2 Error 4 error LNK2019: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::generic_category(void)" (?generic_category@system@boost@@YAABVerror_category@12@XZ) referenced in function "void __cdecl boost::system::'dynamic initializer for 'errno_ecat''(void)" (??__Eerrno_ecat@system@boost@@YAXXZ) c:\Users\Gen\documents\visual studio 2012\Projects\ConsoleApplication2\ConsoleApplication2\ConsoleApplication2.obj core2 Error 5 error LNK1120: 2 unresolved externals c:\users\gen\documents\visual studio 2012\Projects\ConsoleApplication2\Debug\core2.exe 1 1 core2'

  • Now I downloaded the last boost. I copied your code from the post and it compiled without a single error. The main point in the project settings folder in which the header files and static libraries. - Roman Goriachevskiy

2 answers 2

Try to connect the boost_system library

  • To connect it you need to write in the header So? #include <boost_system> - Not even close
  • not. Not only. It is necessary in libraries (libraries) to add the desired file. - gecube
  • No, it is necessary somewhere in the project properties to specify the link library boost_system.dll - skegg
  • By the way, the header can be omitted. It is already included in the boost_asio headers, which depends on this library. Many libraries of Busto depend on it. - skegg
  • Sorry, I didn’t understand how to add: (. I even did a search for this dll in a folder with a boost but it wasn’t found) can be explained as for stupid?) - Not even close

By the title I see what you are compiling in the studio.

Write a line after the header.

 #pragma comment(lib, "boost_system.lib") 

well, or whatever that library is called.

In general, you yourself compiled boost?
In the studio, specify the path to the libraries and you will be happy.

My library is called:
libboost_system-vc100-mt-1_52.lib for Release
or
libboost_system-vc100-mt-gd-1_52.lib for Debug

  • Yes, I compiled it myself, it seems to be the way I pointed out (as far as I understand it doesn’t swear at inclices), but even your method doesn’t see the library library - Not even close
  • Well, if you did not specify the path to the files in the studio settings, then in the command that I wrote from above, you need to enter the full path to the library. - Roman Goriachevskiy
  • If there is no such library (which is very strange), it can be found [here] [1]. [1]: sourceforge.net/projects/boost/files/boost-binaries - skegg
  • [How to compile boost to dll.] [1] [1]: boost.2283326.n4.nabble.com/Building-Boost-DLLs-td2695730.html - skegg