I got stuck in my first asio code. I have read a first part of tutorial from official web-site(https://www.boost.org/doc/libs/1_73_0/doc/html/boost_asio/tutorial/tuttimer1.html)
Here is the code
#include <iostream>
#include <boost/asio.hpp>
int main()
{
boost::asio::io_context io;
boost::asio::steady_timer t(io, boost::asio::chrono::seconds(5));
t.wait();
std::cout << "First app with asio!" << std::endl;
return 0;
}
And here are errors
egor@PC:~/Documents/Programming/boost_asio_practice$ g++ trial.cpp
trial.cpp: In function ‘int main()’:
trial.cpp:6:15: error: ‘io_context’ is not a member of ‘boost::asio’
boost::asio::io_context io;
^~~~~~~~~~
trial.cpp:6:15: note: suggested alternative: ‘connect’
boost::asio::io_context io;
^~~~~~~~~~
connect
trial.cpp:7:15: error: ‘steady_timer’ is not a member of ‘boost::asio’
boost::asio::steady_timer t(io, boost::asio::chrono::seconds(5));
^~~~~~~~~~~~
trial.cpp:7:15: note: suggested alternative: ‘deadline_timer’
boost::asio::steady_timer t(io, boost::asio::chrono::seconds(5));
^~~~~~~~~~~~
deadline_timer
trial.cpp:8:2: error: ‘t’ was not declared in this scope
t.wait();
^
trial.cpp:8:2: note: suggested alternative: ‘tm’
t.wait();
^
tm
UPD: I have installed the latest version of boost. Now I am getting these errors, what should I do?
/tmp/ccArqi4D.o: In function `boost::asio::detail::posix_event::posix_event()':
trial.cpp:(.text._ZN5boost4asio6detail11posix_eventC2Ev[_ZN5boost4asio6detail11posix_eventC5Ev]+0x4d): undefined reference to `pthread_condattr_setclock'
/tmp/ccArqi4D.o: In function `boost::asio::detail::posix_thread::~posix_thread()':
trial.cpp:(.text._ZN5boost4asio6detail12posix_threadD2Ev[_ZN5boost4asio6detail12posix_threadD5Ev]+0x26): undefined reference to `pthread_detach'
/tmp/ccArqi4D.o: In function `boost::asio::detail::posix_thread::join()':
trial.cpp:(.text._ZN5boost4asio6detail12posix_thread4joinEv[_ZN5boost4asio6detail12posix_thread4joinEv]+0x2b): undefined reference to `pthread_join'
/tmp/ccArqi4D.o: In function `boost::asio::detail::posix_thread::start_thread(boost::asio::detail::posix_thread::func_base*)':
trial.cpp:(.text._ZN5boost4asio6detail12posix_thread12start_threadEPNS2_9func_baseE[_ZN5boost4asio6detail12posix_thread12start_threadEPNS2_9func_baseE]+0x3a): undefined reference to `pthread_create'
/tmp/ccArqi4D.o: In function `boost::asio::detail::posix_signal_blocker::posix_signal_blocker()':
trial.cpp:(.text._ZN5boost4asio6detail20posix_signal_blockerC2Ev[_ZN5boost4asio6detail20posix_signal_blockerC5Ev]+0x64): undefined reference to `pthread_sigmask'
/tmp/ccArqi4D.o: In function `boost::asio::detail::posix_signal_blocker::~posix_signal_blocker()':
trial.cpp:(.text._ZN5boost4asio6detail20posix_signal_blockerD2Ev[_ZN5boost4asio6detail20posix_signal_blockerD5Ev]+0x2d): undefined reference to `pthread_sigmask'
collect2: error: ld returned 1 exit status