x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How to access Object Tools in C++?

Hi guys,

I wrote the following code:

CreviceFunctionLibrary.h:

 #pragma once
 
 #include "CoreMinimal.h"
 #include "Kismet/BlueprintFunctionLibrary.h"
 #include "CreviceDataSingleton.h"
 #include "CreviceFunctionLibrary.generated.h"
 
 /**
  * 
  */
 UCLASS()
 class CREVICERPG_API UCreviceFunctionLibrary : public UObject
 {
     GENERATED_BODY()
 
     UFUNCTION(BlueprintPure, Category = "Utility")
     static void ConsolidateAssets(UObject* AssetToConsolidateTo, TArray<UObject*> &AssetsToReplace, bool bShowDeleteConfirmation = true);
 };

CreviceFunctionLibrary.cpp

 #include "CreviceRPG.h"
 #include "ObjectTools.h"
 #include "CreviceFunctionLibrary.h"
 
 void UCreviceFunctionLibrary::ConsolidateAssets(UObject* AssetToConsolidateTo, TArray<UObject*> &AssetsToReplace, bool bShowDeleteConfirmation)
 {
     ObjectTools::FConsolidationResults ConsResults = ObjectTools::ConsolidateObjects(AssetToConsolidateTo, AssetsToReplace, bShowDeleteConfirmation);
 }

I'm getting the following errors:

 2>CreviceFunctionLibrary.cpp.obj : error LNK2019: Verweis auf nicht aufgel÷stes externes Symbol ""__declspec(dllimport) public: virtual __cdecl ObjectTools::FConsolidationResults::~FConsolidationResults(void)" (__imp_??1FConsolidationResults@ObjectTools@@UEAA@XZ)" in Funktion ""private: static void __cdecl UCreviceFunctionLibrary::ConsolidateAssets(class UObject *,class TArray<class UObject *,class FDefaultAllocator> &,bool)" (?ConsolidateAssets@UCreviceFunctionLibrary@@CAXPEAVUObject@@AEAV?$TArray@PEAVUObject@@VFDefaultAllocator@@@@_N@Z)".
 2>CreviceFunctionLibrary.cpp.obj : error LNK2019: Verweis auf nicht aufgel÷stes externes Symbol ""__declspec(dllimport) struct ObjectTools::FConsolidationResults __cdecl ObjectTools::ConsolidateObjects(class UObject *,class TArray<class UObject *,class FDefaultAllocator> &,bool)" (__imp_?ConsolidateObjects@ObjectTools@@YA?AUFConsolidationResults@1@PEAVUObject@@AEAV?$TArray@PEAVUObject@@VFDefaultAllocator@@@@_N@Z)" in Funktion ""private: static void __cdecl UCreviceFunctionLibrary::ConsolidateAssets(class UObject *,class TArray<class UObject *,class FDefaultAllocator> &,bool)" (?ConsolidateAssets@UCreviceFunctionLibrary@@CAXPEAVUObject@@AEAV?$TArray@PEAVUObject@@VFDefaultAllocator@@@@_N@Z)".

There seems to be a problem to accessing the ObjectTools namespace, and I didn't manage to find out what caused this error. Does anyone know about that?

Cheers,

Luke

Product Version: UE 4.21
Tags:
more ▼

asked Mar 03 '19 at 10:17 AM in C++ Programming

avatar image

LukeScopegoat
6 1 2 3

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Hi!Did you add the module "UnrealEd" to the build.cs file and regenerate the project? Cause UE4 doesnt know where to find this headers by default.

https://api.unrealengine.com/INT/API/Editor/UnrealEd/ObjectTools__GenerateFactoryFile-/index.html

its under the "UnrealEd" module.

more ▼

answered Mar 03 '19 at 10:41 AM

avatar image

Maksym Nosatov
21 1 3

avatar image LukeScopegoat Mar 03 '19 at 10:53 AM

That solved it! Thank you a lot! :)

avatar image Shadowriver Mar 03 '19 at 05:35 PM

Keep in mind that id you add dependency to UnrealEd, you codem odule effectively becomes editor module and it will throw oyu errors on packageing to any non-editor build. You need to edit either uproject or uplugin and change Type of module you making from Runtime to Editor. You probably will need to make seperate runtime module for code that will run at runtime.

You can also make conditional dependency in build.cs so it only depend on it when you module is build for editor use and filter the editor dependent code with #if WITH_EDITOR , this let oyu have osme editor only code in runtime module without any packaging issues

avatar image LukeScopegoat Mar 07 '19 at 09:44 AM

Thank you, I'll try the WITH_EDITOR solution. :)

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question