How to link lib

Hello,

I try to link a lib to ue4 but it dosen’t works.
I follow this tutorial : link text

My project name is ‘First’ and my lib is MathFuncsLib.
My file First.Build.cs look like :

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

using System.IO;
using UnrealBuildTool;

public class First : 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 First(TargetInfo Target)
	{
		PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" });

        PrivateDependencyModuleNames.AddRange(new string[] { });

        LoadMathFuncsLib(Target);

		// 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");
		//		}
		// }
	}

    public bool LoadMathFuncsLib(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, "MathFuncsLib", "Libraries");

            PublicAdditionalLibraries.Add(Path.Combine(LibrariesPath, "MathFuncsLib." + PlatformString + ".lib"));
        }

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

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

        return isLibrarySupported;
    }
}

Finally my problem become with the point : “Visual Studio 2013 - Linking Our Library”
When I make :

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

#include "First.h"
#include "Welcome/to/MathFuncsLib.h"

IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, First, "First" );

I have this error : error C1083: Cannot open include file: ‘Welcome/to/MathFuncsLib.h’: No such file or directory

Best Regards,

Its very clear… it cant find welcome/to/mathFuncsLib.h in the folder its looking at. I assume your not working in a file structure called YourProject/Source/Private/Welcome/to/MathfFuncsLib.h

The “Third Party Directory” step is where I think you need to play around. You want your libray, following that tutorial to a T to be under yourprojectfolder/ThirdParty/MathFuncsLib/Includes/MathFuncsLib.h THEY HAVE TO BE THE SAME NAME

and again YourProjectFolder/ThirdParty/MathFuncsLib/Libraries/MathFuncLib.x64.lib

Make sure your private string ThirdPartyPath is set to “…/…/…/ThirdParty/” You may need to add or remove …/ 's depending on the structure.

I’d say check your directories and your spelling. Make sure everywhere MathFuncLib is in the tutorial, is where it is in your setup, and spelled correctectly, case sensitive.

Also realize that tutorial was written for 4.4, a quite old version. Alot has changed since then and 4.9 is a little buggy. Try on 4.8 or 4.7. 4.6 I beleive is the closest new version you’ll get to 4.4’s API. Posting in the C++ section on tyhe forums might be what you need for this.

Hope this helps
Don’t forget to accept an answer that best clears your question up or answers it so when the community finds your question in the future via search/google they know exactly what you did to fix it/get it going.

Thx for the reply :slight_smile:

My directories is good and I work on UE4 4.9.

I’m going to test plugin implementation and not third party.