Skip to content

Commit

Permalink
Use a single static lib file for onnxruntime on Windows (#404)
Browse files Browse the repository at this point in the history
  • Loading branch information
csukuangfj authored Oct 31, 2023
1 parent b80b7e5 commit 27db015
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 84 deletions.
15 changes: 8 additions & 7 deletions cmake/onnxruntime-win-x64-static.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ if(BUILD_SHARED_LIBS)
message(FATAL_ERROR "This file is for building static libraries. BUILD_SHARED_LIBS: ${BUILD_SHARED_LIBS}")
endif()

set(onnxruntime_URL "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.16.0/onnxruntime-win-x64-static-1.16.0.tar.bz2")
set(onnxruntime_URL2 "https://huggingface.co/csukuangfj/onnxruntime-libs/resolve/main/onnxruntime-win-x64-static-1.16.0.tar.bz2")
set(onnxruntime_HASH "SHA256=d1b87e8a438a7e31b46bf13a194c5ac38fdf60ebeefef82692008e42e3242776")
set(onnxruntime_URL "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.16.0/onnxruntime-win-x64-static_lib-1.16.0.tar.bz2")
set(onnxruntime_URL2 "https://huggingface.co/csukuangfj/onnxruntime-libs/resolve/main/onnxruntime-win-x64-static_lib-1.16.0.tar.bz2")
set(onnxruntime_HASH "SHA256=7b28a694178d075e6836d618613e2a0fd0046ccd9fd66bbf6a46d22e96db33b8")

# If you don't have access to the Internet,
# please download onnxruntime to one of the following locations.
# You can add more if you want.
set(possible_file_locations
$ENV{HOME}/Downloads/onnxruntime-win-x64-static-1.16.0.tar.bz2
${PROJECT_SOURCE_DIR}/onnxruntime-win-x64-static-1.16.0.tar.bz2
${PROJECT_BINARY_DIR}/onnxruntime-win-x64-static-1.16.0.tar.bz2
/tmp/onnxruntime-win-x64-static-1.16.0.tar.bz2
$ENV{HOME}/Downloads/onnxruntime-win-x64-static_lib-1.16.0.tar.bz2
${PROJECT_SOURCE_DIR}/onnxruntime-win-x64-static_lib-1.16.0.tar.bz2
${PROJECT_BINARY_DIR}/onnxruntime-win-x64-static_lib-1.16.0.tar.bz2
/tmp/onnxruntime-win-x64-static_lib-1.16.0.tar.bz2
)

foreach(f IN LISTS possible_file_locations)
Expand Down Expand Up @@ -57,6 +57,7 @@ message(STATUS "onnxruntime is downloaded to ${onnxruntime_SOURCE_DIR}")
include_directories(${onnxruntime_SOURCE_DIR}/include)

file(GLOB onnxruntime_lib_files "${onnxruntime_SOURCE_DIR}/lib/*.lib")

set(onnxruntime_lib_files ${onnxruntime_lib_files} PARENT_SCOPE)

message(STATUS "onnxruntime lib files: ${onnxruntime_lib_files}")
Expand Down
14 changes: 7 additions & 7 deletions cmake/onnxruntime-win-x86-static.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ if(BUILD_SHARED_LIBS)
message(FATAL_ERROR "This file is for building static libraries. BUILD_SHARED_LIBS: ${BUILD_SHARED_LIBS}")
endif()

set(onnxruntime_URL "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.16.0/onnxruntime-win-x86-static-1.16.0.tar.bz2")
set(onnxruntime_URL2 "https://huggingface.co/csukuangfj/onnxruntime-libs/resolve/main/onnxruntime-win-x86-static-1.16.0.tar.bz2")
set(onnxruntime_HASH "SHA256=aedb6b5275f7832ac5117db8e40328a0842ae8ce6749a0c99bcb4218c53fdc60")
set(onnxruntime_URL "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.16.0/onnxruntime-win-x86-static_lib-1.16.0.tar.bz2")
set(onnxruntime_URL2 "https://huggingface.co/csukuangfj/onnxruntime-libs/resolve/main/onnxruntime-win-x86-static_lib-1.16.0.tar.bz2")
set(onnxruntime_HASH "SHA256=fe78775b222244bbcb512631719a94336391b645edb23c314201a6991ddecb58")

# If you don't have access to the Internet,
# please download onnxruntime to one of the following locations.
# You can add more if you want.
set(possible_file_locations
$ENV{HOME}/Downloads/onnxruntime-win-x86-static-1.16.0.tar.bz2
${PROJECT_SOURCE_DIR}/onnxruntime-win-x86-static-1.16.0.tar.bz2
${PROJECT_BINARY_DIR}/onnxruntime-win-x86-static-1.16.0.tar.bz2
/tmp/onnxruntime-win-x86-static-1.16.0.tar.bz2
$ENV{HOME}/Downloads/onnxruntime-win-x86-static_lib-1.16.0.tar.bz2
${PROJECT_SOURCE_DIR}/onnxruntime-win-x86-static_lib-1.16.0.tar.bz2
${PROJECT_BINARY_DIR}/onnxruntime-win-x86-static_lib-1.16.0.tar.bz2
/tmp/onnxruntime-win-x86-static_lib-1.16.0.tar.bz2
)

foreach(f IN LISTS possible_file_locations)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,7 @@
sherpa-onnx-kaldifst-core.lib;
sherpa-onnx-fst.lib;
kaldi-native-fbank-core.lib;
absl_base.lib;
absl_city.lib;
absl_hash.lib;
absl_low_level_hash.lib;
absl_raw_hash_set.lib;
absl_raw_logging_internal.lib;
absl_throw_delegate.lib;
clog.lib;
cpuinfo.lib;
flatbuffers.lib;
libprotobuf-lite.lib;
onnx.lib;
onnx_proto.lib;
onnxruntime_common.lib;
onnxruntime_flatbuffers.lib;
onnxruntime_framework.lib;
onnxruntime_graph.lib;
onnxruntime_mlas.lib;
onnxruntime_optimizer.lib;
onnxruntime_providers.lib;
onnxruntime_session.lib;
onnxruntime_util.lib;
re2.lib;
onnxruntime.lib;
</SherpaOnnxLibraries>
</PropertyGroup>
<ItemDefinitionGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>Dynamic</UseOfMfc>
<UseOfMfc>Static</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
Expand Down
24 changes: 1 addition & 23 deletions mfc-examples/NonStreamingTextToSpeech/sherpa-onnx-deps.props
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,7 @@
sherpa-onnx-kaldifst-core.lib;
sherpa-onnx-fst.lib;
kaldi-native-fbank-core.lib;
absl_base.lib;
absl_city.lib;
absl_hash.lib;
absl_low_level_hash.lib;
absl_raw_hash_set.lib;
absl_raw_logging_internal.lib;
absl_throw_delegate.lib;
clog.lib;
cpuinfo.lib;
flatbuffers.lib;
libprotobuf-lite.lib;
onnx.lib;
onnx_proto.lib;
onnxruntime_common.lib;
onnxruntime_flatbuffers.lib;
onnxruntime_framework.lib;
onnxruntime_graph.lib;
onnxruntime_mlas.lib;
onnxruntime_optimizer.lib;
onnxruntime_providers.lib;
onnxruntime_session.lib;
onnxruntime_util.lib;
re2.lib;
onnxruntime.lib;
</SherpaOnnxLibraries>
</PropertyGroup>
<ItemDefinitionGroup>
Expand Down
24 changes: 1 addition & 23 deletions mfc-examples/StreamingSpeechRecognition/sherpa-onnx-deps.props
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,7 @@
sherpa-onnx-kaldifst-core.lib;
sherpa-onnx-fst.lib;
kaldi-native-fbank-core.lib;
absl_base.lib;
absl_city.lib;
absl_hash.lib;
absl_low_level_hash.lib;
absl_raw_hash_set.lib;
absl_raw_logging_internal.lib;
absl_throw_delegate.lib;
clog.lib;
cpuinfo.lib;
flatbuffers.lib;
libprotobuf-lite.lib;
onnx.lib;
onnx_proto.lib;
onnxruntime_common.lib;
onnxruntime_flatbuffers.lib;
onnxruntime_framework.lib;
onnxruntime_graph.lib;
onnxruntime_mlas.lib;
onnxruntime_optimizer.lib;
onnxruntime_providers.lib;
onnxruntime_session.lib;
onnxruntime_util.lib;
re2.lib;
onnxruntime.lib;
</SherpaOnnxLibraries>
</PropertyGroup>
<ItemDefinitionGroup>
Expand Down

0 comments on commit 27db015

Please sign in to comment.