I have a simple program in C# that uses OR-Tools 9.2.9972 on Ubuntu 21.04 but even after copying the shared libraries into the bin
folder, it returns that the library was unable to be loaded. I tried the command dotnet add package
but the error remains.
Unable to load shared library ‘google-ortools-native’ or one of its dependencies.
Any idea how to add these shared libraries into the project?
using System;
using Google.OrTools.LinearSolver;
public class SimpleLpProgram
{
static void Main()
{
Console.WriteLine("Starting");
Solver solver = Solver.CreateSolver("GLOP"); // linking error
Variable x = solver.MakeNumVar(0.0, double.PositiveInfinity, "x");
}
}
Project file
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<LangVersion>8.0</LangVersion>
<TargetFrameworks>net6.0</TargetFrameworks>
<EnableDefaultItems>false</EnableDefaultItems>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<!-- see https://github.com/dotnet/docs/issues/12237 -->
<RollForward>LatestMajor</RollForward>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<AssemblyName>Google.OrTools.SimpleLpProgram</AssemblyName>
<Version>9.2.9972</Version>
<!-- Nuget Properties -->
<Description>Simple App consuming Google.OrTools package</Description>
<!-- Pack Option -->
<IsPackable>true</IsPackable>
<Title>Google.OrTools.SimpleLpProgram v9.2.9972</Title>
<PackageId>Google.OrTools.SimpleLpProgram</PackageId>
<PackageTags>sample</PackageTags>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<!-- Signing -->
<SignAssembly>false</SignAssembly>
<PublicSign>false</PublicSign>
<DelaySign>false</DelaySign>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugType>full</DebugType>
<Optimize>true</Optimize>
<GenerateTailCalls>true</GenerateTailCalls>
</PropertyGroup>
<!-- Dependencies -->
<PropertyGroup>
<RestoreSources>../../../packages;$(RestoreSources);https://api.nuget.org/v3/index.json</RestoreSources>
</PropertyGroup>
<ItemGroup>
<Compile Include="SimpleLpProgram.cs" />
<PackageReference Include="Google.OrTools" Version="9.2.9972" />
<PackageReference Include="Google.OrTools.runtime.linux-x64" Version="9.2.9972" />
</ItemGroup>
</Project>