Interactml / iml-unreal

55 stars 18 forks source link

Linux Support #10

Open jerobarraco opened 2 years ago

jerobarraco commented 2 years ago

First let me thank you for making such amazing plugin and making it open source. and also using opensource libraries. Also i think rapidLib was an excellent choice.

I want to run this on linux (ue5). currently i can´t because it can´t compile the plugin.

[1/8] Compile Module.InteractML.cpp In file included from /home/nande/work/uep/tdai/Plugins/InteractML/Intermediate/Build/Linux/B4D820EA/UnrealEditor/Development/InteractML/Module.InteractML.cpp:2: In file included from /home/nande/work/uep/tdai/Plugins/InteractML/Source/InteractML/Private/InteractML.cpp:7: In file included from /home/nande/work/uep/tdai/Plugins/InteractML/Source/InteractML/Public/InteractML.h:18: /home/nande/work/uep/tdai/Plugins/InteractML/Source/InteractML/Public/InteractMLTask.h:16:10: fatal error: 'rapidLib.h' file not found

include "rapidLib.h"

it says it cant find that library. but i checked and is there. seems like the build.cs file doesn t include on linux but im not confident enough to do it myself.

i did however download rapidLib from github and compiled with cmake on a different folder and it worked. so i hope this will work too.

log.txt

jerobarraco commented 2 years ago

ive added this chunk to InteractML.Build.cs at line 110

    if((Target.Platform==UnrealTargetPlatform.Linux) /*|| (Target.Platform==UnrealTargetPlatform.Win32)*/)
        {
            //platform variants
            string platform_string;
            if(Target.Platform==UnrealTargetPlatform.Linux)
            {
                platform_string = "x64";
            }
            else
            {
                throw new System.ApplicationException("Unsupported RapidLib build target platform "+Target.Platform );
            }

            //configuration
            string config_string; //shipping/test has none
            switch(Target.Configuration)
            {
                case UnrealTargetConfiguration.Debug:
                case UnrealTargetConfiguration.DebugGame:
                    //full debug can't currently be supported (Unreal still links the release CRT)
                    //instead, the debug build uses release CRL but is still unoptimised
                case UnrealTargetConfiguration.Development:
                    config_string = "Debug";
                    break;
                case UnrealTargetConfiguration.Shipping:
                    config_string = "Release";
                    break;
                default:
                    throw new System.ApplicationException("Unsupported RapidLib build configuration "+Target.Configuration );
            }

            //narrow down location
            lib_dir = Path.Combine( lib_dir, platform_string, config_string );
            is_lib_supported = true;
        }
jerobarraco commented 2 years ago

I got this error which i got rid by deleting the ascii art on the header


In file included from /home/nande/work/uep/tdai/Plugins/InteractML/Intermediate/Build/Linux/B4D820EA/UnrealEditor/Development/InteractMLScripting/Module.InteractMLScripting.cpp:2:
In file included from /home/nande/work/uep/tdai/Plugins/InteractML/Source/InteractMLScripting/Private/InteractMLExternalModelNode.cpp:21:
In file included from /home/nande/work/uep/tdai/Plugins/InteractML/Source/InteractML/Public/InteractMLModel.h:20:
In file included from /home/nande/work/uep/tdai/Plugins/InteractML/Source/InteractML/Public/InteractMLTask.h:16:
/home/nande/work/uep/tdai/Plugins/InteractML/Source/3rdParty/RapidLib/src/rapidLib.h:14:42: error: backslash and newline separated by space [-Werror,-Wbackslash-newline-escape]
// | '__/ _` | '_ \| |/ _` | |    | | '_ \
jerobarraco commented 2 years ago

But now i have this and have no idea


[1/8] Compile Module.InteractML.cpp
In file included from /home/nande/work/uep/tdai/Plugins/InteractML/Intermediate/Build/Linux/B4D820EA/UnrealEditor/Development/InteractML/Module.InteractML.cpp:2:
/home/nande/work/uep/tdai/Plugins/InteractML/Source/InteractML/Private/InteractML.cpp:13:10: fatal error: 'HAL/PlatformFilemanager.h' file not found
#include "HAL/PlatformFilemanager.h"

that file exists under /home/nande/work/UE5/Engine/Source/Runtime/Core/Public/HAL which is the engine. but i dont know whats the appropriate way to add it to the include list

jerobarraco commented 2 years ago

Linux is case sensitive so i had to fix this import in these files (notice uppercase M)

include "HAL/PlatformFileManager.h"

/home/nande/work/uep/tdai/Plugins/InteractML/Source/InteractML/Private/InteractML.cpp

include "Models/InteractMLDynamicTimeWarpModel.h" (uppercase W)

/home/nande/work/uep/tdai/Plugins/InteractML/Source/InteractMLEditor/Private/InteractMLModelActions.cpp /home/nande/work/uep/tdai/Plugins/InteractML/Source/InteractMLEditor/Private/InteractMLModelFactory.cpp

jerobarraco commented 2 years ago

Then i got a bunch of errors linking so i had to download rapidlib from github (used this one https://github.com/mzed/RapidLib not sure if its correct) compiled with cmake . then make then copied the .so here /home/nande/work/uep/tdai/Plugins/InteractML/Source/3rdParty/RapidLib/lib/x64/librapidLib.so

i tried compiling the .a by myself with the command below but the results where the same ar rcs librapidLib.a /home/nande/work/uep/RapidLib/CMakeFiles/rapidLib.dir/src/classification.cpp.o /home/nande/work/uep/RapidLib/CMakeFiles/rapidLib.dir/src/dtw.cpp.o /home/nande/work/uep/RapidLib/CMakeFiles/rapidLib.dir/src/fastDTW.cpp.o /home/nande/work/uep/RapidLib/CMakeFiles/rapidLib.dir/src/knnClassification.cpp.o /home/nande/work/uep/RapidLib/CMakeFiles/rapidLib.dir/src/modelSet.cpp.o /home/nande/work/uep/RapidLib/CMakeFiles/rapidLib.dir/src/neuralNetwork.cpp.o /home/nande/work/uep/RapidLib/CMakeFiles/rapidLib.dir/src/rapidStream.cpp.o /home/nande/work/uep/RapidLib/CMakeFiles/rapidLib.dir/src/regression.cpp.o /home/nande/work/uep/RapidLib/CMakeFiles/rapidLib.dir/src/searchWindow.cpp.o /home/nande/work/uep/RapidLib/CMakeFiles/rapidLib.dir/src/seriesClassification.cpp.o /home/nande/work/uep/RapidLib/CMakeFiles/rapidLib.dir/src/svmClassification.cpp.o /home/nande/work/uep/RapidLib/CMakeFiles/rapidLib.dir/src/warpPath.cpp.o /home/nande/work/uep/RapidLib/CMakeFiles/rapidLib.dir/dependencies/bayesfilter/src/BayesianFilter.cpp.o /home/nande/work/uep/RapidLib/CMakeFiles/rapidLib.dir/dependencies/bayesfilter/src/filter_utilities.cpp.o /home/nande/work/uep/RapidLib/CMakeFiles/rapidLib.dir/dependencies/libsvm/libsvm.cpp.o /home/nande/work/uep/RapidLib/CMakeFiles/rapidLib.dir/dependencies/jsoncpp.cpp.o and added this to the .build.cs


if(is_lib_supported)
        {
            string lib_path = Path.Combine( lib_dir, "RapidLib.lib" );

            if((Target.Platform==UnrealTargetPlatform.Linux)) {
                lib_path = Path.Combine( lib_dir, "librapidLib.so" );

                PublicAdditionalLibraries.Add( "/usr/lib/gcc/x86_64-linux-gnu/11/libstdc++.a" );
                // PublicAdditionalLibraries.Add( "/usr/lib/x86_64-linux-gnu/libc.a" );

            }
            PublicAdditionalLibraries.Add( lib_path );
            PublicIncludePaths.Add( include_dir );
        }
jerobarraco commented 2 years ago

but i got this error,

`[1/4] Link (lld) libUnrealEditor-InteractML.so ld.lld: error: undefined symbol: modelSet::putJSON(std::1::basic_string<char, std::__1::char_traits, std::1::allocator > const&)

referenced by InteractMLModel.cpp:75 (/home/nande/work/uep/tdai/Plugins/InteractML/Source/InteractML/Private/InteractMLModel.cpp:75) /home/nande/work/uep/tdai/Plugins/InteractML/Intermediate/Build/Linux/B4D820EA/UnrealEditor/Development/InteractML/Module.InteractML.cpp.o:(UInteractMLModel::LoadJson(FName, FString const&))

ld.lld: error: undefined symbol: modelSet::getJSON()

referenced by InteractMLModel.cpp:101 (/home/nande/work/uep/tdai/Plugins/InteractML/Source/InteractML/Private/InteractMLModel.cpp:101) /home/nande/work/uep/tdai/Plugins/InteractML/Intermediate/Build/Linux/B4D820EA/UnrealEditor/Development/InteractML/Module.InteractML.cpp.o:(UInteractMLModel::SaveJson(FName, FString&) const)

ld.lld: error: undefined symbol: modelSet::run(std::1::vector<float, std::1::allocator > const&)

referenced by InteractMLModel.cpp:426 (/home/nande/work/uep/tdai/Plugins/InteractML/Source/InteractML/Private/InteractMLModel.cpp:426) /home/nande/work/uep/tdai/Plugins/InteractML/Intermediate/Build/Linux/B4D820EA/UnrealEditor/Development/InteractML/Module.InteractML.cpp.o:(UInteractMLModel::DoRunningModel(TSharedPtr<FInteractMLTask, (ESPMode)1>))

ld.lld: error: undefined symbol: seriesClassificationTemplate::run(std::1::vector<std::1::vector<float, std::1::allocator >, std::1::allocator<std::1::vector<float, std::1::allocator > > > const&)

referenced by InteractMLDynamicTimeWarpModel.cpp:80 (/home/nande/work/uep/tdai/Plugins/InteractML/Source/InteractML/Private/Models/InteractMLDynamicTimeWarpModel.cpp:80) /home/nande/work/uep/tdai/Plugins/InteractML/Intermediate/Build/Linux/B4D820EA/UnrealEditor/Development/InteractML/Module.InteractML.cpp.o:(UInteractMLDynamicTimeWarpModel::DoRunningModel(TSharedPtr<FInteractMLTask, (ESPMode)1>))

ld.lld: error: undefined symbol: seriesClassificationTemplate::train(std::1::vector<trainingSeriesTemplate, std::1::allocator<trainingSeriesTemplate > > const&)

referenced by InteractMLDynamicTimeWarpModel.cpp:193 (/home/nande/work/uep/tdai/Plugins/InteractML/Source/InteractML/Private/Models/InteractMLDynamicTimeWarpModel.cpp:193) /home/nande/work/uep/tdai/Plugins/InteractML/Intermediate/Build/Linux/B4D820EA/UnrealEditor/Development/InteractML/Module.InteractML.cpp.o:(UInteractMLDynamicTimeWarpModel::ApplyExamples())

ld.lld: error: undefined symbol: __libc_single_threaded

referenced by guard.o:(cxa_guard_acquire) in archive /usr/lib/gcc/x86_64-linux-gnu/11/libstdc++.a referenced by guard.o:(__cxa_guard_abort) in archive /usr/lib/gcc/x86_64-linux-gnu/11/libstdc++.a referenced by guard.o:(cxa_guard_release) in archive /usr/lib/gcc/x86_64-linux-gnu/11/libstdc++.a referenced 25 more times

ld.lld: error: undefined symbol: __cxa_thread_atexit_impl

referenced by atexit_thread.o:(__cxa_thread_atexit) in archive /usr/lib/gcc/x86_64-linux-gnu/11/libstdc++.a clang++: error: linker command failed with exit code 1 (use -v to see invocation) `

i wonder if thats because rapidlib seemed to be using c11?

nm -D librapidLib.so > nmrapidso.txt nmrapidso.txt

putjson is there 0000000000039b20 W _ZN8modelSetIfE7putJSONERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE 00000000000376e0 W _ZN8modelSetIdE7putJSONERKNSt7cxx1112basic_stringIcSt11char_traitsIcESaIcEEE but ues cxx11 basic string instead of std::1::basic_string

jerobarraco commented 2 years ago

Seems like i would want to compile rapidlib to use libc++ instead of libstdc++ but honestly i don't know how https://forums.unrealengine.com/t/demangled-used-std-basic-string-but-i-need-std-basic-string/408345/2

https://pgaleone.eu/2022/05/27/unreal-engine-third-party-linux-abi-compatibility/

(The extra library include on the build.CS was because it was showing missing definitions from rapidlib but shouldnt be necessary)