undefined symbol: _ZN22UMyCustomMeshComponentC1ERK18FObjectInitializer

i have a basic hello world plugin, that now compiles, links, but then fails at runtime with the error below.

/home/raptor/UnrealEngine/Engine/Binaries/Linux/UE4Editor: symbol lookup error: /home/raptor/Documents/Unreal Projects/MyProject/Plugins/MyPlugin/Binaries/Linux/libUE4Editor-MyPlugin.so: undefined symbol: _ZN22UMyCustomMeshComponentC1ERK18FObjectInitializer

My hello world is just a skeleton, and i haven’t defined a constructor for my UCLASS yet. I was expecting a compile time, or link time error, not a runtime error like this one.

my .cpp file

#pragma once
#include <ModuleManager.h>
#include <IMyPlugin.h>
std::vector<std::shared_ptr<std::thread>> __spawned_threads__;

class FMyPlugin : public IMyPlugin {
	virtual void StartupModule() override {
	std::cout << std::string("TESTING MYBLUEPRINT...") << std::endl;
}
	virtual void ShutdownModule() override {
	std::cout << std::string("MYPLUGIN EXIT") << std::endl;
}
};
IMPLEMENT_MODULE( FMyPlugin, MyPlugin )

my header file

#pragma once
#include <Eigen/Core>
#include <random>
#include <memory>
#include <vector>
#include <array>
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <thread>
#include <chrono>
#include <cmath>
#include <complex>
#include <atomic>
#include <cstdlib>
typedef long   i64;
typedef int    i32;
typedef double f64;
typedef double float64;
typedef float  f32;
typedef float  float32;
typedef const char*  cstring;
typedef std::string string;

#include "Runtime/UMG/Public/UMG.h"
#include "Runtime/UMG/Public/UMGStyle.h"
#include "Runtime/UMG/Public/Slate/SObjectWidget.h"
#include "Runtime/UMG/Public/IUMGModule.h"
#include "Runtime/UMG/Public/Blueprint/UserWidget.h"
#include "AIController.h"
#include "Components/AudioComponent.h"
#include "AudioDecompress.h"
#include "AudioDevice.h"
#include "ActiveSound.h"
#include "Audio.h"
#include "Developer/TargetPlatform/Public/Interfaces/IAudioFormat.h"
#include "VorbisAudioInfo.h"

#include "IMyPlugin.generated.h"

class IMyPlugin : public IModuleInterface {
	IMyPlugin& Get() {
		return FModuleManager::LoadModuleChecked<IMyPlugin>("MyPlugin");
	}
	bool IsAvailable() {
		return FModuleManager::Get().IsModuleLoaded("MyPlugin");
	}
};

USTRUCT(BlueprintType)
struct FMyCustomMeshTriangle {
	GENERATED_USTRUCT_BODY()
		UPROPERTY(EditAnywhere, Category=Triangle)
		FVector Vertex0;
		UPROPERTY(EditAnywhere, Category=Triangle)
		FVector Vertex1;
		UPROPERTY(EditAnywhere, Category=Triangle)
		FVector Vertex2;
};

UCLASS()
class UMyCustomMeshComponent:  public UMeshComponent {
GENERATED_UCLASS_BODY()
  public:
	TArray<FMyCustomMeshTriangle> CustomMeshTris;
	std::weak_ptr<UMyCustomMeshComponent> __weakref__;
	bool __initialized_UMyCustomMeshComponent;
	constexpr static const char* __class__ = "UMyCustomMeshComponent";
	virtual std::string get_class_name(){ return std::string("UMyCustomMeshComponent");}
};

i tried adding a constructor to my uclass and now i get this error:
In file included from …/…/…/Documents/Unreal Projects/MyProject/Plugins/MyPlugin/Intermediate/Build/Linux/B4D820EA/UE4Editor/Inc/MyPlugin/MyPlugin.generated.dep.h:9:
…/…/…/Documents/Unreal Projects/MyProject/Plugins/MyPlugin/Source/MyPlugin/Public/IMyPlugin.h:372:11: error: constructor cannot be redeclared
inline UMyCustomObject( const FObjectInitializer& ObjectInitializer ) : Super( ObjectInitializer ) {}
^
…/…/…/Documents/Unreal Projects/MyProject/Plugins/MyPlugin/Source/MyPlugin/Public/IMyPlugin.h:369:1: note: previous declaration is here
GENERATED_UCLASS_BODY()

my constructor is defined in my header, should i move that to my cpp file instead?

myheader

USTRUCT(BlueprintType)
struct FMyCustomStruct {
	GENERATED_USTRUCT_BODY()
		UPROPERTY(EditAnywhere, Category=Triangle)
		FVector Vertex0;
		UPROPERTY(EditAnywhere, Category=Triangle)
		FVector Vertex1;
		UPROPERTY(EditAnywhere, Category=Triangle)
		FVector Vertex2;
};
/**
 * []
 */
UCLASS()
class UMyCustomObject:  public UObject {
GENERATED_UCLASS_BODY()
  public:
		TArray<FMyCustomStruct> MyStructs;
		inline UMyCustomObject( const FObjectInitializer& ObjectInitializer ) : Super( ObjectInitializer ) {}
};

If you use GENERATED_UCLASS_BODY() then you have to define (but not declare) a constructor like this:

UMyCustomObject::UMyCustomObject( const FObjectInitializer& ObjectInitializer )
    : Super( ObjectInitializer )
{
}

Alternatively you may use GENERATED_BODY() instead, as that doesn’t require that constructor to be defined.

thanks, using GENERATED_BODY() instead of GENERATED_UCLASS_BODY() fixed the problem.
I think the documentation could have made this more clear, although the examples and tutorials all show the syntax and rules, they do not go into the details of these macros and why the code must be carefully split apart into headers and cpp files, because of parsing and code generation that unreal build tool must perform.