How to let the DLL know that I added a new function?

I introduced a new function in UObjectArray.h to get the MaxElement Number of UObjects.
Do I need to add this newly added function anywhere so the DLL knows about it?

Here is the error I got when the project was compiled

The procedure entry point ?GetObjectArrayLimit@FUObjectArray@@QEAAHXZ could not be located in the dynamic link library


FORCEINLINE int32 GetObjectArrayLimit() const
	{
		return ObjObjects.Capacity();
	}

You will need to make sure that the implementation of the function is included in a source file that is being compiled and linked into the project’s DLL. You can do this by adding the implementation of the function in the same .cpp file where you have the definition of the FUObjectArray class. If it’s a new module, you will also need to include the cpp file in your build file.

Another issue could be that the function is not marked as a DLL export. Unreal Engine uses a macro called DLLEXPORT to mark functions that should be exported from the DLL.

You will need to add DLLEXPORT before the FORCEINLINE keyword for the function to be exported: DLLEXPORT FORCEINLINE int32 GetObjectArrayLimit() const.

1 Like

Did you rebuild the engine after this modification ?
Or did you simply modify the header file from a binary engine (from the launcher) and ignore VS warning ?
You need to download a source engine from GitHub to be able to make changes, and recompile the engine.
Then you need to point your project to your “custom” engine, via right-click on .uproject → switch engine version.


If all you need is access this private variable, while not recommended, there’s some simpler hacky way. Something like :

// fake struct mirroring FUObjectArray up until ObjObjects
class FUObjectArrayHack
{
public:
    int32 ObjFirstGCIndex;
    int32 ObjLastNonGCIndex;
    int32 MaxObjectsNotConsideredByGC;
    bool OpenForDisregardForGC;
    FChunkedFixedUObjectArray ObjObjects;
};

// cast to fake struct to use its members
FUObjectArrayHack* Ptr = (FUObjectArrayHack*)(&GUObjectArray);
UE_LOG(LogTemp, Log, TEXT("Capacity: %i"), Ptr->ObjObjects.Capacity());

This doesn’t require modifying and rebuilding engine source, so it’s pretty ideal short term for development/debugging purposes.
However updating engine might break without warning (structural changes), and this might not be cross-platform, so if you need a more long-term production solution I’d still recommend modifying source.

Good hack, but I needed to make it official, and not subject to change.

I declared the implementation in the cpp file, I didn’t get error, but then, the got this error later.
error: inline function 'FUObjectArray::GetObjectArrayLimit' is not defined [-Werror,-Wundefined-inline]