Skip to content

Commit f5f159c

Browse files
authored
server : fix building and simplify lib deps on Windows (#1772)
* make : fix server example building on MSYS2 environments (Windows) It was not working since commit eff3570 when server was introduced. * cmake : simplify server example lib deps on Windows server uses httplib::Server, not httplib::SSLServer, so there is no need to mention cryptographic libraries in target_link_libraries. Winsock (ws2_32) suffices here. Also use plain library names like we use in other places.
1 parent 6ebba52 commit f5f159c

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

Makefile

+11-1
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,16 @@ ifeq ($(filter $(UNAME_S),Linux Darwin DragonFly FreeBSD NetBSD OpenBSD Haiku),$
9999
CXXFLAGS += -pthread
100100
endif
101101

102+
# detect Windows
103+
ifneq ($(findstring _NT,$(UNAME_S)),)
104+
_WIN32 := 1
105+
endif
106+
107+
# Windows Sockets 2 (Winsock) for network-capable apps
108+
ifeq ($(_WIN32),1)
109+
LWINSOCK2 := -lws2_32
110+
endif
111+
102112
# Architecture specific
103113
# TODO: probably these flags need to be tweaked on some architectures
104114
# feel free to update the Makefile for your architecture and send a pull request or issue
@@ -360,7 +370,7 @@ quantize: examples/quantize/quantize.cpp $(WHISPER_OBJ) $(SRC_COMMON)
360370
$(CXX) $(CXXFLAGS) examples/quantize/quantize.cpp $(SRC_COMMON) $(WHISPER_OBJ) -o quantize $(LDFLAGS)
361371

362372
server: examples/server/server.cpp $(SRC_COMMON) $(WHISPER_OBJ)
363-
$(CXX) $(CXXFLAGS) examples/server/server.cpp $(SRC_COMMON) $(WHISPER_OBJ) -o server $(LDFLAGS)
373+
$(CXX) $(CXXFLAGS) examples/server/server.cpp $(SRC_COMMON) $(WHISPER_OBJ) -o server $(LDFLAGS) $(LWINSOCK2)
364374

365375
stream: examples/stream/stream.cpp $(SRC_COMMON) $(SRC_COMMON_SDL) $(WHISPER_OBJ)
366376
$(CXX) $(CXXFLAGS) examples/stream/stream.cpp $(SRC_COMMON) $(SRC_COMMON_SDL) $(WHISPER_OBJ) -o stream $(CC_SDL) $(LDFLAGS)

examples/server/CMakeLists.txt

+2-4
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ include(DefaultTargetOptions)
55

66
target_link_libraries(${TARGET} PRIVATE common whisper ${CMAKE_THREAD_LIBS_INIT})
77

8-
# Check if the compiler is MinGW
9-
if(MINGW)
10-
# Link the necessary libraries for SSL and Winsock
11-
target_link_libraries(${TARGET} PRIVATE -lcrypt32 -lssl -lcrypto -lws2_32)
8+
if (WIN32)
9+
target_link_libraries(${TARGET} PRIVATE ws2_32)
1210
endif()

0 commit comments

Comments
 (0)