Download

Has anybody been successful using libnoise in UE4?

Hi,

so I am trying to use libnoise inside my UE4 project. I tried settings up the UBT stuff like explained in this Wiki Page:

I used the .lib file you can find on the website of libnoise and added the includes. Everything as mentioned in the above tutorial.

However, when I try to compile, I still get linker problems:



Error	11	error : Failed to produce item: C:\Users\Christian\Documents\Unreal Projects\UE4ProceduralMesh\Binaries\Win64\UE4Editor-ProceduralMesh.dll	C:\Users\Christian\Documents\Unreal Projects\UE4ProceduralMesh\Intermediate\ProjectFiles\ERROR	ProceduralMesh
Error	10	error LNK1120: 3 unresolved externals	C:\Users\Christian\Documents\Unreal Projects\UE4ProceduralMesh\Binaries\Win64\UE4Editor-ProceduralMesh.dll	1	1	ProceduralMesh
Error	8	error LNK2019: unresolved external symbol "public: __cdecl noise::module::Perlin::Perlin(void)" (??0Perlin@module@noise@@QEAA@XZ) referenced in function "public: __cdecl AGameGeneratedActor::AGameGeneratedActor(class FPostConstructInitializeProperties const &)" (??0AGameGeneratedActor@@QEAA@AEBVFPostConstructInitializeProperties@@@Z)	C:\Users\Christian\Documents\Unreal Projects\UE4ProceduralMesh\Intermediate\ProjectFiles\GameGeneratedActor.cpp.obj	ProceduralMesh
Error	7	error LNK2019: unresolved external symbol "public: virtual __cdecl noise::module::Module::~Module(void)" (??1Module@module@noise@@UEAA@XZ) referenced in function "public: __cdecl AGameGeneratedActor::AGameGeneratedActor(class FPostConstructInitializeProperties const &)" (??0AGameGeneratedActor@@QEAA@AEBVFPostConstructInitializeProperties@@@Z)	C:\Users\Christian\Documents\Unreal Projects\UE4ProceduralMesh\Intermediate\ProjectFiles\GameGeneratedActor.cpp.obj	ProceduralMesh
Error	9	error LNK2019: unresolved external symbol "public: virtual double __cdecl noise::module::Perlin::GetValue(double,double,double)const " (?GetValue@Perlin@module@noise@@UEBANNNN@Z) referenced in function "public: __cdecl AGameGeneratedActor::AGameGeneratedActor(class FPostConstructInitializeProperties const &)" (??0AGameGeneratedActor@@QEAA@AEBVFPostConstructInitializeProperties@@@Z)	C:\Users\Christian\Documents\Unreal Projects\UE4ProceduralMesh\Intermediate\ProjectFiles\GameGeneratedActor.cpp.obj	ProceduralMesh
Error	12	error MSB3073: The command ""D:\dev\Unreal Engine 4\Unreal Engine\4.4\Engine\Build\BatchFiles\Build.bat" ProceduralMeshEditor Win64 Development "C:\Users\Christian\Documents\Unreal Projects\UE4ProceduralMesh\ProceduralMesh.uproject" -rocket" exited with code -1.	C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.MakeFile.Targets	38	5	ProceduralMesh


This is how my build.cs file looks:





using UnrealBuildTool;
using System.IO;

public class ProceduralMesh : ModuleRules
{
    private string ModulePath
    {
        get { return Path.GetDirectoryName(RulesCompiler.GetModuleFilename(this.GetType().Name)); }
    }

    private string ThirdPartyPath
    {
        get { return Path.GetFullPath(Path.Combine(ModulePath, "../../ThirdParty/")); }
    }
    
    public ProceduralMesh(TargetInfo Target)
	{
		PublicDependencyModuleNames.AddRange(new string] { "Core", "CoreUObject", "Engine", "InputCore" });

		PrivateDependencyModuleNames.AddRange(new string] { "RHI", "RenderCore", "ShaderCore" });


		// Uncomment if you are using Slate UI
		// PrivateDependencyModuleNames.AddRange(new string] { "Slate", "SlateCore" });
		
		// Uncomment if you are using online features
		// PrivateDependencyModuleNames.Add("OnlineSubsystem");
		// if ((Target.Platform == UnrealTargetPlatform.Win32) || (Target.Platform == UnrealTargetPlatform.Win64))
		// {
		//		if (UEBuildConfiguration.bCompileSteamOSS == true)
		//		{
		//			DynamicallyLoadedModuleNames.Add("OnlineSubsystemSteam");
		//		}
		// }

        LoadLibNoise(Target);
	}
    public bool LoadLibNoise(TargetInfo Target)
    {
        bool isLibrarySupported = false;

        if ((Target.Platform == UnrealTargetPlatform.Win64) || (Target.Platform == UnrealTargetPlatform.Win32))
        {
            isLibrarySupported = true;

            string LibrariesPath = Path.Combine(ThirdPartyPath, "LibNoise", "Libraries");

            PublicAdditionalLibraries.Add(Path.Combine(LibrariesPath, "libnoise.lib"));
        }

        if (isLibrarySupported)
        {
            // Include path
            PublicIncludePaths.Add(Path.Combine(ThirdPartyPath, "LibNoise", "Includes"));
        }

        Definitions.Add(string.Format("WITH_LIB_NOISE_BINDING={0}", isLibrarySupported ? 1 : 0));

        return isLibrarySupported;
    }

}



As far as I can tell, with my little C# knowledge, everything looks fine, and UBT is not complaining about files that cannot be found.

I also added the includes files to my VS2013 Project Settings, but if I understand correctly, UBT does not really care about those, right?

I also tried to compile libnoise on my own but couldnt get it to work with VS2013.

Any help would be highly appreciated.

As far as I know, you can’t use libs compiled in another compiler or even another version of VS compiler. So you must compile your lib


PublicIncludePaths.Add(Path.Combine(ThirdPartyPath, "LibNoise", "Includes")); 

this line adds all lib related includes.

What errors do you receive?

I’ve also been trying to get libnoise working inside of UE4. Followed the same steps as Brainshack

I also rebuild Libnoise for 64bit in VS2013


// Fill out your copyright notice in the Description page of Project Settings.

// https://wiki.unrealengine.com/Linking_Static_Libraries_Using_The_Build_System

using UnrealBuildTool;
using System.IO;
using System;

public class ELE : ModuleRules
{
    private string ModulePath
    {
        get { return Path.GetDirectoryName(RulesCompiler.GetModuleFilename(this.GetType().Name)); }
    }

    private string ThirdPartyPath
    {
        get { return Path.GetFullPath(Path.Combine(ModulePath, "../../ThirdParty/")); }
    }

	public ELE(TargetInfo Target)
	{
		PublicDependencyModuleNames.AddRange(new string] { "Core", "CoreUObject", "Engine", "InputCore" });

		PrivateDependencyModuleNames.AddRange(new string] {  });

		// Uncomment if you are using Slate UI
		// PrivateDependencyModuleNames.AddRange(new string] { "Slate", "SlateCore" });
		
		// Uncomment if you are using online features
		// PrivateDependencyModuleNames.Add("OnlineSubsystem");
		// if ((Target.Platform == UnrealTargetPlatform.Win32) || (Target.Platform == UnrealTargetPlatform.Win64))
		// {
		//		if (UEBuildConfiguration.bCompileSteamOSS == true)
		//		{
		//			DynamicallyLoadedModuleNames.Add("OnlineSubsystemSteam");
		//		}
		// }

        LoadLibnoise(Target);
	}

    public bool LoadLibnoise(TargetInfo Target)
    {
        bool isLibrarySupported = false;

        if ((Target.Platform == UnrealTargetPlatform.Win64) || (Target.Platform == UnrealTargetPlatform.Win32))
        {
            isLibrarySupported = true;

            string PlatformString = (Target.Platform == UnrealTargetPlatform.Win64) ? "x64" : "x86";
            string LibrariesPath = Path.Combine(ThirdPartyPath, "Libnoise", "Libraries");

            Console.WriteLine(Path.Combine(LibrariesPath, "libnoise.lib")); 
            //PublicAdditionalLibraries.Add(Path.Combine(LibrariesPath, "Libnoise." + PlatformString + ".lib"));
            PublicAdditionalLibraries.Add(Path.Combine(LibrariesPath, "libnoise.lib"));
            //PublicAdditionalLibraries.Add(Path.Combine(LibrariesPath, "libnoise.dll"));
        }

        if (isLibrarySupported)
        {
            Console.WriteLine(Path.Combine(ThirdPartyPath, "Libnoise", "Includes")); 
            // Include path
            PublicIncludePaths.Add(Path.Combine(ThirdPartyPath, "Libnoise", "Includes"));
        }

        Definitions.Add(string.Format("WITH_LIB_NOISE_BINDING={0}", isLibrarySupported ? 1 : 0));

        return isLibrarySupported;
    }
}



In one of my classes:


// Fill out your copyright notice in the Description page of Project Settings.

#include "Project.h"
#include "MyActor.h"

#include <iostream>
#include <noise.h>

using namespace noise;


// Sets default values
AMyActor::AMyActor()
{
 	// Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;

}

// Called when the game starts or when spawned
void AMyActor::BeginPlay()
{
	Super::BeginPlay();
	
}

// Called every frame
void AMyActor::Tick( float DeltaTime )
{
	Super::Tick( DeltaTime );
}

void AMyActor::ActivateSunShine( float something )
{
	//module::Perlin myModule;
	noise::module::Perlin myModule;


	double value = myModule.GetValue(1.25, 0.75, 0.50);
	//UE_LOG(LogTemp, Warning, TEXT(value));
}


Output when trying to build the solution:

It can’t find libnoise.dll (I put mine in /Binaries/Win32/ and it was happy).

Don’t forget to copy the model and module subfolders from the libnoise src directory to /ThirdParty/LibNoise/Includes as well (only need the .h files inside them though).

And last of all, I took out the “using namespace noise” line as it was causing ambiguous symbol definition errors, even with #include “AllowWindowsPlatformTypes.h” and #include “HideWindowsPlatformTypes.h” either side of the noise.h include.

(which I just learned about here: Trouble using windows includes with DWORD, INT.. - UE4 AnswerHub)

I haven’t had a chance to test it properly though, this is just with your example code above where you instantiate a perlin noise module.

I should probably also mention that I built libnoise as a 32 bit build because there was no 64 bit option in the project configuration options in VS2013 and I don’t know how to add it :slight_smile:

Bummer, bad news sorry.

Got home and can’t get it to work on my laptop installation of Unreal no matter what I try… (including all the above).

A few years later: