]> git.djapps.eu Git - pkg/ggml/sources/whisper.cpp/commitdiff
server : fix building and simplify lib deps on Windows (#1772)
authorPrzemysław Pawełczyk <redacted>
Mon, 15 Jan 2024 13:48:13 +0000 (14:48 +0100)
committerGitHub <redacted>
Mon, 15 Jan 2024 13:48:13 +0000 (15:48 +0200)
* make : fix server example building on MSYS2 environments (Windows)

It was not working since commit eff3570f78742dfd56024328ed93d4f442434280
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.

Makefile
examples/server/CMakeLists.txt

index 611dc0eb2c0e016bba27646518d963a07b1457ed..f09c0bcf22a9ba46d6f03c7c742f57d4a2ba5036 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -99,6 +99,16 @@ ifeq ($(filter $(UNAME_S),Linux Darwin DragonFly FreeBSD NetBSD OpenBSD Haiku),$
        CXXFLAGS += -pthread
 endif
 
+# detect Windows
+ifneq ($(findstring _NT,$(UNAME_S)),)
+       _WIN32 := 1
+endif
+
+# Windows Sockets 2 (Winsock) for network-capable apps
+ifeq ($(_WIN32),1)
+       LWINSOCK2 := -lws2_32
+endif
+
 # Architecture specific
 # TODO: probably these flags need to be tweaked on some architectures
 #       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)
        $(CXX) $(CXXFLAGS) examples/quantize/quantize.cpp $(SRC_COMMON) $(WHISPER_OBJ) -o quantize $(LDFLAGS)
 
 server: examples/server/server.cpp $(SRC_COMMON) $(WHISPER_OBJ)
-       $(CXX) $(CXXFLAGS) examples/server/server.cpp $(SRC_COMMON) $(WHISPER_OBJ) -o server $(LDFLAGS)
+       $(CXX) $(CXXFLAGS) examples/server/server.cpp $(SRC_COMMON) $(WHISPER_OBJ) -o server $(LDFLAGS) $(LWINSOCK2)
 
 stream: examples/stream/stream.cpp $(SRC_COMMON) $(SRC_COMMON_SDL) $(WHISPER_OBJ)
        $(CXX) $(CXXFLAGS) examples/stream/stream.cpp $(SRC_COMMON) $(SRC_COMMON_SDL) $(WHISPER_OBJ) -o stream $(CC_SDL) $(LDFLAGS)
index f53022765269896f46104e215decf3422c92bee6..1e8c921323f9e1795669f1715e584d10f8a65364 100644 (file)
@@ -5,8 +5,6 @@ include(DefaultTargetOptions)
 
 target_link_libraries(${TARGET} PRIVATE common whisper ${CMAKE_THREAD_LIBS_INIT})
 
-# Check if the compiler is MinGW
-if(MINGW)
-    # Link the necessary libraries for SSL and Winsock
-    target_link_libraries(${TARGET} PRIVATE -lcrypt32 -lssl -lcrypto -lws2_32)
+if (WIN32)
+    target_link_libraries(${TARGET} PRIVATE ws2_32)
 endif()