[bug?] SGraphNodeComment doesn't link

So I think that 99% is that I’m doing something wrong but I can’t understand what. So I was thinking about using SGraphNodeResizable as a base for some of my own classes. But when I tried to compile a project - it gave me whole lot of unresolved externals. But then I thought maybe I’m doing something wrong and I created a blank c++ project (well, not blank, it was third person, but it doesn’t matter). Then I added next in my build file:

    PrivateDependencyModuleNames.AddRange(new string[] {
        "Slate",
        "SlateCore",
        "PropertyEditor",
        "UnrealEd",
        "EditorStyle",
        "GraphEditor",
        "AssetTools",
    });

I just copied that from my previous project. And then I added just this line to the constructor of game mode:

SGraphNodeComment SNode;

I didn’t forget about includes:

#include "SGraphNodeComment.h"
#include "SlateCore.h"
#include "SlateBasics.h"

And I pressed build. After that I received huge amount of errors:

log1.txt

I don’t think it’s normal, what’s wrong and how to fix it? Without that line (and include statement) everything compiles normally. Just including SGraphNodeComment.h will give those errors. And I used SGraphNodeComment, but SGraphNodeResizable doesn’t compile also. Just by including SGraphNodeResizable.h I receive this:
log2.txt

So how it can be fixed?

UPD.
So I’ve added a bunch of headers it complained about. So now extra includes look like this:

#include "EdGraph/EdGraphNodeUtils.h"
#include "ScopedTransaction.h"
#include "EditorStyleSet.h"

#include "SGraphNode.h"
#include "SGraphNodeResizable.h"
#include "SGraphNodeComment.h"

After that it compiled normally. But adding just one line breaks everything:

SGraphNodeComment SNode;

Now we get to the real question. Why I get all this unresolved externals?

log3.txt

Maybe I forgot to add somehting to the build file?

Hello,

These include are already in in my game mode source file. It is called MyProjectGameMode.cpp. Or I don’t understand what you’re saying.
Anyway, here is the project:

Hey funbiscuit-

The errors appear to be coming from the MyProjectGameMode.cpp file. Can you try moving your includes to your game mode source file and try to compile again. If you are still getting unresolved externals then I would need to take a look at your project directly to further investigate. You can attach the project as an attachment if it is not too large. If it is large you can upload the project and provide a link to download it from. For privacy, you can set the post with the project information to private using the dropdown below the comment button.

Hey funbiscuit-

If you are still having troubles getting your code to compile, I found that variable being created needs to be a pointer instead. You can use this along with a forward declaration of the SGraphNodeComment rather than trying to include the SGraphNodeComment.h file itself to get the code to compile. With this I was able to get class SGraphNodeComment* SNode; to compile without the need to add additional includes or make any changes to the Build.cs file.

Cheers

Uhm, it doesn’t work in the original project. I have a node that inherits from SGraphNode. And everything works correctly. But if I change inheritance from SGraphNode to SGraphNodeResizable or SGraphNodeComment - I get unresolved externals. Since the project is quite big - I can’t guarantee that I always use pointers, but I’m about 99% sure that I always use pointers (or references).
So are you saying that I get unresolved externals only because somewhere I use non pointer version? And if so am I allowed to use references?

It seems that by declaring just a pointer compiler optimized out a lot of stuff and that’s why you didn’t receive any unresolved externals. I just tried in that blank project to write this (just as always - in constructor of game mode):

UEdGraphNode* node;
TSharedPtr<SGraphNodeComment> SNode = SNew(SGraphNodeComment, node);

And it doesn’t work. It compiles but gives unresolved externals.
Using TSharedRef also gives unresolved externals.

In the project you sent, I was able to get the code to compile after moving the SGraphNodeComment SNode; and SGraphNodeResizable SNode; lines from MyProjectGameMode.cpp to the MyProjectGameMode.h and adding class and the asterisk (*) as I mentioned in my previous response. You should also be able to remove the extra includes from MyProjectGameMode.cpp as well.

Can you explain exactly what you are trying to accomplish? As mentioned, I was able to get the SGraphNodeComment SNode; line to compile after moving it from the constructor (.cpp file) to the class declaration (.h file) and editing it slightly to look like class SGraphNodeComment* SNode;. Your latest comment is the first mention of UEdGraphNode or declaring SNode as a TSharedPtr.

I’m trying to create my own graph editor based from unreal’s graph editor (soundcue and soundclass since they are the easier ones). And it is working as expected. But currently all my nodes inherit from SGraphNode so their size is fixed. I thought about making them resizable and I changed SGraphNode to SGraphNodeResizable and I immediately got all this unresolved externals.

SNew is a macro that is used in factory that creates all this nodes. So I must use the line

TSharedPtr<SGraphNodeComment> SNode = SNew(SGraphNodeComment, node);

There is just no other way to create a node. Because in a factory (which inherit from FGraphPanelNodeFactory) I need to override this function:

virtual TSharedPtr<class SGraphNode> CreateNode(UEdGraphNode* Node) const override;

As you see, from declaration of it I need somewhere in this function create TSharedPtr. And I cannot do it because it gives unresolved externals.
Or are you saying that I cannot write

TSharedRef<SGraphNodeComment> SNode = SNew(SGraphNodeComment, node);

It seems to be a totally valid line of code.

From what I’ve figured out, it is because the SGraphNodeResizable is not under an API. So where SGraphNode is defined as:

class GRAPHEDITOR_API SGraphNode : public SNodePanel::SNode

SGraphNodeResizable is defined like this without the GRAPHEDITOR_API:

class SGraphNodeResizable : public SGraphNode

And similarily with SGraphNodeComment

class SGraphNodeComment : public SGraphNodeResizable`

So if you try to extend one of these classes with the API specified, it will spit out a ton of errors (the same ones in the your logs).

class MYPROJECT_API SMyGraphNodeComment : SGraphNodeComment

And if you remove the MYPROJECT_API it compiles fine! BUT it screws up again when you go in your factory and try to create it

SNew(SMyGraphNodeComment, InNode);

This will spit out errors again. I am not sure why it fails at this point, I was thinking that the FNodeFactory also isn’t under an API but it is under the GRAPHEDITOR_API.

I suspect adding GRAPHEDITOR_API to both SGraphNodeResizable and SGraphNodeComment will fix this. I don’t know if someone forgot to add the GRAPHEDITOR_API or if it was intended.