Hello! I’m fairly new to Unreal engine and I wanted to read yaml files in my project using c++, so i tried to link the yaml-cpp library which didn’t work.
Before i even tried to link the yaml-cpp library, I have followed this tutorial for linking static library and everything worked fine.
I then tried to replicate the same process using the yaml-cpp library and the project then didn’t compile. I’ve got the “cannot open file yaml.h” during compilation if i include the header anywhere in the code. Or i got a lot of linker errors.
Here is the .build.cs file of the project
using UnrealBuildTool;
using System.IO;
public class Cooking_Game : ModuleRules
{
private string ModulePath
{
get { return ModuleDirectory; }
}
private string ThirdPartyPath
{
get { return Path.GetFullPath( Path.Combine( ModulePath, "../../ThirdParty/" ) ); }
}
public Cooking_Game(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" });
PrivateDependencyModuleNames.AddRange(new string[] { });
LoadYamlCpp(Target);
}
public bool LoadYamlCpp(ReadOnlyTargetRules Target)
{
bool isLibrarySupported = false;
if (Target.Platform == UnrealTargetPlatform.Win64)
{
isLibrarySupported = true;
string PlatformString = (Target.Platform == UnrealTargetPlatform.Win64) ? "x64" : "x86";
string LibrariesPath = Path.Combine(ThirdPartyPath, "yaml-cpp", "lib");
PublicAdditionalLibraries.Add(Path.Combine(LibrariesPath, "yaml-cpp." + PlatformString + ".lib"));
}
if (isLibrarySupported)
{
PublicIncludePaths.Add(Path.Combine(ThirdPartyPath, "yaml-cpp", "include"));
}
return isLibrarySupported;
}
}
First i got this error (sorry that it is not fully english): fatal error C1083: Nejde otev? soubor zahrnout: yaml.h: No such file or directory
But trying to redo everything from scratch i got bunch of linker errors, mostly unrecognized external symbol. you can see here
Files in ThirdParty folder:
yaml-cpp
└include
**└yaml-cpp
****└other headers
**** └ yaml.h
└lib
** └ yamp-cpp.x64.lib
Code using the yaml library:
#include "TestFunctionLibrary.h"
#include "yaml-cpp/yaml.h"
int UTestFunctionLibrary::TestFunc() {
return 5;
}
float UTestFunctionLibrary::YAMLtest() {
//Load the YAML file
YAML::Node config = YAML::LoadFile("example.yaml");
//Access data from the YAML file
float version = config["version"].as<float>();
return version;
}
Does anyone know what is wrong or what can i do to fix this? I have tried to search the internet for three whole days now, but i cannot find a solution. I’m also open to different solutions like diferent libraries or aproaches, if that will allow me to work with yaml files. I would be grateful for any kind of help