How to set up a UE4 C++ project to work with SkookumScript


#1

Making your C++ project work with SkookumScript (i.e. how to use UCLASS, UFUNCTION. UPROPERTY and UENUM macros in your own C++ code and have the reflected types appear in SkookumScript) requires making a few modifications to some source and build files. Follow this guide and you should have it working in no time.

  1. Please download the FireBot sample project from our downloads page. It is an example C++ project that uses SkookumScript, and we will use it as a reference.
  2. Start by creating a new file named SkookumScript.ini in your project’s Config folder. We recommend you copy it from the FireBot project and modify it. In SkookumScript.ini, you specify (repeat several times to specify multiple items of the same kind)
  • +ScriptSupportedModules to tell SkookumScript for which module to generate bindings (this is usually just one module - your main game module)
  • +AdditionalIncludes to specify additional include files to include to make the binding code work (this is sometimes necessary as UE4 header files very often do not include all necessary sub-includes and will simply not compile unless used in a “magic order” which is hard to get perfect)
  • +SkipClasses to specify the name of classes or structs that you do not want to reflect to SkookumScript
  • +RenameClasses and +RenameProperties to resolve name conflicts when mapping UE4 Blueprints to SkookumScript code (see here for details)
  1. Important: In UE 4.15 and below, whenever you make changes to SkookumScript.ini, you need to Clean UnrealHeaderTool (or temporarily add a blank line to any header file containing UCLASS or UFUNCTION macros) to pick up the changes. In UE 4.16 and above, the build system automatically detects the changes and triggers the appropriate build steps.
  2. In your game module main cpp file (usually named YourGame.cpp) add the following include file:
    #include <SkUEProjectGeneratedBindings.generated.inl>
  3. In your game module’s MyGame.Build.cs script file
    • add the following imports to the top of the file: using System.IO; using System.Collections.Generic; using Tools.DotNETCommon;
    • add the following code to the constructor:
      PrivateDependencyModuleNames.AddRange(GetSkookumScriptModuleNames(Path.Combine(ModuleDirectory, "../..")));
    • add the definition of the function GetSkookumScriptModuleNames() itself (see the FireBot sample project’s FireBot.Build.cs file for an example)
  4. If you are using UE 4.15 or below, Clean UnrealHeaderTool (or temporarily add a blank line to any header file containing UCLASS or UFUNCTION macros) to manually trigger a re-run of UnrealHeaderTool
  5. Build your game project

This should be all that’s needed for you to start using UCLASS(), UFUNCTION() etc. macros and see the respective SkookumScript classes appear in the IDE!

Hope this helps! Don’t hesitate to let us know if you have any more questions.


3.0.4462 is here! Lots of stability improvements and easier C++ project setup
BlueprintPure functions
Working with other plugins?
Sub-Includes
UStructs not showing in IDE
About Automated tests using SK
Read the SkookumScript Primer to level up!
[Resolved] Not seeing raw data members in ShooterGame base project
Docs for 3rd party plugins
[Solved] Mixed Versioning between Source/Binary engine/plugin? Project vs Engine plugin?
Great curated posts to learn about SkookumScript
Failed moving project information from temporary to editable location
Trying To Call Custom Functions on Custom Pawn From C++
#2

Thank you for this guide! I had come across :sk: earlier this year and liked what I saw, but struggled getting it working with a c++ project and left it for the time.

But with your updates since then and this post, it’s all good now and I’m really liking it so far. Great to see all the support you guys provide in the forums too.

[@Noolarch: Moved note about possible missing script files error to - "Missing script bindings for 4.13.2]


#3

For the build.cs instructions, you need to include the following assemblies at the top of the file:

using System.IO;
using System.Collections.Generic;


#4

I’ve been banging my head against a wall trying to follow old instructions. I found this tutorial today and I think that I’m on the right track, but now I’m getting a weird error in VS.

Missing binary: C:\Users\Matt\Documents\Unreal Projects\Testing\Plugins\SkookumScript\Binaries\Win64\UnrealHeaderTool-SkookumScriptGenerator.dll

I installed the Skookumscript plugin from the market place and it is in my UE4.15 Engine/Plugins folder. Why is it still trying to find the .dll in my project?

Edit: It looks like my real problem is that Paper2D is not supported by default. I’m now getting this error in VS:

Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol “__declspec(dllimport) public: static class SkClass * __cdecl SkUEPaperTileInfo::get_class(void)” (_imp?get_class@SkUEPaperTileInfo@@SAPEAVSkClass@@XZ) referenced in function “void __cdecl SkUETestingWorldGenerator_Impl::mthd_paper_tile_info_for_tile(class SkInvokedMethod *,class SkInstance * *)” (?mthd_paper_tile_info_for_tile@SkUETestingWorldGenerator_Impl@@YAXPEAVSkInvokedMethod@@PEAPEAVSkInstance@@@Z) Testing C:\Users\Matt\Documents\Unreal Projects\Testing\Intermediate\ProjectFiles\Testing.cpp.obj 1


#5

With the GitHub version of SkookumScript you can enable Paper2D by adding Paper2D to the +ScriptSupportedModules list in Config/SkookumScript.ini of the plugin, then rebuild, after which the class would be available for use in :sk:.

If you don’t want to make the leap to build from GitHub source, we will see if there is a workaround for the launcher+Marketplace builds and will give updated instructions as soon we have the details.


#6

It would be helpful to explain how the string should look like for this when you have 2+ includes you want to add. Do you call the parameter multiple times? Or use a comma-separated list? Is the variable quotes-encapsulated? Etc.

The Firebot project doesn’t use this so it’s not helpful.


#7

In Step 5, you also need to add:

using Tools.DotNETCommon;


#8

Is it possible to get Skookum (the plugin version, not full source) working with a C++ project which does NOT use the full engine?

IE–> If I add the Skookum plugin from the marketplace to my UE4.18 retail install and then create a C++ project through the wizard, and THEN follow the above steps, is it supposed to work? Or Not?


#9

Yes, using the Unreal Marketplace version of the SkookumScript plugin with a C++ project should be fine.

Not 100% sure what you mean by “does NOT use the full engine”?


#10

“NOT use the full engine”…

meaning I didn’t build the engine myself, I’m using an off the shelf retail version (not the one from github which requires compilation)…


#11

Yes. Many do and it should be fine.


#12

OK because I followed the steps, skookum loads automatically and compiles successfully. But as soon as I try to add a new member I get the following message:

2018-07-04%2015_00_04-SkookumIDE%20Standard%20-%20NP


#13

Looks like I got this working by manually copying Project-Generated-BP and Project-Generated-C++ over to a new Scripts directory and also making a Skookum-project.ini file in there…


#14

Good to hear you got it working.

We’ll see if we can recreate your setup issue and try to improve the workflow.

Thanks!


#15

I’ve got a project in 4.19.2 and I’ve followed all the steps, but I keep getting the following errors:

1>------ Build started: Project: Blobber, Configuration: Development_Editor x64 ------
1>Creating makefile for BlobberEditor (changes to external dependency)
1>Performing 3 actions (4 in parallel)
1>Blobber.cpp
1>H:\HLG\Blobber\Source\Blobber\Blobber.cpp(5): fatal error C1083: Cannot open include file: 'SkUEProjectGeneratedBindings.generated.inl': No such file or directory
1>UnrealBuildTool : error : UBT ERROR: Failed to produce item: H:\HLG\Blobber\Binaries\Win64\UE4Editor-Blobber.dll
1>Total build time: 6.01 seconds (Local executor: 0.00 seconds)
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.MakeFile.Targets(44,5): error MSB3075: The command ""H:\Epic Games\UE_4.19\Engine\Build\BatchFiles\Build.bat" BlobberEditor Win64 Development "H:\HLG\Blobber\Blobber.uproject" -WaitMutex -FromMsBuild" exited with code 5. Please verify that you have sufficient rights to run this command.
1>Done building project "Blobber.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I can compile without

#include <SkUEProjectGeneratedBindings.generated.inl>

in my Blobber.cpp file but then none of my C++ is accessible from :sk: :frowning:

Any help anyone could give me would be greatly appreciated.

Edit: Forgot to mention, everything is downloaded through the launcher.


#16

Did you add the GetSkookumScriptModuleNames stuff to your Blobber.Build.cs?


#17

Yeah, I’ll add it below just in case it’s useful

// Fill out your copyright notice in the Description page of Project Settings.

using UnrealBuildTool;
using System.IO;
using System.Collections.Generic;
using Tools.DotNETCommon;

public class Blobber : ModuleRules
{
	public Blobber(ReadOnlyTargetRules Target) : base(Target)
	{
		PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
	
		PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" });

		PrivateDependencyModuleNames.AddRange(new string[] {  });

        // Load SkookumScript.ini and add any ScriptSupportedModules specified to the list of PrivateDependencyModuleNames
        PrivateDependencyModuleNames.AddRange(GetSkookumScriptModuleNames(Path.Combine(ModuleDirectory, "../..")));

        // Uncomment if you are using Slate UI
        // PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });

        // Uncomment if you are using online features
        // PrivateDependencyModuleNames.Add("OnlineSubsystem");

        // To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true
    }

    // Load SkookumScript.ini and return any ScriptSupportedModules specified
    public static List<string> GetSkookumScriptModuleNames(string PluginOrProjectRootDirectory, bool AddSkookumScriptRuntime = true)
    {
        List<string> moduleList = null;

        // Load SkookumScript.ini and get ScriptSupportedModules
        string iniFilePath = Path.Combine(PluginOrProjectRootDirectory, "Config/SkookumScript.ini");
        if (File.Exists(iniFilePath))
        {
            ConfigFile iniFile = new ConfigFile(new FileReference(iniFilePath), ConfigLineAction.Add);
            var skookumConfig = new ConfigHierarchy(new ConfigFile[] { iniFile });
            skookumConfig.GetArray("CommonSettings", "ScriptSupportedModules", out moduleList);
        }

        if (moduleList == null)
        {
            moduleList = new List<string>();
        }

        // Add additional modules needed for SkookumScript to function
        moduleList.Add("AgogCore");
        moduleList.Add("SkookumScript");
        if (AddSkookumScriptRuntime)
        {
            moduleList.Add("SkookumScriptRuntime");
        }

        return moduleList;
    }
}

#18

Hmm, so the file in question is actually generated during the build. You’ll find it and other files in Intermediate/Build/Win64/UE4Editor/Inc/Blobber. If they aren’t getting generated then… can you confirm that you have SkookumScript plugin in your .uproject set to enabled?

Also did you try deleting Intermediate folder and then regenerating VS project from your .uproject?

Finally, grasping for straws here, but I’ve never used PCHUsageMode.UseExplicitOrSharedPCHs in any of my :sk: projects. That could be a final test if you can easily disable it to test.


#19

Enabled in the .uproject

{
	"FileVersion": 3,
	"EngineAssociation": "4.19",
	"Category": "",
	"Description": "",
	"Modules": [
		{
			"Name": "Blobber",
			"Type": "Runtime",
			"LoadingPhase": "Default"
		}
	],
	"Plugins": [
		{
			"Name": "SkookumScript",
			"Enabled": true,
			"MarketplaceURL": "com.epicgames.launcher://ue/marketplace/content/38694f554c2c4b9f84c585256d509481"
		}
	]
}

As for PCHUsageMode.UseExplicitOrSharedPCHs I’ll try disabling that and report back.

Oh, forgot to mention, using the marketplace version of the plugin.


#20

The PCHUsageMode seems to have done it. It came with the stock Blobber.build.cs. Thanks so much for the help :smiley:

I’ve been banging my head against this for a day now.

:beers: for you!