Home > Software design >  Using a package from packages.config in C visual studio 2017
Using a package from packages.config in C visual studio 2017

Time:10-10

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 world\n"

    return 0;
}

CodePudding user response:

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#?

CodePudding user response:

OnnxRuntime lib and dll can be found in folder Yourproject\packages\Microsoft.ML.OnnxRuntime.XXX\runtimes\win-x64\native.Header file folder XXX\packages\Microsoft.ML.OnnxRuntime.XXX\build\native\include Try adding them as dependencies.

  • Related