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
//...
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?