From b4021057663b7bcde6795707667ac37d0bed2e29 Mon Sep 17 00:00:00 2001 From: von Date: Sun, 24 May 2020 15:43:02 +0800 Subject: [PATCH] fix build on windows platfrom, use vs2019! --- CMakeLists.txt | 8 ++++---- include/opc/ua/protocol/utils.h | 2 +- src/core/common/uri_facade_win.cpp | 4 ++-- src/core/socket_channel.cpp | 1 + src/server/tcp_server.cpp | 1 + 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8bcc2454..3fd18323 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -165,7 +165,7 @@ ADD_CUSTOM_COMMAND( ) -add_library(opcuaprotocol +add_library(opcuaprotocol STATIC src/protocol/rawsize_auto.cpp src/protocol/serialize_auto.cpp src/protocol/deserialize_auto.cpp @@ -273,7 +273,7 @@ SET(opcuacore_SOURCES src/core/server_operations.cpp ) -add_library(opcuacore ${opcuacore_SOURCES}) +add_library(opcuacore STATIC ${opcuacore_SOURCES}) if (NOT CMAKE_VERSION VERSION_LESS 2.8.12) target_compile_options(opcuacore PUBLIC ${STATIC_LIBRARY_CXX_FLAGS}) @@ -329,7 +329,7 @@ endif(BUILD_TESTING) ############################################################################ if (BUILD_CLIENT) - add_library(opcuaclient + add_library(opcuaclient STATIC src/client/binary_connection.cpp src/client/binary_client.cpp src/client/binary_client_addon.cpp @@ -400,7 +400,7 @@ if(BUILD_SERVER) #) #ENDFOREACH(PART) - add_library(opcuaserver + add_library(opcuaserver STATIC src/server/address_space_addon.cpp src/server/address_space_internal.cpp src/server/asio_addon.cpp diff --git a/include/opc/ua/protocol/utils.h b/include/opc/ua/protocol/utils.h index e23bffe9..db846120 100644 --- a/include/opc/ua/protocol/utils.h +++ b/include/opc/ua/protocol/utils.h @@ -64,7 +64,7 @@ inline std::string ToHexDump(const char * buf, std::size_t size) template inline std::ostream & ToHexDump(std::ostream & os, const std::vector & buf, std::size_t size) { std::stringstream lineEnd; - size = std::min(size, buf.size()); + size = (std::min)(size, buf.size()); unsigned pos = 0; os << "size: " << size << "(0x" << std::hex << size << ")"; diff --git a/src/core/common/uri_facade_win.cpp b/src/core/common/uri_facade_win.cpp index 1a807fb8..2839ddf3 100644 --- a/src/core/common/uri_facade_win.cpp +++ b/src/core/common/uri_facade_win.cpp @@ -19,7 +19,7 @@ namespace Common { -void Uri::Initialize(const char * uriString, std::size_t size) +void Uri::Initialize(const std::string& uriString) { URL_COMPONENTS url = {0}; url.dwStructSize = sizeof(url); @@ -31,7 +31,7 @@ void Uri::Initialize(const char * uriString, std::size_t size) // TODO msdn says do not use this function in services and in server patforms. :( // TODO http://msdn.microsoft.com/en-us/library/windows/desktop/aa384376(v=vs.85).aspx - if (!InternetCrackUrl(uriString, size, options, &url)) + if (!InternetCrackUrl(uriString.c_str(), uriString.size(), options, &url)) { THROW_ERROR1(CannotParseUri, uriString); } diff --git a/src/core/socket_channel.cpp b/src/core/socket_channel.cpp index d54ea732..567de887 100644 --- a/src/core/socket_channel.cpp +++ b/src/core/socket_channel.cpp @@ -23,6 +23,7 @@ #ifdef _WIN32 #include +int close(SOCKET s) { return closesocket(s); } #else #include #include diff --git a/src/server/tcp_server.cpp b/src/server/tcp_server.cpp index b4f20005..8b312b6f 100644 --- a/src/server/tcp_server.cpp +++ b/src/server/tcp_server.cpp @@ -36,6 +36,7 @@ #ifdef _WIN32 +#define SHUT_RDWR 2 #else #include #include