Skip to content

Commit f6efa6d

Browse files
some more windows support change
1 parent 7c50468 commit f6efa6d

File tree

6 files changed

+107
-210
lines changed

6 files changed

+107
-210
lines changed

CMakeLists.txt

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ set(CMAKE_CXX_STANDARD 17)
66
set(CMAKE_CXX_STANDARD_REQUIRED ON)
77
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
88

9+
if(MSVC)
10+
# Release: the prebuilt webrtc is using /MT, so we need to match that
11+
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>" CACHE STRING "" FORCE)
12+
endif()
13+
914
############## Protobuf ################
1015

1116
# ---- Protobuf (FFI protos) ----
@@ -27,7 +32,13 @@ set(FFI_PROTO_FILES
2732
set(PROTO_BINARY_DIR ${CMAKE_BINARY_DIR}/generated)
2833
file(MAKE_DIRECTORY ${PROTO_BINARY_DIR})
2934

30-
find_package(Protobuf REQUIRED)
35+
find_package(Protobuf CONFIG REQUIRED)
36+
#if(MSVC)
37+
#set(Protobuf_PROTOC_EXECUTABLE
38+
# "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/tools/protobuf/protoc.exe"
39+
# CACHE FILEPATH "" FORCE)
40+
#endif()
41+
find_package(absl CONFIG REQUIRED)
3142

3243
# Object library that owns generated .pb.cc/.pb.h
3344
add_library(livekit_proto OBJECT ${FFI_PROTO_FILES})
@@ -307,7 +318,7 @@ endif()
307318
endif()
308319

309320
# Only Protobuf >= 6 needs Abseil
310-
if (Protobuf_VERSION VERSION_GREATER_EQUAL 6.0)
321+
#if (Protobuf_VERSION VERSION_GREATER_EQUAL 6.0)
311322
# Some distros export as "Abseil::"
312323
find_package(absl CONFIG QUIET)
313324
if (NOT absl_FOUND)
@@ -334,9 +345,9 @@ if (Protobuf_VERSION VERSION_GREATER_EQUAL 6.0)
334345
"Install Abseil (macOS: 'brew install abseil', Ubuntu: 'sudo apt-get install libabsl-dev'), "
335346
"or use Protobuf < 6.")
336347
endif()
337-
else()
338-
message(STATUS "Protobuf < 6 detected; skipping Abseil linking.")
339-
endif()
348+
#else()
349+
# message(STATUS "Protobuf < 6 detected; skipping Abseil linking.")
350+
#endif()
340351

341352
# On Linux, it needs to link OpenSSL
342353
if(UNIX AND NOT APPLE)

README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ This SDK enables native C++ applications to connect to LiveKit servers for real-
99
- **Rust / Cargo** (latest stable toolchain)
1010
- **Protobuf** compiler (`protoc`)
1111
- **macOS** users: System frameworks (CoreAudio, AudioToolbox, etc.) are automatically linked via CMake.
12-
- **windows** users: Ninja,
12+
- **windows** users: Ninja, Visual Studio 2022 Build Tools (MSVC toolset + Windows SDK), Rust stable (MSVC toolchain) + Cargo,
13+
vcpkg (recommended dependency manager on Windows) and install protobuf package via vcpkg
1314
- **Git LFS** (required for examples)
1415
Some example data files (e.g., audio assets) are stored using Git LFS.
1516
You must install Git LFS before cloning or pulling the repo if you want to run the examples.
@@ -32,13 +33,29 @@ git submodule update --init --recursive
3233
## ⚙️ BUILD
3334

3435
All build actions are managed by the provided build.sh script.
36+
**UNIX**
3537
```bash
3638
./build.sh clean # Clean CMake build artifacts
3739
./build.sh clean-all # Deep clean (C++ + Rust + generated files)
3840
./build.sh debug # Build Debug version
3941
./build.sh release # Build Release version
4042
./build.sh verbose # Verbose build output
4143
```
44+
**Windows**
45+
```bash
46+
cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE="$PWD/vcpkg/scripts/buildsystems/vcpkg.cmake" # Generate Makefiles in build folder
47+
# Build (Release or Debug)
48+
cmake --build build --config Release
49+
# or:
50+
cmake --build build --config Debug
51+
# Clean CMake build artifacts
52+
Remove-Item -Recurse -Force build
53+
```
54+
Note (Windows), This assumes vcpkg is checked out in the repo root at .\vcpkg\.
55+
You must install protobuf via vcpkg (so CMake can find ProtobufConfig.cmake and protoc), for example:
56+
```bash
57+
.\vcpkg\vcpkg install protobuf:x64-windows
58+
```
4259

4360
## 🧪 Run Example
4461

examples/CMakeLists.txt

Lines changed: 66 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,91 @@
11
cmake_minimum_required(VERSION 3.31.0)
2-
project (livekit-examples)
2+
project(livekit-examples)
33

44
set(CMAKE_CXX_STANDARD 17)
55
set(CMAKE_CXX_STANDARD_REQUIRED ON)
66

7-
#################### SimpleRoom example ##########################
7+
include(FetchContent)
88

9-
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
10-
include(sdl3)
9+
set(SDL_TEST OFF CACHE BOOL "" FORCE)
10+
set(SDL_TESTS OFF CACHE BOOL "" FORCE)
11+
set(SDL_INSTALL OFF CACHE BOOL "" FORCE)
12+
set(SDL_EXAMPLES OFF CACHE BOOL "" FORCE)
1113

12-
add_executable(SimpleRoom
13-
simple_room/main.cpp
14-
simple_room/fallback_capture.cpp
15-
simple_room/fallback_capture.h
16-
simple_room/sdl_media.cpp
17-
simple_room/sdl_media.h
18-
simple_room/sdl_media_manager.cpp
19-
simple_room/sdl_media_manager.h
20-
simple_room/sdl_video_renderer.cpp
21-
simple_room/sdl_video_renderer.h
22-
simple_room/wav_audio_source.cpp
23-
simple_room/wav_audio_source.h
14+
FetchContent_Declare(
15+
SDL3
16+
GIT_REPOSITORY https://github.com/libsdl-org/SDL.git
17+
GIT_TAG release-3.2.0
2418
)
19+
FetchContent_MakeAvailable(SDL3)
2520

26-
target_link_libraries(SimpleRoom
27-
PRIVATE
28-
livekit
29-
SDL3::SDL3
21+
function(livekit_windows_link_deps target)
22+
if (WIN32)
23+
target_link_libraries(${target} PRIVATE
24+
ntdll
25+
userenv
26+
winmm
27+
iphlpapi
28+
ole32
29+
uuid
30+
msdmo
31+
dmoguids
32+
strmiids
33+
wmcodecdspuuid
34+
ws2_32
35+
bcrypt
36+
)
37+
endif()
38+
endfunction()
39+
40+
add_executable(SimpleRoom
41+
simple_room/main.cpp
42+
simple_room/fallback_capture.cpp
43+
simple_room/fallback_capture.h
44+
simple_room/sdl_media.cpp
45+
simple_room/sdl_media.h
46+
simple_room/sdl_media_manager.cpp
47+
simple_room/sdl_media_manager.h
48+
simple_room/sdl_video_renderer.cpp
49+
simple_room/sdl_video_renderer.h
50+
simple_room/wav_audio_source.cpp
51+
simple_room/wav_audio_source.h
3052
)
3153

54+
target_link_libraries(SimpleRoom PRIVATE livekit SDL3::SDL3)
55+
livekit_windows_link_deps(SimpleRoom)
56+
3257
add_custom_command(TARGET SimpleRoom POST_BUILD
33-
COMMAND ${CMAKE_COMMAND} -E copy_directory
34-
${CMAKE_SOURCE_DIR}/data
35-
${CMAKE_CURRENT_BINARY_DIR}/data
58+
COMMAND ${CMAKE_COMMAND} -E copy_directory
59+
${CMAKE_SOURCE_DIR}/data
60+
${CMAKE_CURRENT_BINARY_DIR}/data
3661
)
3762

38-
#################### SimpleRpc example ##########################
39-
40-
include(FetchContent)
4163
FetchContent_Declare(
4264
nlohmann_json
4365
URL https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz
4466
)
4567
FetchContent_MakeAvailable(nlohmann_json)
4668

47-
add_executable(SimpleRpc
48-
simple_rpc/main.cpp
49-
)
50-
51-
target_link_libraries(SimpleRpc
52-
PRIVATE
53-
nlohmann_json::nlohmann_json
54-
livekit
55-
)
69+
add_executable(SimpleRpc simple_rpc/main.cpp)
70+
target_link_libraries(SimpleRpc PRIVATE nlohmann_json::nlohmann_json livekit)
71+
livekit_windows_link_deps(SimpleRpc)
5672

57-
#################### SimpleDataStream example ##########################
58-
59-
add_executable(SimpleDataStream
60-
simple_data_stream/main.cpp
61-
)
73+
add_executable(SimpleDataStream simple_data_stream/main.cpp)
74+
target_link_libraries(SimpleDataStream PRIVATE livekit)
75+
livekit_windows_link_deps(SimpleDataStream)
6276

63-
target_link_libraries(SimpleDataStream
64-
PRIVATE
65-
livekit
66-
)
67-
68-
add_custom_command(
69-
TARGET SimpleDataStream
70-
POST_BUILD
77+
add_custom_command(TARGET SimpleDataStream POST_BUILD
7178
COMMAND ${CMAKE_COMMAND} -E copy_directory
7279
${CMAKE_SOURCE_DIR}/data
7380
$<TARGET_FILE_DIR:SimpleDataStream>/data
74-
)
81+
)
82+
83+
if (WIN32 AND TARGET SDL3::SDL3)
84+
foreach(tgt SimpleRoom SimpleRpc SimpleDataStream)
85+
add_custom_command(TARGET ${tgt} POST_BUILD
86+
COMMAND ${CMAKE_COMMAND} -E copy_if_different
87+
$<TARGET_FILE:SDL3::SDL3>
88+
$<TARGET_FILE_DIR:${tgt}>
89+
)
90+
endforeach()
91+
endif()

examples/simple_data_stream/main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <map>
88
#include <optional>
99
#include <random>
10+
#include <sstream>
1011
#include <string>
1112
#include <thread>
1213
#include <vector>

examples/simple_room/fallback_capture.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@
1616

1717
#include "fallback_capture.h"
1818

19+
#include <array>
20+
#include <atomic>
1921
#include <chrono>
22+
#include <cstdint>
23+
#include <iostream>
2024
#include <thread>
2125

2226
#include "livekit/livekit.h"

0 commit comments

Comments
 (0)