From 06ca4e0be62a51f2f1acddcad94d29fe2ef29d59 Mon Sep 17 00:00:00 2001
From: Xu <34770031+Blinue@users.noreply.github.com>
Date: Sun, 10 Mar 2024 14:52:22 +0800
Subject: [PATCH] =?UTF-8?q?chore:=20=E4=BE=9D=E8=B5=96=20dll=20=E7=A7=BB?=
=?UTF-8?q?=E5=88=B0=20third=5Fparty=20=E6=96=87=E4=BB=B6=E5=A4=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/Common.Post.props | 28 +++++++++++++++++++---------
src/Magpie.App/Magpie.App.vcxproj | 1 +
src/Magpie/main.cpp | 19 +++++++++++++------
3 files changed, 33 insertions(+), 15 deletions(-)
diff --git a/src/Common.Post.props b/src/Common.Post.props
index 8b680372c..5406f6303 100644
--- a/src/Common.Post.props
+++ b/src/Common.Post.props
@@ -48,15 +48,25 @@
-
-
-
- C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.2\include;S:\TensorRT-8.6.1.6\include;%(AdditionalIncludeDirectories)
-
-
- C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.2\lib\x64;S:\TensorRT-8.6.1.6\lib;%(AdditionalLibraryDirectories)
-
-
+
+
+
+ C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.2\include;S:\TensorRT-8.6.1.6\include;%(AdditionalIncludeDirectories)
+
+
+ C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.2\lib\x64;S:\TensorRT-8.6.1.6\lib;%(AdditionalLibraryDirectories)
+
+
+
+
+
+
+
+
+ third_party\%(FileName)%(Extension)
+
+
+
diff --git a/src/Magpie.App/Magpie.App.vcxproj b/src/Magpie.App/Magpie.App.vcxproj
index 2e0bbf0b3..4eb959ff2 100644
--- a/src/Magpie.App/Magpie.App.vcxproj
+++ b/src/Magpie.App/Magpie.App.vcxproj
@@ -62,6 +62,7 @@
Console
kernel32.lib;ole32.lib;oleaut32.lib;user32.lib;gdi32.lib;$(OutDir).\Magpie.Core.lib;%(AdditionalDependencies)
Magpie.App.def
+ d3d12.dll;cudart64_12.dll;onnxruntime.dll;DirectML.dll
diff --git a/src/Magpie/main.cpp b/src/Magpie/main.cpp
index 782445414..4a7262a28 100644
--- a/src/Magpie/main.cpp
+++ b/src/Magpie/main.cpp
@@ -19,19 +19,22 @@
#include "StrUtils.h"
// 将当前目录设为程序所在目录
-static void SetCurDir() noexcept {
- wchar_t curDir[MAX_PATH] = { 0 };
- GetModuleFileName(NULL, curDir, MAX_PATH);
+static std::wstring SetCurDir() noexcept {
+ std::wstring curDir(MAX_PATH, L'\0');
+ curDir.resize(GetModuleFileName(NULL, curDir.data(), MAX_PATH));
- for (int i = (int)StrUtils::StrLen(curDir) - 1; i >= 0; --i) {
+ int i = (int)curDir.size() - 1;
+ for (; i >= 0; --i) {
if (curDir[i] == L'\\' || curDir[i] == L'/') {
break;
} else {
curDir[i] = L'\0';
}
}
+ curDir.resize(i);
- SetCurrentDirectory(curDir);
+ SetCurrentDirectory(curDir.c_str());
+ return curDir;
}
int APIENTRY wWinMain(
@@ -51,7 +54,11 @@ int APIENTRY wWinMain(
// 见 https://kennykerr.ca/2018/03/24/cppwinrt-hosting-the-windows-runtime/
winrt::init_apartment(winrt::apartment_type::single_threaded);
- SetCurDir();
+ std::wstring curDir = SetCurDir();
+
+ SetDefaultDllDirectories(LOAD_LIBRARY_SEARCH_DEFAULT_DIRS);
+ curDir += L"\\third_party";
+ AddDllDirectory(curDir.c_str());
auto& app = Magpie::XamlApp::Get();
if (!app.Initialize(hInstance, lpCmdLine)) {