Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question DllNotFoundException but I have the dll?

Discussion in 'Scripting' started by Aimi64, Jul 9, 2023.

  1. Aimi64

    Aimi64

    Joined:
    Jan 23, 2023
    Posts:
    1
    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: https://github.com/Auburn/FastNoise2
    FastNoise2 C# Bindings: https://github.com/Auburn/FastNoise2Bindings

    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:
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using Quixel;
    5.  
    6. public class HoshiTerrain : MonoBehaviour, IGenerator
    7. {
    8.     float mult = 0.05f;
    9.     FastNoise Surface = FastNoise.FromEncodedNodeTree("JQDNzMw9AACAP83MzD0AAIA/FAAEAAAAAAAAAKBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABDQADAAAAAACAQCcAAQAAAAkAAM3MTD4AAAAAvwAAAAAAAAAAAAA=");
    10.  
    11.     public VoxelData calculateDensity(Vector3 position)
    12.     {
    13.         float density = Surface.GenSingle3D(position.x * mult, position.y * mult, position.z * mult, 64);
    14.  
    15.         VoxelData voxel = new VoxelData();
    16.  
    17.         voxel.density += density;
    18.  
    19.         return voxel;
    20.     }
    21. }
    22.  
    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.
     
  2. Bunny83

    Bunny83

    Joined:
    Oct 18, 2010
    Posts:
    3,495
    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.
     
    Last edited: Jul 10, 2023
    Aimi64 and KillDashNine like this.