Open Sparika opened 11 months ago
The dotnet code to call into the library is :
using System.Runtime.InteropServices;
namespace Demo
{
static class Program
{
[DllImport("demo_rs", CallingConvention = CallingConvention.Cdecl)]
private static extern void hello_world();
static void Main(string[] args)
{
Console.WriteLine("Starting C# code");
hello_world();
}
}
}
Uff, if this is specific to embedding into a .NET binary, then I cannot really add anything. Personally, I would start grepping the NumPy source tree for that error message to understand why NumPy thinks that it was loading from its source tree.
I had this kind of error on OSX when there was a mismatch between the Rust architecture and the Python one.
Hi,
I am building a Rust dynamic library embedding Python using rust-numpy. My project allows me to build a pure Rust binary, a C binary loading the Rust library and a Dotnet binary loading the Rust library. All three scenarios works on Windows but fails on Linux with "Error importing numpy".
The following code built as a cdylib is enough to reproduce the problem when imported into a Dotnet SDK 6.0 or 7.0 program
On Windows, the code succeeds
On Ubuntu, the code fails
The error triggers on import of numpy whether we use Rust PyArray or do a import numpy in Python. Removing references to numpy allows to execute Python code with success. For instance, I can print some informations from within Dotnet > Rust > Python as follows :
Numpy was installed using pip3, but I don't think it has anything to do with my Python setup since the dynamic library works when tested from a C code. It seems the error message may be giving a false indication as to the real cause of the error.
Any help would be greatly appreciated!