# How to correctly link to 3rd party libraries when cross compiling?

**URL:** <https://forums.unrealengine.com/t/how-to-correctly-link-to-3rd-party-libraries-when-cross-compiling/2057109>\
**Category:** Programming & Scripting\
**Tags:** cross-compiling, unreal-engine, question\
**Created:** [October 7, 2024, 1:22pm UTC](https://forums.unrealengine.com/t/how-to-correctly-link-to-3rd-party-libraries-when-cross-compiling/2057109 "2024-10-07T13:22:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![CyFio](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@CyFio](https://forums.unrealengine.com/u/CyFio)\
**Post date:** [October 7, 2024, 1:22pm UTC](https://forums.unrealengine.com/t/how-to-correctly-link-to-3rd-party-libraries-when-cross-compiling/2057109/1 "2024-10-07T13:22:17Z")

</div>

I am trying to link a cross-platform library to my unreal project. The library has prebuilt librarys in .lib for windows/.so for Linux. Here is the segment where I add the dependencies in Build.cs

```cs
//...
public class MyLibraryPlugin : ModuleRules
{
    public string[] MyLibraryModules => new string[] {
        "core",
    };

	public string[] MyLibrary_Linux_so => new string[] {
		"libMyLibrary_core",
	};
	public string[] MyLibrary_Linux_a => new string[] {
		"libMyLibrary_utils",
	};

    public bool AddMyLibraryDependencies(ReadOnlyTargetRules Target)
    {
        // find MyLibrary package
        // paths
        string MyLibraryHome = Environment.GetEnvironmentVariable("MyLibrary_HOME");
        string MyLibraryIncludePath = Path.Combine(MyLibraryHome, "include");
        string MyLibraryLibPath = Path.Combine(MyLibraryHome, "lib");
        string MyLibraryBinPath = Path.Combine(MyLibraryHome, "bin");
        // include
        Logger.LogInformation("MyLibrary include path: " + MyLibraryIncludePath);
        PublicIncludePaths.AddRange(
            new string[] {
				// the MyLibrary include path is %MyLibrary_HOME%/include
					MyLibraryIncludePath,
                });
        // link libraries
        if (Target.Platform == UnrealTargetPlatform.Win64)
        {

            // static
            foreach (string MyLibraryModule in MyLibraryModules)
            {
                PublicAdditionalLibraries.Add(Path.Combine(MyLibraryLibPath, $"MyLibrary_{MyLibraryModule}.lib"));
            }
            // dynamic
            return true;
        }
		else if (Target.Platform == UnrealTargetPlatform.Linux)
		{
            // static
			foreach (string a in MyLibrary_Linux_a)
			{
				PublicAdditionalLibraries.Add(Path.Combine(MyLibraryLibPath, $"{a}.a"));
			}
            // dynamic
			foreach (string so in MyLibrary_Linux_so)
			{
				RuntimeDependencies.Add(Path.Combine(MyLibraryLibPath, $"{so}.so"));
			}
            return true;
		}

        return false;
    }
    //...

```

When I build the project for windows, it works pretty fine, with whole build process successful and the packaged exe functioning . Howerver, the linker fails to link any symbols associated with that library when cross compling for linux. Whats wrong with it?
