From 1d737014e93d409961cb485fd445ebf78d43a26c Mon Sep 17 00:00:00 2001 From: CJ Cobb Date: Tue, 15 Dec 2020 13:44:16 -0500 Subject: [PATCH] fix link error --- CMakeLists.txt | 6 +++++- reporting/ETLSource.cpp | 1 - websocket_server_async.cpp | 32 ++++++++++++++++++++------------ 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 21180915..421b7e5f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,11 @@ project(reporting) cmake_minimum_required(VERSION 3.17) set (CMAKE_CXX_STANDARD 17) -FIND_PACKAGE( Boost 1.75 COMPONENTS thread system log REQUIRED ) +set(Boost_USE_STATIC_LIBS ON) +set(Boost_USE_MULTITHREADED ON) +set(Boost_USE_STATIC_RUNTIME ON) + +FIND_PACKAGE( Boost 1.75 COMPONENTS log log_setup thread system REQUIRED ) add_executable (reporting websocket_server_async.cpp diff --git a/reporting/ETLSource.cpp b/reporting/ETLSource.cpp index 267f26bb..4e8c9c1b 100644 --- a/reporting/ETLSource.cpp +++ b/reporting/ETLSource.cpp @@ -1,5 +1,4 @@ -#define BOOST_LOG_DYN_LINK 1 //------------------------------------------------------------------------------ /* diff --git a/websocket_server_async.cpp b/websocket_server_async.cpp index fa1923dc..db574c87 100644 --- a/websocket_server_async.cpp +++ b/websocket_server_async.cpp @@ -230,14 +230,22 @@ private: std::optional parse_config(const char* filename) { - std::ifstream in(filename, std::ios::in | std::ios::binary); - if (in) + try { - std::stringstream contents; - contents << in.rdbuf(); - in.close(); - boost::json::value value = boost::json::parse(contents.str()); - return value.as_object(); + std::ifstream in(filename, std::ios::in | std::ios::binary); + if (in) + { + std::stringstream contents; + contents << in.rdbuf(); + in.close(); + std::cout << contents.str() << std::endl; + boost::json::value value = boost::json::parse(contents.str()); + return value.as_object(); + } + } + catch (std::exception const& e) + { + std::cout << e.what() << std::endl; } return {}; } @@ -247,12 +255,12 @@ int main(int argc, char* argv[]) { // Check command line arguments. - if (argc != 4) + if (argc != 5) { - std::cerr - << "Usage: websocket-server-async
\n" - << "Example:\n" - << " websocket-server-async 0.0.0.0 8080 1\n"; + std::cerr << "Usage: websocket-server-async
" + " \n" + << "Example:\n" + << " websocket-server-async 0.0.0.0 8080 1\n"; return EXIT_FAILURE; } auto const address = net::ip::make_address(argv[1]);