cmake 找不到 onnx 运行时库

问题描述 投票:0回答:1

这是我的CMakeLists.txt

cmake_minimum_required(VERSION 3.19)
project(TesteVoxarApp LANGUAGES CXX)

find_package(Qt6 6.5 REQUIRED COMPONENTS Core Widgets LinguistTools)

find_path(ONNX_RUNTIME_SESSION_INCLUDE_DIRS REQUIRED onnxruntime_cxx_api.h HINTS "../../Documentos/onnxruntime-win-x64-gpu-1.20.1/include")
find_library(ONNX_RUNTIME_LIB REQUIRED onnxruntime HINTS "../../Documentos/onnxruntime-win-x64-gpu-1.20.1/lib")

qt_standard_project_setup()

qt_add_executable(TesteVoxarApp
        WIN32 MACOSX_BUNDLE
    main.cpp
    mainwindow.cpp
    mainwindow.h
    mainwindow.ui
)

qt_add_translations(
    TARGETS TesteVoxarApp
    TS_FILES TesteVoxarApp_en_US.ts
)

target_include_directories(TesteVoxarApp
    PRIVATE
        ${ONNX_RUNTIME_SESSION_INCLUDE_DIRS}
)
target_link_libraries(TesteVoxarApp
    PRIVATE
        Qt::Core
        Qt::Widgets
        ${ONNX_RUNTIME_LIB}

)

include(GNUInstallDirs)

install(TARGETS TesteVoxarApp
    BUNDLE  DESTINATION .
    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
)

qt_generate_deploy_app_script(
    TARGET TesteVoxarApp
    OUTPUT_SCRIPT deploy_script
    NO_UNSUPPORTED_PLATFORM_ERROR
)
install(SCRIPT ${deploy_script})

当我使用此代码运行项目时,它加载正常。但是当我尝试在 main.cpp 中调用我的 onnx 库时说: 07:05:50: 启动 C:\Users nge4\OneDrive\Documentos\TesteVoxarApp uild\Desktop_Qt_6_8_1_MSVC2022_64bit-Debug\TesteVoxarApp.exe... 不支持给定版本 [20],此版本仅支持版本 1 到 10。 07:05:51:进程崩溃了。

main.cpp中的代码:

#include "mainwindow.h"

#include <QApplication>
#include <QLocale>
#include <QTranslator>
#include "onnxruntime_cxx_api.h"

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    Ort::Env env(ORT_LOGGING_LEVEL_WARNING, "ONNXRuntime");


    QTranslator translator;
    const QStringList uiLanguages = QLocale::system().uiLanguages();
    for (const QString &locale : uiLanguages) {
        const QString baseName = "TesteVoxarApp_" + QLocale(locale).name();
        if (translator.load(":/i18n/" + baseName)) {
            a.installTranslator(&translator);
            break;
        }
    }
    MainWindow w;
    w.show();
    return a.exec();
}

代码中没有问题或错误下划线。有人可以帮忙吗?

qt pytorch onnx onnxruntime
1个回答
0
投票

我也遇到了同样的问题,结果是实际的 DLL 不在路径中。

尝试使用自定义目标将它们复制到输出目录。

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.