I have been having a lot of difficulty trying to get a simple HTTP server built in to my application. It will be communicating only with other servers on the same local network, so SSL/TLS is not needed.
I tried setting up uWebSockets (I'm happy to take advice of anything else, especially if it is available in cygwin, since that seems to be much easier to make work), but the documentation is not very good. I did manage to get the IDE to say all errors were good by using the command:
vcpkg install libuv uwebsockets --triplet=x64-windows
and using the following CMakeLists.txt
:
cmake_minimum_required(VERSION 3.21) project(exchange)
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules) set(CMAKE_CXX_STANDARD 20) set(CMAKE_C_FLAGS "-lgmp") set(ZLIB_DEPS_DIR /cygdrive/c/src/vcpkg/packages/zlib_x64-windows/bin)
set(HEADER_FILES
long list of .h files )
set(SOURCE_FILES
long list of .cpp files )
find_package(GMP REQUIRED)
include_directories(uWebSockets) add_executable(exchange main.cpp ${SOURCE_FILES} ${HEADER_FILES}) target_link_libraries(exchange gmp gmpxx z uv)
set(UWEBSOCKETS_INCLUDE_DIRS /cygdrive/c/src/vcpkg/packages/uwebsockets_x64-windows/include/uwebsockets) set(ZLIB_INCLUDE_DIRS /cygdrive/c/src/vcpkg/packages/zlib_x64-windows/include) set(USOCKETS_INCLUDE_DIRS /cygdrive/c/src/vcpkg/packages/usockets_x64-windows/include)
target_include_directories(exchange PRIVATE ${ZLIB_INCLUDE_DIRS}) target_include_directories(exchange PRIVATE ${UWEBSOCKETS_INCLUDE_DIRS}) target_include_directories(exchange PRIVATE ${USOCKETS_INCLUDE_DIRS})
add_library(exchange_lib STATIC ${SOURCE_FILES} ${HEADER_FILES})
But, I keep getting this error when I try to build it:
/cygdrive/c/src/vcpkg/packages/uwebsockets_x64-windows/include/uwebsockets/Loop.h:31: undefined reference to `us_loop_ext'
What is an undefined reference/unresolved external symbol error and how do I fix it? explains what the problem is. The libraries are not being linked but it does not explain how to fix it.
If the library was from cygwin i could add uwebsockets to the target link library but since it is not available from that doing so just gives an error.