Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error compiling sio_client_impl.cpp #300

Closed
GIP2000 opened this issue Apr 13, 2021 · 10 comments
Closed

Error compiling sio_client_impl.cpp #300

GIP2000 opened this issue Apr 13, 2021 · 10 comments
Labels
boost Issue related to the previous BOOS requirement needs info Information has been asked and we are waiting for a reply

Comments

@GIP2000
Copy link

GIP2000 commented Apr 13, 2021

I am trying to compile the project however I run into an issue when I compile the sio_clinet_impl.cpp file

Makefile
`.PHONY: clean
all: SocketHandler.out

SocketHandler.out:
g++ -std=c++11 -I ./socket.io-client-cpp/lib/asio/asio/include -I ./socket.io-client-cpp/lib/websocketpp -I ./socket.io-client-cpp/lib/rapidjson/include -c SocketHandler.cpp
g++ -std=c++11 -I ./socket.io-client-cpp/lib/asio/asio/include -I ./socket.io-client-cpp/lib/websocketpp -I ./socket.io-client-cpp/lib/rapidjson/include -c sio_client.cpp
g++ -std=c++11 -I ./socket.io-client-cpp/lib/asio/asio/include -I ./socket.io-client-cpp/lib/websocketpp -I ./socket.io-client-cpp/lib/rapidjson/include -c sio_socket.cpp
g++ -std=c++11 -I ./socket.io-client-cpp/lib/asio/asio/include -I ./socket.io-client-cpp/lib/websocketpp -I ./socket.io-client-cpp/lib/rapidjson/include -c internal/sio_packet.cpp
g++ -std=c++11 -I ./socket.io-client-cpp/lib/asio/asio/include -I ./socket.io-client-cpp/lib/websocketpp -I ./socket.io-client-cpp/lib/rapidjson/include -c internal/sio_client_impl.cpp
g++ -std=c++11 sio_client.o sio_socket.o sio_packet.o SocketHandler.o -o output.out

clean:
rm -rf SocketHandler.out
rm -rf sio_client.o
rm -rf sio_socket.o
rm -rf sio_packet.o
rm -rf SocketHandler.o`

my boost version is 1.71.0ubuntu2 (I ran dpkg -s libboost-dev | grep 'Version')

I moved the contents of the src folder to the main directory but left everything else in the folder that comes with the git clone.
I am clearly doing something wrong can anyone help me please.

I get these errors:
`
internal/sio_client_impl.cpp: In member function ‘asio::io_service& sio::client_impl::get_io_service()’:
internal/sio_client_impl.cpp:201:39: error: invalid initialization of reference of type ‘asio::io_service&’ {aka ‘asio::io_context&’} from expression of type ‘boost::asio::io_service’ {aka ‘boost::asio::io_context’}
201 | return m_client.get_io_service();
| ~~~~~~~~~~~~~~~~~~~~~~~^~
internal/sio_client_impl.cpp: In member function ‘void sio::client_impl::ping(const error_code&)’:
internal/sio_client_impl.cpp:321:88: error: no matching function for call to ‘asio::basic_waitable_timerstd::chrono::_V2::steady_clock::basic_waitable_timer(boost::asio::io_service&)’
321 | _timer.reset(new asio::steady_timer(m_client.get_io_service()));
| ^

In file included from ./socket.io-client-cpp/lib/asio/asio/include/asio/steady_timer.hpp:22,
from internal/sio_client_impl.h:37,
from internal/sio_client_impl.cpp:9:
./socket.io-client-cpp/lib/asio/asio/include/asio/basic_waitable_timer.hpp:231:3: note: candidate: ‘asio::basic_waitable_timer<Clock, WaitTraits>::basic_waitable_timer(asio::basic_waitable_timer<Clock, WaitTraits>&&) [with Clock = std::chrono::_V2::steady_clock; WaitTraits = asio::wait_traitsstd::chrono::_V2::steady_clock]’
231 | basic_waitable_timer(basic_waitable_timer&& other)
| ^~~~~~~~~~~~~~~~~~~~
./socket.io-client-cpp/lib/asio/asio/include/asio/basic_waitable_timer.hpp:231:47: note: no known conversion for argument 1 from ‘boost::asio::io_service’ {aka ‘boost::asio::io_context’} to ‘asio::basic_waitable_timerstd::chrono::_V2::steady_clock&&’
231 | basic_waitable_timer(basic_waitable_timer&& other)
| ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
./socket.io-client-cpp/lib/asio/asio/include/asio/basic_waitable_timer.hpp:210:3: note: candidate: ‘asio::basic_waitable_timer<Clock, WaitTraits>::basic_waitable_timer(asio::io_context&, const duration&) [with Clock = std::chrono::_V2::steady_clock; WaitTraits = asio::wait_traitsstd::chrono::_V2::steady_clock; asio::basic_waitable_timer<Clock, WaitTraits>::duration = std::chrono::duration<long int, std::ratio<1, 1000000000> >]’
210 | basic_waitable_timer(asio::io_context& io_context,
| ^~~~~~~~~~~~~~~~~~~~
./socket.io-client-cpp/lib/asio/asio/include/asio/basic_waitable_timer.hpp:210:3: note: candidate expects 2 arguments, 1 provided
./socket.io-client-cpp/lib/asio/asio/include/asio/basic_waitable_timer.hpp:191:3: note: candidate: ‘asio::basic_waitable_timer<Clock, WaitTraits>::basic_waitable_timer(asio::io_context&, const time_point&) [with Clock = std::chrono::_V2::steady_clock; WaitTraits = asio::wait_traitsstd::chrono::_V2::steady_clock; asio::basic_waitable_timer<Clock, WaitTraits>::time_point = std::chrono::time_point<std::chrono::_V2::steady_clock, std::chrono::duration<long int, std::ratio<1, 1000000000> > >]’
191 | basic_waitable_timer(asio::io_context& io_context,
| ^~~~~~~~~~~~~~~~~~~~
./socket.io-client-cpp/lib/asio/asio/include/asio/basic_waitable_timer.hpp:191:3: note: candidate expects 2 arguments, 1 provided
./socket.io-client-cpp/lib/asio/asio/include/asio/basic_waitable_timer.hpp:176:12: note: candidate: ‘asio::basic_waitable_timer<Clock, WaitTraits>::basic_waitable_timer(asio::io_context&) [with Clock = std::chrono::_V2::steady_clock; WaitTraits = asio::wait_traitsstd::chrono::_V2::steady_clock]’
176 | explicit basic_waitable_timer(asio::io_context& io_context)
| ^~~~~~~~~~~~~~~~~~~~
./socket.io-client-cpp/lib/asio/asio/include/asio/basic_waitable_timer.hpp:176:51: note: no known conversion for argument 1 from ‘boost::asio::io_service’ {aka ‘boost::asio::io_context’} to ‘asio::io_context&’
176 | explicit basic_waitable_timer(asio::io_context& io_context)
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~
internal/sio_client_impl.cpp: In member function ‘void sio::client_impl::on_fail(websocketpp::connection_hdl)’:
internal/sio_client_impl.cpp:405:82: error: no matching function for call to ‘asio::basic_waitable_timerstd::chrono::_V2::steady_clock::basic_waitable_timer(boost::asio::io_service&)’
405 | _timer.reset(new asio::steady_timer(m_client.get_io_service()));
| ^

In file included from ./socket.io-client-cpp/lib/asio/asio/include/asio/steady_timer.hpp:22,
from internal/sio_client_impl.h:37,
from internal/sio_client_impl.cpp:9:
./socket.io-client-cpp/lib/asio/asio/include/asio/basic_waitable_timer.hpp:231:3: note: candidate: ‘asio::basic_waitable_timer<Clock, WaitTraits>::basic_waitable_timer(asio::basic_waitable_timer<Clock, WaitTraits>&&) [with Clock = std::chrono::_V2::steady_clock; WaitTraits = asio::wait_traitsstd::chrono::_V2::steady_clock]’
231 | basic_waitable_timer(basic_waitable_timer&& other)
| ^~~~~~~~~~~~~~~~~~~~
./socket.io-client-cpp/lib/asio/asio/include/asio/basic_waitable_timer.hpp:231:47: note: no known conversion for argument 1 from ‘boost::asio::io_service’ {aka ‘boost::asio::io_context’} to ‘asio::basic_waitable_timerstd::chrono::_V2::steady_clock&&’
231 | basic_waitable_timer(basic_waitable_timer&& other)
| ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
./socket.io-client-cpp/lib/asio/asio/include/asio/basic_waitable_timer.hpp:210:3: note: candidate: ‘asio::basic_waitable_timer<Clock, WaitTraits>::basic_waitable_timer(asio::io_context&, const duration&) [with Clock = std::chrono::_V2::steady_clock; WaitTraits = asio::wait_traitsstd::chrono::_V2::steady_clock; asio::basic_waitable_timer<Clock, WaitTraits>::duration = std::chrono::duration<long int, std::ratio<1, 1000000000> >]’
210 | basic_waitable_timer(asio::io_context& io_context,
| ^~~~~~~~~~~~~~~~~~~~
./socket.io-client-cpp/lib/asio/asio/include/asio/basic_waitable_timer.hpp:210:3: note: candidate expects 2 arguments, 1 provided
./socket.io-client-cpp/lib/asio/asio/include/asio/basic_waitable_timer.hpp:191:3: note: candidate: ‘asio::basic_waitable_timer<Clock, WaitTraits>::basic_waitable_timer(asio::io_context&, const time_point&) [with Clock = std::chrono::_V2::steady_clock; WaitTraits = asio::wait_traitsstd::chrono::_V2::steady_clock; asio::basic_waitable_timer<Clock, WaitTraits>::time_point = std::chrono::time_point<std::chrono::_V2::steady_clock, std::chrono::duration<long int, std::ratio<1, 1000000000> > >]’
191 | basic_waitable_timer(asio::io_context& io_context,
| ^~~~~~~~~~~~~~~~~~~~
./socket.io-client-cpp/lib/asio/asio/include/asio/basic_waitable_timer.hpp:191:3: note: candidate expects 2 arguments, 1 provided
./socket.io-client-cpp/lib/asio/asio/include/asio/basic_waitable_timer.hpp:176:12: note: candidate: ‘asio::basic_waitable_timer<Clock, WaitTraits>::basic_waitable_timer(asio::io_context&) [with Clock = std::chrono::_V2::steady_clock; WaitTraits = asio::wait_traitsstd::chrono::_V2::steady_clock]’
176 | explicit basic_waitable_timer(asio::io_context& io_context)
| ^~~~~~~~~~~~~~~~~~~~
./socket.io-client-cpp/lib/asio/asio/include/asio/basic_waitable_timer.hpp:176:51: note: no known conversion for argument 1 from ‘boost::asio::io_service’ {aka ‘boost::asio::io_context’} to ‘asio::io_context&’
176 | explicit basic_waitable_timer(asio::io_context& io_context)
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~
internal/sio_client_impl.cpp: In member function ‘void sio::client_impl::on_close(websocketpp::connection_hdl)’:
internal/sio_client_impl.cpp:469:86: error: no matching function for call to ‘asio::basic_waitable_timerstd::chrono::_V2::steady_clock::basic_waitable_timer(boost::asio::io_service&)’
469 | _timer.reset(new asio::steady_timer(m_client.get_io_service()));
| ^

In file included from ./socket.io-client-cpp/lib/asio/asio/include/asio/steady_timer.hpp:22,
from internal/sio_client_impl.h:37,
from internal/sio_client_impl.cpp:9:
./socket.io-client-cpp/lib/asio/asio/include/asio/basic_waitable_timer.hpp:231:3: note: candidate: ‘asio::basic_waitable_timer<Clock, WaitTraits>::basic_waitable_timer(asio::basic_waitable_timer<Clock, WaitTraits>&&) [with Clock = std::chrono::_V2::steady_clock; WaitTraits = asio::wait_traitsstd::chrono::_V2::steady_clock]’
231 | basic_waitable_timer(basic_waitable_timer&& other)
| ^~~~~~~~~~~~~~~~~~~~
./socket.io-client-cpp/lib/asio/asio/include/asio/basic_waitable_timer.hpp:231:47: note: no known conversion for argument 1 from ‘boost::asio::io_service’ {aka ‘boost::asio::io_context’} to ‘asio::basic_waitable_timerstd::chrono::_V2::steady_clock&&’
231 | basic_waitable_timer(basic_waitable_timer&& other)
| ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
./socket.io-client-cpp/lib/asio/asio/include/asio/basic_waitable_timer.hpp:210:3: note: candidate: ‘asio::basic_waitable_timer<Clock, WaitTraits>::basic_waitable_timer(asio::io_context&, const duration&) [with Clock = std::chrono::_V2::steady_clock; WaitTraits = asio::wait_traitsstd::chrono::_V2::steady_clock; asio::basic_waitable_timer<Clock, WaitTraits>::duration = std::chrono::duration<long int, std::ratio<1, 1000000000> >]’
210 | basic_waitable_timer(asio::io_context& io_context,
| ^~~~~~~~~~~~~~~~~~~~
./socket.io-client-cpp/lib/asio/asio/include/asio/basic_waitable_timer.hpp:210:3: note: candidate expects 2 arguments, 1 provided
./socket.io-client-cpp/lib/asio/asio/include/asio/basic_waitable_timer.hpp:191:3: note: candidate: ‘asio::basic_waitable_timer<Clock, WaitTraits>::basic_waitable_timer(asio::io_context&, const time_point&) [with Clock = std::chrono::_V2::steady_clock; WaitTraits = asio::wait_traitsstd::chrono::_V2::steady_clock; asio::basic_waitable_timer<Clock, WaitTraits>::time_point = std::chrono::time_point<std::chrono::_V2::steady_clock, std::chrono::duration<long int, std::ratio<1, 1000000000> > >]’
191 | basic_waitable_timer(asio::io_context& io_context,
| ^~~~~~~~~~~~~~~~~~~~
./socket.io-client-cpp/lib/asio/asio/include/asio/basic_waitable_timer.hpp:191:3: note: candidate expects 2 arguments, 1 provided
./socket.io-client-cpp/lib/asio/asio/include/asio/basic_waitable_timer.hpp:176:12: note: candidate: ‘asio::basic_waitable_timer<Clock, WaitTraits>::basic_waitable_timer(asio::io_context&) [with Clock = std::chrono::_V2::steady_clock; WaitTraits = asio::wait_traitsstd::chrono::_V2::steady_clock]’
176 | explicit basic_waitable_timer(asio::io_context& io_context)
| ^~~~~~~~~~~~~~~~~~~~
./socket.io-client-cpp/lib/asio/asio/include/asio/basic_waitable_timer.hpp:176:51: note: no known conversion for argument 1 from ‘boost::asio::io_service’ {aka ‘boost::asio::io_context’} to ‘asio::io_context&’
176 | explicit basic_waitable_timer(asio::io_context& io_context)`

@ghost
Copy link

ghost commented May 21, 2021

@GIP2000 i get same issue
if you solved please share for me

@Amith4504
Copy link

I have been encountering the same issue . Has anyone resolved the errors ?

@megan1997s
Copy link

I have the same issue boost is still "required" even though it should not be and I eliminated most of the errors by including boost to the project and have it down to for errors

@jmigual
Copy link
Collaborator

jmigual commented Mar 10, 2022

Hi, as of af68bf3 Boost is no longer required. We've updated the installation instructions without CMake. Can you try following them and see if the issue persists?

@jmigual jmigual added boost Issue related to the previous BOOS requirement needs info Information has been asked and we are waiting for a reply labels Mar 10, 2022
@jimver04
Copy link

jimver04 commented Feb 6, 2023

When you say without CMake, I have inferred that you mean Visual Studio, but which version? For the sake of user friendliness say at least Visual Studio. There are also other C++ IDEs. Thanks!

@jmigual
Copy link
Collaborator

jmigual commented Feb 6, 2023

Hi @jimver04. We don't mean any IDE in particular. Each IDE or build system has a way of specifying a header search path (point 2) a source files path (point 3) and some defines (point 4). So in your IDE or build system you need to specify:

  • That the header search paths should contain:
    • ./lib/asio/asio/include
    • ./lib/websocketpp
    • ./lib/rapidjson/include
  • That the files to be built from socket.io-cpp are all files under the ./src directory
  • That the defines that must be set are:
    • BOOST_DATE_TIME_NO_LIB
    • BOOST_REGEX_NO_LIB
    • ASIO_STANDALONE
    • _WEBSOCKETPP_CPP11_STL_
    • _WEBSOCKETPP_CPP11_FUNCTIONAL_

Afterwards you can use the socket io c++ library by including the header sio_client.h in your code.

@jmigual jmigual closed this as completed Feb 6, 2023
@jimver04
Copy link

I have done these steps and I get:

cannot open file 'boost.lib'

boost.lib is nowhere in my filesystem

@jmigual
Copy link
Collaborator

jmigual commented Feb 13, 2023

Boost is not required. We only officially support CMake and provide info for other build systems. I don't know how to help you if you are not using CMake

@jimver04
Copy link

ok, I had to remove boost.lib from Linker/Additional Dependencies.
boost.lib is needed only for the QT example I guess ...
Probably it was forgotten if QT example was used as a start base for the Console example.

image

@jmigual
Copy link
Collaborator

jmigual commented Feb 13, 2023

Ah you are right! We forgot to remove that part from the examples. I'll remove it from the documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
boost Issue related to the previous BOOS requirement needs info Information has been asked and we are waiting for a reply
Projects
None yet
Development

No branches or pull requests

5 participants