rodrigo
rodrigo

Reputation: 68

cmake cant find onnx runtime lib

Here is myCMakeLists.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})

When i run the project with this code it loads fine. But when i try to call my onnx library in main.cpp says: 07:05:50: Starting C:\Users\ange4\OneDrive\Documentos\TesteVoxarApp\build\Desktop_Qt_6_8_1_MSVC2022_64bit-Debug\TesteVoxarApp.exe... The given version [20] is not supported, only version 1 to 10 is supported in this build. 07:05:51: The process crashed.

Code in 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();
}

There is no issue or error underline in code. Can anyone help?

Upvotes: 0

Views: 41

Answers (1)

Daniel Belokon
Daniel Belokon

Reputation: 1

I've had the same issue, turned out the actual DLLs weren't in the path.

Try copying them to the output directory with a custom target.

Upvotes: 0

Related Questions