Using 3rd party libraries in cross-platform way

It seems the easiest way is to use compiled libraries with Unreal as opposed to dropping in the source code of the library in the Unreal project. I followed instructions at below page (with few changes) to use compiled version:

Changes required in above instructions:

  1. Use Multithreaded Dynamic Library as opposed to Static Library setting. If you don’t do this then you will get error such as error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj and error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MD_DynamicDebug' in program.obj
  2. Make sure you don’t have _CONSOLE or _DEBUG macros defined in Release build (see C/C++ > Preprocessors tab).
  3. Build both Release and Debug versions of library and put them in Libraries folder. Below is the code in my MyUEProject.Build.cs

Code:

using UnrealBuildTool;
using System.IO;
public class FlyingTest : ModuleRules
{
	private string ModulePath
	{
		get { return ModuleDirectory; }
	}
		 
	private string ThirdPartyPath
	{
		get { return Path.GetFullPath( Path.Combine( ModulePath, "ThirdParty/" ) ); }
	}
	
	public FlyingTest(TargetInfo Target)
	{
		UEBuildConfiguration.bForceEnableExceptions = true;
		PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "RenderCore" });
		
		LoadThirdPartyLibrary(Target, "MavLinkCom");
	}
	
	public bool LoadThirdPartyLibrary(TargetInfo Target, string LibName)
	{
		bool isLibrarySupported = false;

		string LibrariesPath = Path.Combine(ThirdPartyPath, LibName, "Libraries");
		string PlatformString = (Target.Platform == UnrealTargetPlatform.Win64) ? "x64" : "x86";
		string ConfigurationString = (Target.Configuration == UnrealTargetConfiguration.Debug) ? "Debug" : "Release";


		if (Target.Platform == UnrealTargetPlatform.Win64)
		{
			isLibrarySupported = true;
 
			PublicAdditionalLibraries.Add(Path.Combine(LibrariesPath, PlatformString, ConfigurationString, LibName + ".lib")); 
		}
 
		if (isLibrarySupported)
		{
			// Include path
			PublicIncludePaths.Add( Path.Combine( ThirdPartyPath, LibName, "Includes" ) );
		}
 
		Definitions.Add(string.Format( "WITH_" + LibName.ToUpper() + "_BINDING={0}", isLibrarySupported ? 1 : 0 ) );
 
		return isLibrarySupported;
	}	
}