Download

C++ Transition Guide for 4.18

Dear Community,

Cheers and fireworks for 4.18! Yay!

Here is a thread where you can post your research & solutions as you are upgrading to 4.18.

Questions are welcome here about C++, as well as any other editor-related aspects of 4.18 that you think might be common issues.

Have fun upgrading!

:heart:

Rama

Can’t Make VS Files For Your Project?

The New Target.cs

Are you finding you can’t generate VS files for your project?

Beginning with 4.18 you must use the new target.cs setup

old:



public class PMeleeWeaponTarget : TargetRules
{
    public PMeleeWeaponTarget(TargetInfo Target)
    {
        Type = TargetType.Game;
    }

    public override void SetupBinaries(
        TargetInfo Target,
        ref List<UEBuildBinaryConfiguration> OutBuildBinaryConfigurations,
        ref List<string> OutExtraModuleNames
        )
    {
        OutExtraModuleNames.AddRange( new string] { "PMeleeWeapon" } );
    }
}


New:



public class PMeleeWeaponTarget : TargetRules
{
    public PMeleeWeaponTarget(TargetInfo Target)
        : base(Target)
    {
        Type = TargetType.Game;
        ExtraModuleNames.Add("PMeleeWeapon");
    }
}


Editor Old



public class PMeleeWeaponEditorTarget : TargetRules
{
    public PMeleeWeaponEditorTarget(TargetInfo Target)
    {
        Type = TargetType.Editor;
    }

    //
    // TargetRules interface.
    //

    public override void SetupBinaries(
        TargetInfo Target,
        ref List<UEBuildBinaryConfiguration> OutBuildBinaryConfigurations,
        ref List<string> OutExtraModuleNames
        )
    {
        OutExtraModuleNames.AddRange( new string] { "PMeleeWeapon" } );
    }
}



Editor New



public class PMeleeWeaponEditorTarget : TargetRules
{
    public PMeleeWeaponEditorTarget(TargetInfo Target)
        : base(Target)
    {
        Type = TargetType.Editor;
        ExtraModuleNames.Add("PMeleeWeapon");
    }
}


:heart:

Rama

The HMD device location has changed - but it’s a pretty simple fix up:
Previously if you did:


EHMDDeviceType::Type  device = GEngine->HMDDevice.Get()

You now do:


EHMDDeviceType::Type  device = GEngine->XRSystem->GetHMDDevice()

and #include “IXRTrackingSystem.h”

And it should all work as before.

Got this one:

And this:

Both was moved to a public folder:



#include "IImageWrapper.h"
#include "IImageWrapperModule.h"


Hi guys,

Anyone else getting compile errors on a vanilla github 4.18 source compile? I"m getting these errors and seem to be in the engine side:

GitEngines\UnrealEngine_4.18.0\Engine\Source\Programs\Mac\ShaderCacheTool\Private\ShaderCacheTool.cpp(66): error C2039: ‘MergeShaderCacheFiles’: is not a member of ‘FShaderCache’

… and…

GitEngines\UnrealEngine_4.18.0\Engine\Source\Programs\BuildPatchTool\Private\ToolModes\AutomationMode.cpp(12): fatal error C1083: Cannot open include file: ‘Interfaces/IAutomationWorkerModule.h’: No such file or directory

How do i properly relink the Destruction Apex Class since they moved it to be a plugin? https://i.gyazo.com/3d691d86ff09b038640c880a12836ee9.png

Are the DPI related functions (e.g. FGenericPlatformMisc::ConvertInchesToPixels) gone in 4.18? Is there a new way for calculating DPI? Thank you.

One of the [FONT=courier new]FTimespan() constructors changed signature from


FTimespan(int32 Days, int32 Hours, int32 Minutes, int32 Seconds, int32 Milliseconds, int32 Microseconds = 0)

to


FTimespan(int32 Days, int32 Hours, int32 Minutes, int32 Seconds, int32 FractionNano)

The easiest way to fix this is use one of the built in static functions (In my case, I used [FONT=courier new]FTimespan::FromSeconds(DeltaTime) )

[FONT=courier new]FBodyInstance functions [FONT=courier new]SetAngularVelocity() and [FONT=courier new]GetUnrealWorldAngularVelocity() are now deprecated
To fix, use their [FONT=courier new]SetAngularVelocityInRadians() and [FONT=courier new]GetUnrealWorldAngularVelocityInRadians() variants instead. Don’t forget to call [FONT=courier new]FMath:: DegreesToRadians() where needed!

Add to your .uproject or your .uplugin:



"Plugins" :
    
        {
            "Name": "ApexDestruction",
            "Enabled": true
        } 
    ]    


:heart:

Rama

Hi Devero!!!

Did this ever get resolved?

:slight_smile:

Rama

Remove the ShaderCacheTool project from your solution.

For ‘Interfaces/IAutomationWorkerModule.h’ remove the ‘Interfaces/’ portion.

I have added ApexDestruction plugin but do I need to change the headers? The one on the screenshots did not work for me. Also should I change anything else?

https://docs.unrealengine.com/latest…esh/index.html

in official documentation info about holding apex class but nothing more … not event it’s deprecated.

I noticed an annoying 4.18 bug I think. I can’t join a dedicated server as a client from the command line anymore. It works when I do the exact same thing in 4.17 (with modifying the UE4 path of course). When I do it in 4.18, I just get a black screen. This is what I typed in command prompt.

“C:\Program Files\Epic Games\UE_4.18\Engine\Binaries\Win64\UE4Editor.exe” “C:\UnrealProjects\Testing\Testing.uproject” -server -log

“C:\Program Files\Epic Games\UE_4.18\Engine\Binaries\Win64\UE4Editor.exe” “C:\UnrealProjects\Testing\Testing.uproject” 192.168.2.21 -game -log

It says everything is connected in the log but I just get a black screen for the client window. What’s going on?

I noticed that the module containing FGamepadKeyNames has been changed from Core to ApplicationCore.



struct **CORE_API** FGamepadKeyNames
{
    typedef FName Type;
...


struct **APPLICATIONCORE_API **FGamepadKeyNames
{
    typedef FName Type;
...



Inside


Engine\Source\Runtime\Core\Public\CoreGlobals.h

I had


CORE_API extern int32            customVariable;

defined, and also



Engine\Source\Runtime\Core\Private\Misc\CoreGlobals.cpp


CORE_API int32            customVariable = 0;

I am using this variable inside


Engine\Source\Runtime\Slate\Private\Framework\Application\SlateApplication.cpp

casually.

It all compiles fine under 4.17

But! Under 4.18, I get:


2>Module.Slate.1_of_5.cpp.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) int customVariable" (__imp_?customVariable@@3HA)
2>Engine\Binaries\Win64\UE4Editor-Slate.dll : fatal error LNK1120: 1 unresolved externals

Can’t solve this no matter what. Either by including ‘CoreGlobal.h’ header and stuff. What actually did change, that it worked before, and not working now?

Since updating to 4.18, I am seeing this wierd non-fatal crash in the log my dedicated server and client on linux and windows:
(Important bits in underlined bold)


[2017.10.31-21.55.14:751]  0]LogPakFile: New pak file ../../../ProjectName/Content/Paks/ProjectName-WindowsNoEditor.pak added to pak precacher.
[2017.10.31-21.55.15:023]  0]LogStats: FPlatformStackWalk::StackWalkAndDump -  0.164 s
[2017.10.31-21.55.15:023]  0]LogOutputDevice: Error: === Handled ensure: ===
[2017.10.31-21.55.15:023]  0]LogOutputDevice: Error:
[2017.10.31-21.55.15:023]  0]LogOutputDevice: Error: Ensure condition failed: Lhs.Array.Num() == Lhs.InitialNum [File:c:\users\altrue\documents\unrealengine\engine\source\runtime\core\public\Containers/SparseArray.h] [Line: 781]
[2017.10.31-21.55.15:023]  0]LogOutputDevice: Error: **Container has changed during ranged-for iteration!**
[2017.10.31-21.55.15:023]  0]LogOutputDevice: Error: Stack:
[2017.10.31-21.55.15:023]  0]LogOutputDevice: Error: [Callstack] 0x0000000040271766 ProjectName.exe!FWindowsPlatformStackWalk::StackWalkAndDump() [c:\users\altrue\documents\unrealengine\engine\source\runtime\core\private\windows\windowsplatformstackwalk.cpp:200]
[2017.10.31-21.55.15:023]  0]LogOutputDevice: Error: [Callstack] 0x00000000400106C1 ProjectName.exe!FDebug::EnsureFailed() [c:\users\altrue\documents\unrealengine\engine\source\runtime\core\private\misc\assertionmacros.cpp:299]
[2017.10.31-21.55.15:023]  0]LogOutputDevice: Error: [Callstack] 0x000000004002AA06 ProjectName.exe!FDebug::OptionallyLogFormattedEnsureMessageReturningFalse() [c:\users\altrue\documents\unrealengine\engine\source\runtime\core\private\misc\assertionmacros.cpp:425]
**[2017.10.31-21.55.15:023]  0]LogOutputDevice: Error: [Callstack] 0x0000000042DCC415 ProjectName.exe!FPakAsyncReadFileHandle::DoProcessing() [c:\users\altrue\documents\unrealengine\engine\source\runtime\pakfile\private\iplatformfilepak.cpp:3218]**
[2017.10.31-21.55.15:023]  0]LogOutputDevice: Error: [Callstack] 0x0000000042DCED96 ProjectName.exe!TGraphTask<FAsyncIOCPUWorkTask>::ExecuteTask() [c:\users\altrue\documents\unrealengine\engine\source\runtime\core\public\async	askgraphinterfaces.h:787]
[2017.10.31-21.55.15:023]  0]LogOutputDevice: Error: [Callstack] 0x000000003FEE5D15 ProjectName.exe!FTaskThreadAnyThread::ProcessTasks() [c:\users\altrue\documents\unrealengine\engine\source\runtime\core\private\async	askgraph.cpp:910]
[2017.10.31-21.55.15:023]  0]LogOutputDevice: Error: [Callstack] 0x000000003FEE6F8D ProjectName.exe!FTaskThreadAnyThread::ProcessTasksUntilQuit() [c:\users\altrue\documents\unrealengine\engine\source\runtime\core\private\async	askgraph.cpp:786]
[2017.10.31-21.55.15:023]  0]LogOutputDevice: Error: [Callstack] 0x000000003FEF5455 ProjectName.exe!FTaskThreadBase::Run() [c:\users\altrue\documents\unrealengine\engine\source\runtime\core\private\async	askgraph.cpp:502]
[2017.10.31-21.55.15:023]  0]LogOutputDevice: Error: [Callstack] 0x000000004026F41C ProjectName.exe!FRunnableThreadWin::Run() [c:\users\altrue\documents\unrealengine\engine\source\runtime\core\private\windows\windowsrunnablethread.cpp:76]
[2017.10.31-21.55.15:023]  0]LogOutputDevice: Error: [Callstack] 0x000000004025FF63 ProjectName.exe!FRunnableThreadWin::GuardedRun() [c:\users\altrue\documents\unrealengine\engine\source\runtime\core\private\windows\windowsrunnablethread.cpp:33]
[2017.10.31-21.55.15:023]  0]LogOutputDevice: Error: [Callstack] 0x00000000771959CD kernel32.dll!UnknownFunction ]
[2017.10.31-21.55.15:023]  0]LogOutputDevice: Error: [Callstack] 0x00000000773CA561 ntdll.dll!UnknownFunction ]
[2017.10.31-21.55.15:023]  0]LogOutputDevice: Error:

The game still runs but it’s quite ugly to systematically have a stacktrace at the beginning of your logs. Besides, it’s just broken code waiting to happen…
Any ideas?

Somewhere in your code you are modifying an array while iterating through it which may cause pointer invalidation depending on the way you’re doing it:

Yes, though it happens at the line 3218 of some pak processing code, which is in the engine code itself and not in my code.

Besides, both assertions containing this “**Container has changed during ranged-for iteration!”**text haven’t been modified between 4.17 and 4.18, leading me to believe that even if by some miracle the stacktrace was completely off, and my code was at fault, I would have seen this message in the 4.17 builds.

This seems a bit big for an engine bug though, I mean surely that kind of thing in the logs wouldn’t have passed QA. So I’m guessing this is a 4.17 -> 4.18 transition thing, hence my posting here. Is there any modification to do regarding the way we handle paks or something?

seems like in 4.18 you have to specify starting map, something like this:

“C:\Program Files\Epic Games\UE_4.18\Engine\Binaries\Win64\UE4Editor.exe” “C:\UnrealProjects\Testing\Testing.uproject” /Game/ThirdPersonCPP/Maps/ThirdPersonExampleMap -server -log

It’s working! Thx man, you’re the best!