machinezone / IXWebSocket

websocket and http client and server library, with TLS support and very few dependencies
BSD 3-Clause "New" or "Revised" License
538 stars 173 forks source link

Issue compiling (please help!) #448

Open Exergist opened 1 year ago

Exergist commented 1 year ago

I'm trying to spin up a simple C++ websocket client and I'd like to use IXWebSocket. I've already gone through...

vcpkg install ixwebsocket:x64-windows

...on the Windows 10 command line to install IXWebSocket. However when building in Visual Studio via CmakeLists.txt:

# IXWebsocket: this is super important in order for cmake to include the vcpkg search/lib paths!
set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}\\scripts\\buildsystems\\vcpkg.cmake" CACHE STRING "")

# watch variables (debug)
variable_watch(headerPath)
variable_watch(libPath)
variable_watch(IXWEBSOCKET_INCLUDE_DIR)
variable_watch(IXWEBSOCKET_LIBRARY)

# set paths of interest
set(headerPath "$ENV{VCPKG_ROOT}\\packages\\ixwebsocket_x64-windows\\include\\ixwebsocket\\IXWebSocket.h")
set(libPath "$ENV{VCPKG_ROOT}\\packages\\ixwebsocket_x64-windows\\lib\\ixwebsocket.lib")

# find ixwebsocket library and its headers
find_path(IXWEBSOCKET_INCLUDE_DIR ${headerPath})
find_library(IXWEBSOCKET_LIBRARY ${libPath})

# include headers
include_directories(${IXWEBSOCKET_INCLUDE_DIR})

...${IXWEBSOCKET_INCLUDE_DIR} and ${IXWEBSOCKET_LIBRARY} always seems to be NOTFOUND.

headerPath reports as "D:\Documents\Source\vcpkg\packages\ixwebsocket_x64-windows\include\ixwebsocket\IXWebSocket.h" (which is correct)

libPath reports as "D:\Documents\Source\vcpkg\packages\ixwebsocket_x64-windows\lib\ixwebsocket.lib" (which is correct)

I must be doing something wrong. Any thoughts or suggestions would be most appreciated!

Longwater1234 commented 2 months ago

@Exergist In case you never solved this issue, you can use CPM (a thin wrapper around Cmake FetchContent). No installation required. Here is a sample template Github project. TIP; instead of cloning with GIT_REPOSTORY, you can replace it with URL of github release (.tar.gz). Smaller and faster. I also use VS2022 Community. But This works on other platform without hassle of installation. Best for CI/CD as well.