From eff2570faf3dae7908db87edf4ef1a6ea88e5b33 Mon Sep 17 00:00:00 2001
From: cdevelop <cdevelop@qq.com>
Date: 星期三, 15 十一月 2023 19:46:00 +0800
Subject: [PATCH] 解决windwos 加载lm模型失败 (#1093)

---
 runtime/onnxruntime/src/bias-lm.cpp                            |    4 +++-
 runtime/onnxruntime/CMakeLists.txt                             |    5 ++++-
 runtime/onnxruntime/src/CMakeLists.txt                         |    1 +
 runtime/onnxruntime/third_party/openfst/src/lib/CMakeLists.txt |   18 +++++++++++++++++-
 runtime/websocket/CMakeLists.txt                               |    4 +++-
 5 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/runtime/onnxruntime/CMakeLists.txt b/runtime/onnxruntime/CMakeLists.txt
index f91655d..ab0e842 100644
--- a/runtime/onnxruntime/CMakeLists.txt
+++ b/runtime/onnxruntime/CMakeLists.txt
@@ -55,7 +55,10 @@
     # with some patch to fix the make errors. 
     add_subdirectory(third_party/openfst)
     include_directories(${openfst_SOURCE_DIR}/src/include)
-    
+    if(WIN32)
+    include_directories(${openfst_SOURCE_DIR}/src/lib)
+    endif()
+
 endif()
 
 add_subdirectory(third_party/yaml-cpp)
diff --git a/runtime/onnxruntime/src/CMakeLists.txt b/runtime/onnxruntime/src/CMakeLists.txt
index 1a2ca63..9eac2b6 100644
--- a/runtime/onnxruntime/src/CMakeLists.txt
+++ b/runtime/onnxruntime/src/CMakeLists.txt
@@ -7,6 +7,7 @@
 if(WIN32)
 add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/execution-charset:utf-8>")
 add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/source-charset:utf-8>")
+add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/bigobj>")
 endif()
 
 add_library(funasr SHARED ${files})
diff --git a/runtime/onnxruntime/src/bias-lm.cpp b/runtime/onnxruntime/src/bias-lm.cpp
index 5be87f8..a652f29 100644
--- a/runtime/onnxruntime/src/bias-lm.cpp
+++ b/runtime/onnxruntime/src/bias-lm.cpp
@@ -1,5 +1,7 @@
 #include "bias-lm.h"
-
+#ifdef _WIN32
+#include "fst-types.cc"
+#endif
 namespace funasr {
 void print(std::queue<StateId> &q) {
   std::queue<StateId> data = q;
diff --git a/runtime/onnxruntime/third_party/openfst/src/lib/CMakeLists.txt b/runtime/onnxruntime/third_party/openfst/src/lib/CMakeLists.txt
index 9960ce9..9097bd8 100644
--- a/runtime/onnxruntime/third_party/openfst/src/lib/CMakeLists.txt
+++ b/runtime/onnxruntime/third_party/openfst/src/lib/CMakeLists.txt
@@ -1,6 +1,20 @@
 FILE(GLOB HEADER_FILES ../include/fst/*.h)
 
-
+if(WIN32)
+add_library(fst STATIC
+  compat.cc
+  flags.cc
+  fst-types.cc
+  fst.cc
+  mapped-file.cc
+  properties.cc
+  symbol-table.cc
+  symbol-table-ops.cc
+  util.cc
+  weight.cc
+  ${HEADER_FILES}
+)
+else()
 add_library(fst
   compat.cc
   flags.cc
@@ -14,6 +28,8 @@
   weight.cc
   ${HEADER_FILES}
 )
+endif()
+
 set_target_properties(fst PROPERTIES
   SOVERSION "${SOVERSION}"
 )
diff --git a/runtime/websocket/CMakeLists.txt b/runtime/websocket/CMakeLists.txt
index b234265..a34798e 100644
--- a/runtime/websocket/CMakeLists.txt
+++ b/runtime/websocket/CMakeLists.txt
@@ -111,7 +111,9 @@
     # with some patch to fix the make errors. 
     add_subdirectory(${PROJECT_SOURCE_DIR}/../onnxruntime/third_party/openfst openfst)
     include_directories(${openfst_SOURCE_DIR}/src/include)
-    
+    if(WIN32)
+    include_directories(${openfst_SOURCE_DIR}/src/lib)
+    endif() 
 endif()
 
 

--
Gitblit v1.9.1