DllNotFoundException but I have the dll?

I am getting a DllNotFoundException error while working on my project which uses the FastNoise2 library’s C# bindings. It’s very important that I use this library since I need very fast and efficient noise for my game’s terrain generator.

I recently switched over to Linux (Manjaro) and I am remaking a previous terrain generator from scratch. I believe it worked fine while I was on Windows, but now it seems it can no longer detect the dll for whatever reason. I do not have much experience with dll files so this is relatively new to me.

Editor version: 2023.1.3f1

Error:

DllNotFoundException: FastNoise assembly:<unknown assembly> type:<unknown type> member:(null)
FastNoise..cctor () (at Assets/_Packages/FastNoise2/FastNoise2.cs:283)

FastNoise2: GitHub - Auburn/FastNoise2: Modular node graph based noise generation library using SIMD, C++17 and templates
FastNoise2 C# Bindings: GitHub - Auburn/FastNoise2Bindings: Bindings for FastNoise2 noise generation library

I have moved around the files in the C# bindings slightly, just moving the dll file to the CSharp folder and deleting the test, but I tried restoring it to the original layout and that also doesn’t work.

The current layout:
FastNoise2.cs
FastNoise.dll

The script accessing it:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Quixel;

public class HoshiTerrain : MonoBehaviour, IGenerator
{
    float mult = 0.05f;
    FastNoise Surface = FastNoise.FromEncodedNodeTree("JQDNzMw9AACAP83MzD0AAIA/FAAEAAAAAAAAAKBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABDQADAAAAAACAQCcAAQAAAAkAAM3MTD4AAAAAvwAAAAAAAAAAAAA=");

    public VoxelData calculateDensity(Vector3 position)
    {
        float density = Surface.GenSingle3D(position.x * mult, position.y * mult, position.z * mult, 64);

        VoxelData voxel = new VoxelData();

        voxel.density += density;

        return voxel;
    }
}

File path if that makes any difference:
Assets/_Project/Code/Scripts/Terrain/Generator/HoshiTerrain.cs

You can see FastNoise2.cs in the C# bindings repository as well as the dll file if needed. I have not edited it.

Also, if there is some issue with using the dll, how should I use the library without it? I have never used a C++ library with C# so I do not have much experience with this.

Uhm, you do know that native libraries are not cross platform, right? A native windows DLL will only work on windows. You need the linux version of that library. Usually such libraries have the extension “.so” (shared object) which is the equivalent of a dll on linux. However linux doesn’t really care about extensions That github page seems to offer precompiled versions for different platforms. Expand the “Assets” in a release to see the files. In the linux builds inside the bin folder you should find the actual library.

ps: Make sure you place native code libraries inside the plugins folder inside the Assets folder and check the import settings as you can / have to select for which platforms a certain plugin should be used or not.

2 Likes