How to include paper2d properly into empty C++ project

I have been looking for this proper solution for a long time. Now I’m at final and find proper answer since websites are not giving any clear definition about “How to include paper 2d in blank project in c++”. I hope this helps.

STEP 1:
First you need to include Paper2D into your Build.cs file



PublicDependencyModuleNames.AddRange(new string] { "Core", "CoreUObject", "Engine", "InputCore", "UMG", "Paper2D" });  

This will open up your Paper2D modules

STEP 2:
But, include will not work for Paper related libraries like
#include “PaperSprite.h”
#include “PaperSpriteComponent.h”

For above you need to put below paths into Project->Properties->NMAKE->Include Seach Path-> Edit
Assume that your original ue files under D:\ProgramFiles\Epic Games, if not overwrite properly.



D:\Program Files\Epic Games\UE_4.24\Engine\Plugins\2D\Paper2D\Source\Paper2D\Classes
D:\Program Files\Epic Games\UE_4.24\Engine\Plugins\2D\Paper2D\Source\Paper2D
D:\Program Files\Epic Games\UE_4.24\Engine\Plugins\2D\Paper2D\Intermediate\Build\Win64\UE4Editor\Inc\Paper2D
D:\Program Files\Epic Games\UE_4.24\Engine\Plugins\2D\Paper2D\Source\Paper2D\Public 

STEP 3:
To enable in code referance in UPaperSpriteComponent and others (UPaperSprite will be referenced in code even if you didnt add)
Need to add Project->Properties->NMAKE->PreProcessDefinitions



PAPER2D_VTABLE=DLLEXPORT_VTABLE
PAPER2D_API=
PAPER2DEDITOR_VTABLE=DLLEXPORT_VTABLE
PAPER2DEDITOR_API=
PAPERSPRITESHEETIMPORTER_VTABLE=DLLEXPORT_VTABLE
PAPERSPRITESHEETIMPORTER_API=
PAPERTILEDIMPORTER_VTABLE=DLLEXPORT_VTABLE
PAPERTILEDIMPORTER_API=


Ready to go!

5 Likes

Excellent piece of work, I have been chasing this problem for days, it is good that you have pulled it all together. Your post relates to UE4.24
My reply relates to UE4.23 (Magic Leap version), the paths differ. UE4.23 wants to install to C:\UE4 due to a problem with maximum path length
The 4 paths you listed were:
D:\Program Files\Epic Games\UE_4.24\Engine\Plugins\2D\Paper2D\Source\Paper2D\Classes
D:\Program Files\Epic Games\UE_4.24\Engine\Plugins\2D\Paper2D\Source\Paper2D\Intermediate\Build\Win64\UE4Editor\Inc\Paper2D
D:\Program Files\Epic Games\UE_4.24\Engine\Plugins\2D\Paper2D\Intermediate\Build\Win64\UE4Editor\Inc\Paper2D
D:\Program Files\Epic Games\UE_4.24\Engine\Plugins\2D\Paper2D\Source\Paper2D\Public
The UE4.23 equivalents are:
C:\UE4\MagicLeapUE4Editor\Engine\Plugins\2D\Paper2D\Source\Paper2D\Classes
Not found
C:\UE4\MagicLeapUE4Editor\Engine\Plugins\2D\Paper2D\Intermediate\Build\Win64\UE4Editor\Inc\Paper2D
C:\UE4\MagicLeapUE4Editor\Engine\Plugins\2D\Paper2D\Source\Paper2D\Public

I cannot find a path that matches, your second path.

In UE4.23 the definitions need to be placed under Project->Properties->NMAKE->Preprocess Definitions (Preprocessor not Processor as per original post)

This was super helpful, thank you so much @RedrainKuka!

For any other noobs like me who couldn’t find the Build.cs file, you should be able to find it in the Visual Studio Solution Explorer in the same folder as your cpp files.
You can replace the existing PublicDependencyModuleNames line with the one mentioned in Step 1.
Annotation-20200326-153012.png

Does anyone know how to find Project->Properties->NMAKE->ProcessDefinitions in Visual Studio Code?

[USER=“80968”]Damion Knife[/USER] I had typo there, please find as below

I had trouble with this too, its a little confusing.

R-Click on your MyProjectName folder in the SolutionExplorer (Not the engine or other folders!)

Properties will be the bottom option in the context menu.

I kept opening the engine config and couldn’t find the NMAKE so I hope this helps someone out.