Announcement

Collapse
No announcement yet.

4.2 C++ Transition Guide

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    4.2 C++ Transition Guide

    Dear Community,

    Here's a thread where people can post the compile errors they've managed to resolve for 4.2, and also any compile errors you need help with!

    So I am hoping more people besides me will pitch in here

    Here's what I've learned, now that I've finally gotten Solus to compile in 4.2

    4.2 Upgrade Notes

    1. Get rid of the .inl line in YourGame.cpp

    Code:
    // Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
    
    #include "Solus.h"
    //#include "Solus.generated.inl"
    
    DEFINE_LOG_CATEGORY(SolusLog)
    DEFINE_LOG_CATEGORY(SolusInitLog)
    DEFINE_LOG_CATEGORY(SolusLevelBPLog)
    DEFINE_LOG_CATEGORY(SolusSaveSystemLog)
    
    IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, Solus, "Solus" );

    2. if dependson is not working properly, include the actual header for the classes that are being depended on

    3. GDeltaTime replaced with FApp::GetDeltaTime()

    4. FGenericPlatformMath::Round replaced by FGenericPlatformMath::RoundToInt

    5. Folder Structure

    If you have your own folder structure and your include files are not being found, please note that you can add custom include file paths!

    In YourGame.build.cs

    Code:
    //Private Paths
    PrivateIncludePaths.AddRange(new string[] { 
    	"Solus/Base",
    	"Solus/SolusCore",
    	"Solus/SolusSaveSystem"
    });

    Now if you include any .h files that are in any of these folders, they will be found properly!

    I had to proceed to add a lot of includes in places I never had to before, presumably due to my folder structure.

    So if something is not compiling, try adding the #include for whatever is not being found

    Rama
    UE4 Marketplace: Melee Weapon Plugin & Compressed Binary Save System Plugin | Rama's C++ AI Jumping Videos | Vertex Snap Editor Plugin

    ♥ Rama

    #2
    Thx as always Rama. What would we do without you.

    I'm also having problem with slate in 4.2. Now it's throwing our this error below (samples of it) Any clue how to fix this?

    Code:
    GameGuiResources.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static void __cdecl FSlateStyleRegistry::RegisterSlateStyle(class ISlateStyle const &)" (__imp_?RegisterSlateStyle@FSlateStyleRegistry@@SAXAEBVISlateStyle@@@Z) referenced in function "public: void __cdecl FGameGuiResources::Initialize(void)" (?Initialize@FGameGuiResources@@QEAAXXZ)
    1>GameGuiResources.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static void __cdecl FSlateStyleRegistry::UnRegisterSlateStyle(class ISlateStyle const &)" (__imp_?UnRegisterSlateStyle@FSlateStyleRegistry@@SAXAEBVISlateStyle@@@Z) referenced in function "public: void __cdecl FGameGuiResources::Shutdown(void)" (?Shutdown@FGameGuiResources@@QEAAXXZ)
    1>GameGuiWidget.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class FSimpleSlot & __cdecl TSupportsOneChildMixin<class SWidget,class FSimpleSlot>::operator[](class TSharedRef<class SWidget,0>)" (__imp_??A?$TSupportsOneChildMixin@VSWidget@@VFSimpleSlot@@@@QEAAAEAVFSimpleSlot@@V?$TSharedRef@VSWidget@@$0A@@@@Z) referenced in function "public: void __cdecl SGameGuiWidget::Construct(struct SGameGuiWidget::FArguments const &)" (?Construct@SGameGuiWidget@@QEAAXAEBUFArguments@1@@Z)
    1>GameGuiWidget.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class FSimpleSlot & __cdecl TSupportsContentAlignmentMixin<class FSimpleSlot>::HAlign(enum EHorizontalAlignment)" (__imp_?HAlign@?$TSupportsContentAlignmentMixin@VFSimpleSlot@@@@QEAAAEAVFSimpleSlot@@W4EHorizontalAlignment@@@Z) referenced in function "public: void __cdecl SGameGuiWidget::Construct(struct SGameGuiWidget::FArguments const &)" (?Construct@SGameGuiWidget@@QEAAXAEBUFArguments@1@@Z)
    1>GameGuiWidget.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class FSimpleSlot & __cdecl TSupportsContentAlignmentMixin<class FSimpleSlot>::VAlign(enum EVerticalAlignment)" (__imp_?VAlign@?$TSupportsContentAlignmentMixin@VFSimpleSlot@@@@QEAAAEAVFSimpleSlot@@W4EVerticalAlignment@@@Z) referenced in function "public: void __cdecl SGameGuiWidget::Construct(struct SGameGuiWidget::FArguments const &)" (?Construct@SGameGuiWidget@@QEAAXAEBUFArguments@1@@Z)
    1>GameGuiWidget.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl FSlateFontInfo::FSlateFontInfo(void)" (__imp_??0FSlateFontInfo@@QEAA@XZ) referenced in function "public: __cdecl TAttribute<struct FSlateFontInfo>::TAttribute<struct FSlateFontInfo>(void)" (??0?$TAttribute@UFSlateFontInfo@@@@QEAA@XZ)
    1>GameGuiWidget.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl FSlateFontInfo::FSlateFontInfo(class FString const &,unsigned short)" (__imp_??0FSlateFontInfo@@QEAA@AEBVFString@@G@Z) referenced in function "public: void __cdecl SGameGuiWidget::Construct(struct SGameGuiWidget::FArguments const &)" (?Construct@SGameGuiWidget@@QEAAXAEBUFArguments@1@@Z)
    ps. I really think that Epic should really supply us with a guide like this though...

    Comment


      #3
      I guess you have a compiled DLL with old Slate code that is not compatible with latest api.
      When updating I always delete compiled DLLs (UE4Editor-ProjectName.dll) in ProjectName\Binaries\Win64\ folder and then I hit Build for 'Development' | 'Win64'.

      My problem now is that I can't open any of my levels because of a versioning bug. Latest preview has a higher engine version than the final release one.
      | Savior | USQLite | FSM | Object Pool | Sound Occlusion | Property Transfer | Magic Nodes | MORE |

      Comment


        #4
        Originally posted by KillerPenguin View Post
        Thx as always Rama. What would we do without you.

        I'm also having problem with slate in 4.2. Now it's throwing our this error below (samples of it) Any clue how to fix this?

        Code:
        GameGuiResources.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static void __cdecl FSlateStyleRegistry::RegisterSlateStyle(class ISlateStyle const &)" (__imp_?RegisterSlateStyle@FSlateStyleRegistry@@SAXAEBVISlateStyle@@@Z) referenced in function "public: void __cdecl FGameGuiResources::Initialize(void)" (?Initialize@FGameGuiResources@@QEAAXXZ)
        1>GameGuiResources.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static void __cdecl FSlateStyleRegistry::UnRegisterSlateStyle(class ISlateStyle const &)" (__imp_?UnRegisterSlateStyle@FSlateStyleRegistry@@SAXAEBVISlateStyle@@@Z) referenced in function "public: void __cdecl FGameGuiResources::Shutdown(void)" (?Shutdown@FGameGuiResources@@QEAAXXZ)
        1>GameGuiWidget.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class FSimpleSlot & __cdecl TSupportsOneChildMixin<class SWidget,class FSimpleSlot>::operator[](class TSharedRef<class SWidget,0>)" (__imp_??A?$TSupportsOneChildMixin@VSWidget@@VFSimpleSlot@@@@QEAAAEAVFSimpleSlot@@V?$TSharedRef@VSWidget@@$0A@@@@Z) referenced in function "public: void __cdecl SGameGuiWidget::Construct(struct SGameGuiWidget::FArguments const &)" (?Construct@SGameGuiWidget@@QEAAXAEBUFArguments@1@@Z)
        1>GameGuiWidget.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class FSimpleSlot & __cdecl TSupportsContentAlignmentMixin<class FSimpleSlot>::HAlign(enum EHorizontalAlignment)" (__imp_?HAlign@?$TSupportsContentAlignmentMixin@VFSimpleSlot@@@@QEAAAEAVFSimpleSlot@@W4EHorizontalAlignment@@@Z) referenced in function "public: void __cdecl SGameGuiWidget::Construct(struct SGameGuiWidget::FArguments const &)" (?Construct@SGameGuiWidget@@QEAAXAEBUFArguments@1@@Z)
        1>GameGuiWidget.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class FSimpleSlot & __cdecl TSupportsContentAlignmentMixin<class FSimpleSlot>::VAlign(enum EVerticalAlignment)" (__imp_?VAlign@?$TSupportsContentAlignmentMixin@VFSimpleSlot@@@@QEAAAEAVFSimpleSlot@@W4EVerticalAlignment@@@Z) referenced in function "public: void __cdecl SGameGuiWidget::Construct(struct SGameGuiWidget::FArguments const &)" (?Construct@SGameGuiWidget@@QEAAXAEBUFArguments@1@@Z)
        1>GameGuiWidget.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl FSlateFontInfo::FSlateFontInfo(void)" (__imp_??0FSlateFontInfo@@QEAA@XZ) referenced in function "public: __cdecl TAttribute<struct FSlateFontInfo>::TAttribute<struct FSlateFontInfo>(void)" (??0?$TAttribute@UFSlateFontInfo@@@@QEAA@XZ)
        1>GameGuiWidget.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl FSlateFontInfo::FSlateFontInfo(class FString const &,unsigned short)" (__imp_??0FSlateFontInfo@@QEAA@AEBVFString@@G@Z) referenced in function "public: void __cdecl SGameGuiWidget::Construct(struct SGameGuiWidget::FArguments const &)" (?Construct@SGameGuiWidget@@QEAAXAEBUFArguments@1@@Z)
        ps. I really think that Epic should really supply us with a guide like this though...

        From the release notes:

        Code:
        If in your project you are getting linker errors for unresolved types that are now declared in SlateCore, you may be missing a dependency to 'SlateCore'.
        So add SlateCore to your build.cs dependencies.
        It is by will alone I set my code in motion.
        It is by coding that thoughts acquire speed, the hands acquire shaking, the shaking becomes a warning.
        It is by will alone I set my code in motion.

        Comment


          #5
          Adding SlateCore fixed this, thx a bunch!

          Comment


            #6
            Urrghh... having another problem.

            We got this in 4.2 when we call mSession->CreateSession(ControllerId, SessionName, *HostSettings);

            Code:
            !Id:9594eaa1822fa8e8a7f50e34e8795dd8
            
            Unknown exception - code 00000001 (first/second chance not available)
            
            KERNELBASE.dll
            
            KERNELBASE + 42141 bytes
            UE4Editor_Core + 2998748 bytes
            UE4Editor_Core + 1620298 bytes
            UE4Editor_CoreUObject + 332555 bytes
            UE4Editor!CastChecked<UGameEngine>() + 174 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.2\engine\source\runtime\coreuobject\public\templates\casts.h:30]
            UE4Editor!IsServerDelegateForOSS() + 84 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.2\engine\source\runtime\launch\private\launchengineloop.cpp:585]
            UE4Editor!TBaseStaticDelegateInstance_RetVal_OneParam<bool,FName>::Execute() + 13 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.2\engine\source\runtime\core\public\delegates\delegateinstancesimpl.inl:812]
            UE4Editor_Core + 1612257 bytes
            UE4Editor_OnlineSubsystemNull + 136784 bytes
            UE4Editor_OnlineSubsystemNull + 171875 bytes
            UE4Editor_OnlineSubsystemNull + 103499 bytes
            UE4Editor_game!AgameGameSession::HostSession() + 1800 bytes [d:\gameproject\gameclient\game\source\game\gamegamesession.cpp:50]
            UE4Editor_game!AFrontGui::StartServer() + 612 bytes [d:\gameproject\gameclient\game\source\game\gamegui\frontgui.cpp:163]
            UE4Editor_game!AFrontGui::RenderNetworkMenu() + 852 bytes [d:\gameproject\gameclient\game\source\game\gamegui\frontgui.cpp:83]
            UE4Editor_Engine + 4024757 bytes
            UE4Editor_Engine + 3509487 bytes
            UE4Editor_Engine + 8619847 bytes
            UE4Editor_UnrealEd + 1467386 bytes
            UE4Editor_UnrealEd + 5375494 bytes
            UE4Editor!FEngineLoop::Tick() + 3555 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.2\engine\source\runtime\launch\private\launchengineloop.cpp:2091]
            UE4Editor!GuardedMain() + 476 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.2\engine\source\runtime\launch\private\launch.cpp:132]
            UE4Editor!GuardedMainWrapper() + 26 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.2\engine\source\runtime\launch\private\windows\launchwindows.cpp:125]
            UE4Editor!WinMain() + 249 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.2\engine\source\runtime\launch\private\windows\launchwindows.cpp:207]
            UE4Editor!__tmainCRTStartup() + 329 bytes [f:\dd\vctools\crt\crtw32\dllstuff\crtexe.c:618]
            This crashes the 4.2 engine whenever we call it..

            ps. This seems to only crash the editor, not a built project.
            Last edited by KillerPenguin; 06-04-2014, 11:23 PM.

            Comment


              #7
              Originally posted by KillerPenguin View Post
              ps. This seems to only crash the editor, not a built project.
              oooh that's good intel!

              Great work Killer Penguin!

              Rama
              UE4 Marketplace: Melee Weapon Plugin & Compressed Binary Save System Plugin | Rama's C++ AI Jumping Videos | Vertex Snap Editor Plugin

              ♥ Rama

              Comment


                #8
                FStaticPrimitiveDrawInterface:rawMesh no longer takes 4 arguments.

                Old Function
                Code:
                	virtual void DrawMesh(
                		const FMeshBatch& Mesh,
                		float MinDrawDistance,
                		float MaxDrawDistance,
                		bool bShadowOnly = false
                		) = 0;
                New Function
                Code:
                	virtual void DrawMesh(
                		const FMeshBatch& Mesh,
                		float ScreenSize,
                		bool bShadowOnly = false
                		) = 0;
                Since pretty much every instance of drawmesh was using 0,FLT_MAX anyway I think they felt it appropriate to cut it down to the FLT_MAX.
                Last edited by mordentral; 06-05-2014, 09:01 AM.


                Consider supporting me on patreon

                My Open source tools and plugins
                Advanced Sessions Plugin
                VR Expansion Plugin

                Comment


                  #9
                  Originally posted by KillerPenguin View Post
                  Urrghh... having another problem.

                  We got this in 4.2 when we call mSession->CreateSession(ControllerId, SessionName, *HostSettings);

                  Code:
                  !Id:9594eaa1822fa8e8a7f50e34e8795dd8
                  
                  Unknown exception - code 00000001 (first/second chance not available)
                  
                  UE4Editor!CastChecked<UGameEngine>() + 174 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.2\engine\source\runtime\coreuobject\public\templates\casts.h:30]
                  UE4Editor!IsServerDelegateForOSS() + 84 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.2\engine\source\runtime\launch\private\launchengineloop.cpp:585]
                  UE4Editor!TBaseStaticDelegateInstance_RetVal_OneParam<bool,FName>::Execute() + 13 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.2\engine\source\runtime\core\public\delegates\delegateinstancesimpl.inl:812]
                  UE4Editor_Core + 1612257 bytes
                  UE4Editor_OnlineSubsystemNull + 136784 bytes
                  UE4Editor_OnlineSubsystemNull + 171875 bytes
                  UE4Editor_OnlineSubsystemNull + 103499 bytes
                  UE4Editor_game!AgameGameSession::HostSession() + 1800 bytes [d:\gameproject\gameclient\game\source\game\gamegamesession.cpp:50]
                  UE4Editor_game!AFrontGui::StartServer() + 612 bytes [d:\gameproject\gameclient\game\source\game\gamegui\frontgui.cpp:163]
                  UE4Editor_game!AFrontGui::RenderNetworkMenu() + 852 bytes [d:\gameproject\gameclient\game\source\game\gamegui\frontgui.cpp:83]
                  This crashes the 4.2 engine whenever we call it..

                  ps. This seems to only crash the editor, not a built project.

                  Can you tell me the repro steps for this? At a high level what are you trying to do? You are clearly in the editor, but are you running PIE? How does RenderNetworkMenu get triggered?

                  And your commandline?


                  The OnlineSubsystem is trying to figure out if it should be in "server" or "client" mode and it is missing some data at the time of the determination. As a fallback, it calls a function on the UGameEngine by design because it is not standard practice to do "networking/multiplayer" say while running outside of PIE but in the editor.

                  I need to figure out the combination of things that makes your code run the way it does.

                  Typically we run multiplayer with the editor executable via -game, -server, or clicking the PLAY button in editor. When running multiplayer in PIE, its usually for a minimal subset of things. You can get Unreal Networking in there and not use the OnlineSubsystem.

                  It's hard to explain, so let's hear what you're up to and I'll see what I can do to help you out.

                  Comment


                    #10
                    Arr yes, this is probably related to my other post about c++ network. To keep things short, we couldn't figure out how to always open our packaged game as a listen server without using the command line. So as a work around, we have our game reopen the map with ?listen if it's a standalone.

                    I didn't expect it to crash the 4.2 editor though. Im so sorry if it cause you any trouble. Perhaps there's a better way to configure our packaged game to always open as a listen server? I notice that shooter demo is configured to do this but I just couldn't find out how..
                    Last edited by KillerPenguin; 06-05-2014, 11:32 AM.

                    Comment


                      #11
                      Great to hear from you Josh!

                      Killer Penguin is your issue resolved now? or is there more?

                      ~~~

                      Originally posted by mordentral View Post
                      FStaticPrimitiveDrawInterface:rawMesh no longer takes 4 arguments.

                      Old Function
                      Code:
                      	virtual void DrawMesh(
                      		const FMeshBatch& Mesh,
                      		float MinDrawDistance,
                      		float MaxDrawDistance,
                      		bool bShadowOnly = false
                      		) = 0;
                      New Function
                      Code:
                      	virtual void DrawMesh(
                      		const FMeshBatch& Mesh,
                      		float ScreenSize,
                      		bool bShadowOnly = false
                      		) = 0;
                      Since pretty much every instance of drawmesh was using 0,FLT_MAX anyway I think they felt it appropriate to cut it down to the FLT_MAX.
                      Thanks for sharing this info Mordentral !



                      Rama
                      UE4 Marketplace: Melee Weapon Plugin & Compressed Binary Save System Plugin | Rama's C++ AI Jumping Videos | Vertex Snap Editor Plugin

                      ♥ Rama

                      Comment


                        #12
                        Originally posted by KillerPenguin View Post
                        Arr yes, this is probably related to my other post about c++ network. To keep things short, we couldn't figure out how to always open our packaged game as a listen server without using the command line. So as a work around, we have our game reopen the map with ?listen if it's a standalone.

                        I didn't expect it to crash the 4.2 editor though. Perhaps there's a better way to configure our packaged game to always open as a listen server? I notice that shooter demo is configured to do this but I couldn't find out how..
                        Well I don't expect it to crash either, which is why I need to understand better how you are running it. You launch the editor with WHAT for a commandline? And then you do WHAT do start the game? You aren't just starting a listen server inside the editor while its ticking are you? You use the PLAY button with some configuration?


                        Launching as a listen server without commandline arguments is demonstrated in ShooterGame. Try the following.

                        Code:
                        FString NewURL = "mapname";
                        if (IWantAServer())
                        {
                           NewURL  += TEXT("?listen"); //and anything else you need
                        }
                        
                        World->ServerTravel(NewURL, true, true);
                        I would really like to repro that crash before you move on. So any details you can give me would be appreciated.

                        Comment


                          #13
                          Originally posted by Josh.Markiewicz View Post
                          I would really like to repro that crash before you move on. So any details you can give me would be appreciated.
                          This is your big chance Killer Penguin!

                          The supreme leader of UE4 networking magic wants you!

                          Rama
                          UE4 Marketplace: Melee Weapon Plugin & Compressed Binary Save System Plugin | Rama's C++ AI Jumping Videos | Vertex Snap Editor Plugin

                          ♥ Rama

                          Comment


                            #14
                            I dont want to hijack this thread, but anybody also getting the "ObjectBase.h" error ?

                            Im trying to compile my project and get the following error :

                            1>C:\Program Files\Unreal Engine\4.2\Engine\Source\Runtime\CoreUObject\Public\UObject\ObjectBase.h(10): error C2146: syntax error : missing ';' before identifier 'ScriptPointerType'
                            .....
                            Last edited by Ad3ViLl; 06-15-2014, 04:27 AM. Reason: I found the error thus no longer need to quote everything.

                            Comment


                              #15
                              Originally posted by Ad3ViLl View Post
                              I dont want to hijack this thread, but anybody also getting the "ObjectBase.h" error ?

                              Im trying to compile my project and get the following error :

                              1>C:\Program Files\Unreal Engine\4.2\Engine\Source\Runtime\CoreUObject\Public\UObject\ObjectBase.h(10): error C2146: syntax error : missing ';' before identifier 'ScriptPointerType'
                              1>C:\Program Files\Unreal Engine\4.2\Engine\Source\Runtime\CoreUObject\Public\UObject\ObjectBase.h(10): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
                              ...
                              Ok never mind. I found my error. I accidentally included a file above my "Engine.h" in the "MyProject.h" file, oops :-)

                              Comment

                              Working...
                              X