ASIO and RESTBED C++ not working together

  asio, c++, http, restbed, sockets

I want to make a program that has low level (UDP) connection and higher level (HTTP, WS) connection. For lower lever I’m using the ASIO STANDALONE lib and for the higher level Restbed lib which I build on my pc with the same version of ASIO lib. My problem is that both libs work perfectly separately. When I try to run example code "Serving HTML" from restbed docs I had segmentation fault thrown by asio::detail::object_poolasio::detail::epoll_reactor::descriptor_state::alloc<bool in object_pool.hpp.

I’m not calling any code for low level connection, just have 3 declared classes. When I disable all the code, by commenting it out or not including in CMake, that uses ASIO HTTP server works fine.
This is my CMake File :

cmake_minimum_required(VERSION 3.17)
project(Dyno_Server)

set(CMAKE_CXX_STANDARD 20)

find_package (Threads)
add_library(asio INTERFACE)
target_compile_definitions(asio INTERFACE ASIO_STANDALONE ASIO_LIB USE_STANDALONE_ASIO)
target_include_directories(asio INTERFACE _asio)
target_link_libraries(asio INTERFACE ${CMAKE_THREAD_LIBS_INIT})

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/_restbed/include)

file(GLOB_RECURSE SOURCES)

add_executable(Dyno_Server main.cpp HttpServer.cpp HttpServer.h udpDataServer.h udpDataServer.cpp  udpCommandClient.cpp udpCommandClient.h udpConnectionHandler.h )
target_link_libraries(${PROJECT_NAME} PRIVATE asio ${CMAKE_CURRENT_SOURCE_DIR}/_restbed/library/librestbed.so)

I tried linking both static .a and dynamic .so restbed lib but everytime I get seg fault.

Source: Windows Questions C++

LEAVE A COMMENT