I am developing a code in C++ using as IDEE Visual Studio 2017 on my Windows 10 workstation. I need the onnxruntime
library, so I have installed it by the NuGet package menager. The installation went ok and in my solution I have a folder Resource files
and within it I have the file packages.config
. Its content is:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.ML.OnnxRuntime" version="1.12.1" targetFramework="native" />
</packages>
My main.cpp
is quite simple. It is a simple hello world
where I try to use the installed package. But when I compile, it gives me an error on the using Microsoft.ML.OnnxRuntime;
directive. I have followed the instructions in https://learn.microsoft.com/en-us/nuget/consume-packages/overview-and-workflow.
#include <iostream>
using namespace std;
using Microsoft.ML.OnnxRuntime;
int main()
{
cout<<"Hello worldn"
return 0;
}
2
Answers
You can’t. That package is for .NET C#. You are trying to use a .NET package with C++ (which you can’t)
Perhaps consider switching to C#?
OnnxRuntime lib and dll can be found in folder
YourprojectpackagesMicrosoft.ML.OnnxRuntime.XXXruntimeswin-x64native
.Header file folderXXXpackagesMicrosoft.ML.OnnxRuntime.XXXbuildnativeinclude
Try adding them as dependencies.