Download

Linking static libraries on Mac

Hello,

I found an inconsistent behavior when trying to compile and link my project on Mac: the PublicLibraryPaths seems to not work correctly as it does on the windows build and I have to specify the full path to my libs instead of being able to rely on the PublicLibraryPaths.

For instance I am linking Kiss_FFT statically and here is the corresponding Build.cs file:


using System.IO;
using UnrealBuildTool;

public class Kiss_FFT : ModuleRules
{
    private string Kiss_FFTPath
    {
        get { return Path.GetDirectoryName(RulesCompiler.GetModuleFilename(this.GetType().Name)) + "/kiss_fft129"; }
    }

	public Kiss_FFT(TargetInfo Target)
	{
		Type = ModuleType.External;

		Definitions.Add("WITH_KISSFFT=1");

		// Compile and link with kissFFT

		PublicIncludePaths.Add(Kiss_FFTPath);
                PublicIncludePaths.Add(Kiss_FFTPath + "/tools");

		if (Target.Platform == UnrealTargetPlatform.Win64)
		{
			if (Target.Configuration == UnrealTargetConfiguration.Debug && BuildConfiguration.bDebugBuildsActuallyUseDebugCRT)
			{
				PublicLibraryPaths.Add(Kiss_FFTPath + "/lib/x64/Debug");
			}
			else
			{
				PublicLibraryPaths.Add(Kiss_FFTPath + "/lib/x64/Release");
			}

			PublicAdditionalLibraries.Add("KissFFT.lib");
		}
		else if (Target.Platform == UnrealTargetPlatform.Mac)
		{
			if (Target.Configuration == UnrealTargetConfiguration.Debug && BuildConfiguration.bDebugBuildsActuallyUseDebugCRT)
			{
				PublicAdditionalLibraries.Add(Kiss_FFTPath + "/Lib/Mac/Debug/libKissFFT.a");
			}
			else
			{
				PublicAdditionalLibraries.Add(Kiss_FFTPath + "/Lib/Mac/Release/libKissFFT.a");
			}
		}
	}
}


And in MyProject.build.cs



PrivateDependencyModuleNames.AddRange(new string] { "Kiss_FFT", "OtherExternalModule" });


You can see that on the mac platform I have not been able to apply the same pattern as I did on Windows. Instead I had to supply the full path to PublicAdditionalLibraries. When I try it I get the following error, suggesting that the PublicLibraryPaths has not properly resolved my lib’s location and is instead looking in the engine’s install directory for the lib.

Is this a known issue, or is this supposed to not be supported on Mac ?
Any help with the unreal build tool is greatly appreciated.