UE4 Error:must include the same precompiled header first.
编译时如果出现这样的错误:
1 2 3 4 5 6 7 8 9 10 11 12
1>------ Build started: Project: NetExampleDemo, Configuration: Development_Game x64 ------ 1>Performing full C++ include scan (building a new target) 1>Creating makefile for NetExampleDemo (changes to module files) 1>EXEC : error : All source files in module "WebBrowserEx" must include the same precompiled header first. Currently "C:\Users\visionsmile\Documents\Unreal Projects\Examples\NetExampleDemo\Plugins\WebBrowserEx\Source\WebBrowserEx\Public\WebBrowserEx.h" is included by most of the source files. The following source files are not including "C:\Users\visionsmile\Documents\Unreal Projects\Examples\NetExampleDemo\Plugins\WebBrowserEx\Source\WebBrowserEx\Public\WebBrowserEx.h" as their first include: 1> 1> C:\Users\visionsmile\Documents\Unreal Projects\Examples\NetExampleDemo\Plugins\WebBrowserEx\Source\WebBrowserEx\Private\WebBrowserExWidget.cpp (including C:\Users\visionsmile\Documents\Unreal Projects\Examples\NetExampleDemo\Plugins\WebBrowserEx\Source\WebBrowserEx\Public\WebBrowserExWidget.h) 1> 1> 1> To compile this module without implicit precompiled headers, add "PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;" to WebBrowserEx.build.cs. 1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\VC\VCTargets\Microsoft.MakeFile.Targets(44,5): error MSB3075: The command""C:\Program Files\Epic Games\UE_4.18\Engine\Build\BatchFiles\Build.bat" NetExampleDemo Win64 Development "C:\Users\visionsmile\Documents\Unreal Projects\Examples\NetExampleDemo\NetExampleDemo.uproject" -waitmutex" exited with code 5. Please verify that you have sufficient rights to run this command. 1>Done building project "NetExampleDemo.vcxproj" -- FAILED. ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
/** * Accept or reject a player attempting to join the server. Fails login if you set the ErrorMessage to a non-empty string. * PreLogin is called before Login. Significant game time may pass before Login is called * * @param Options The URL options (e.g. name/spectator) the player has passed * @param Address The network address of the player * @param UniqueId The unique id the player has passed to the server * @param ErrorMessage When set to a non-empty value, the player will be rejected using the error message set */ virtualvoidPreLogin(const FString& Options, const FString& Address, const FUniqueNetIdRepl& UniqueId, FString& ErrorMessage);
GameMode的PreLogin调用栈为:
当玩家被拒绝加入游戏时,服务器会发送给当前连接的客户端错误消息:
1 2 3
// call in server send to client // function is UWorld::NotifyControlMessage FNetControlMessage<NMT_Failure>::Send(Connection, ErrorMsg);
// Only handle failure at this level for game or pending net drivers. FName NetDriverName = NetDriver->NetDriverName; if (NetDriverName == NAME_GameNetDriver || NetDriverName == NAME_PendingNetDriver) { // If this net driver has already been unregistered with this world, then don't handle it. if (World) { if (!FindNamedNetDriver(World, NetDriverName)) { // This netdriver has already been destroyed (probably waiting for GC) return; } }
// Give the GameInstance a chance to handle the failure. HandleNetworkFailure_NotifyGameInstance(World, NetDriver, FailureType);
ENetMode FailureNetMode = NetDriver->GetNetMode(); // NetMode of the driver that failed bool bShouldTravel = true;
switch (FailureType) { case ENetworkFailure::FailureReceived: break; case ENetworkFailure::PendingConnectionFailure: // TODO stop the connecting movie break; case ENetworkFailure::ConnectionLost: // Hosts don't travel when clients disconnect bShouldTravel = (FailureNetMode == NM_Client); break; case ENetworkFailure::ConnectionTimeout: // Hosts don't travel when clients disconnect bShouldTravel = (FailureNetMode == NM_Client); break; case ENetworkFailure::NetGuidMismatch: case ENetworkFailure::NetChecksumMismatch: // Hosts don't travel when clients have actor issues bShouldTravel = (FailureNetMode == NM_Client); break; case ENetworkFailure::NetDriverAlreadyExists: case ENetworkFailure::NetDriverCreateFailure: case ENetworkFailure::OutdatedClient: case ENetworkFailure::OutdatedServer: default: break; }
if (bShouldTravel) { CallHandleDisconnectForFailure(World, NetDriver); } } }
if (World != nullptr && World->GetGameInstance() != nullptr) { World->GetGameInstance()->HandleNetworkError(FailureType, bIsServer); } else { // Since the UWorld passed in might be null, as well as the NetDriver's UWorld, // go through the world contexts until we find the one with this net driver. for (auto& Context : WorldList) { if (Context.PendingNetGame != nullptr && Context.PendingNetGame->NetDriver == NetDriver && Context.OwningGameInstance != nullptr) { // Use the GameInstance from the current context. Context.OwningGameInstance->HandleNetworkError(FailureType, bIsServer); } } } }
// Runtime\Engine\Classes\Engine\EngineBaseType.h /** Types of network failures broadcast from the engine */ UENUM(BlueprintType) namespace ENetworkFailure { enumType { /** A relevant net driver has already been created for this service */ NetDriverAlreadyExists, /** The net driver creation failed */ NetDriverCreateFailure, /** The net driver failed its Listen() call */ NetDriverListenFailure, /** A connection to the net driver has been lost */ ConnectionLost, /** A connection to the net driver has timed out */ ConnectionTimeout, /** The net driver received an NMT_Failure message */ FailureReceived, /** The client needs to upgrade their game */ OutdatedClient, /** The server needs to upgrade their game */ OutdatedServer, /** There was an error during connection to the game */ PendingConnectionFailure, /** NetGuid mismatch */ NetGuidMismatch, /** Network checksum mismatch */ NetChecksumMismatch }; }
fatal error C1853: 'C:\Program Files\Epic Games\UE_4.19\Engine\Intermediate\Build\Win64\UE4Editor\Development\Engine\SharedPCH.Engine.h.pch' precompiled header file is from a previous version of the compiler, or the precompiled header is C++ and you are using it from C (or vice versa
// Add interface functions to this class. This is the class that will be inherited to implement this interface. public: // ... UFUNCTION(BlueprintImplementableEvent, BlueprintCallable) FClampData GetAssetClampData()const; };
// Source/Editor/UnrealEd/Private/CookOnTheFlyServer.cpp(UE4.18.3) // need to subtract 32 because the SavePackage code creates temporary files with longer file names then the one we provide // projects may ignore this restriction if desired const int32 CompressedPackageFileLengthRequirement = bConsiderCompressedPackageFileLengthRequirements ? 32 : 0; const FString FullFilename = FPaths::ConvertRelativePathToFull(PlatFilename); if (FullFilename.Len() >= (PLATFORM_MAX_FILEPATH_LENGTH - CompressedPackageFileLengthRequirement)) { LogCookerMessage(FString::Printf(TEXT("Couldn't save package, filename is too long: %s"), *PlatFilename), EMessageSeverity::Error); UE_LOG(LogCook, Error, TEXT("Couldn't save package, filename is too long :%s"), *PlatFilename); Result = ESavePackageResult::Error; }
显然UE并没有使用Windows提供的MAX_PATH宏,硬编码为了260,即在UE中Windows上的文件路径最大长度为260个字符(在启用bConsiderCompressedPackageFileLengthRequirements时还要减去32个字符),虽然Windows10要[移除260字符的限制](Microsoft removes 260 character limit for NTFS Path in new Windows 10 Insider Preview),引擎里已经支持,(UE4.22 Released支持了长文件名的特性(实验性))。
Sets the type of Module. Valid options are Runtime, RuntimeNoCommandlet, Developer, Editor, EditorNoCommandlet, and Program. This type determines which types of applications this Plugin’s Module is suitable for loading in. For example, some plugins may include modules that are only designed to be loaded when the editor is running. Runtime modules will be loaded in all cases, even in shipped games. Developer modules will only be loaded in development runtime or editor builds, but never in shipping builds. Editor modules will only be loaded when the editor is starting up. Your Plugin can use a combination of modules of different types.
// Engine\Programs\UnrealBuildTool\System\ModuleDescriptor.cs // The type of host that can load a module publicenum ModuleHostType { Default,
// Any target using the UE4 runtime Runtime,
// Any target except for commandlet RuntimeNoCommandlet,
// Any target or program RuntimeAndProgram,
// Loaded only in cooked builds CookedOnly,
// Loaded only when the engine has support for developer tools enabled Developer,
// Loaded only by the editor Editor,
// Loaded only by the editor, except when running commandlets EditorNoCommandlet,
// Loaded only by programs Program,
// Loaded only by servers ServerOnly,
// Loaded only by clients ClientOnly, }
UE4 Plugin:LoadingPhase(Optional)
.uplugin Module LoadingPhase Descriptors.
If specified, controls when the plugin is loaded at start-up. This is an advanced option that should not normally be required. The valid options are Default(which is used when no LoadingPhase is specified), PreDefault, and PostConfigInit. PostConfigInit enables the module to be loaded before the engine has finished starting up key subsystems. PreDefault loads just before the normal phase. Typically, this is only needed if you expect game modules to depend directly on content within your plugin, or types declared within the plugin’s code.
// Engine\Programs\UnrealBuildTool\System\ModuleDescriptor.cs // Indicates when the engine should attempt to load this module publicenum ModuleLoadingPhase { /// Loaded at the default loading point during startup (during engine init, after game modules are loaded.) Default,
// Right after the default phase PostDefault,
// Right before the default phase PreDefault,
// Loaded before the engine is fully initialized, immediately after the config system has been initialized. Necessary only for very low-level hooks PostConfigInit, // After PostConfigInit and before coreUobject initialized. used for early boot loading screens before the uobjects are initialized PreEarlyLoadingScreen, // Since 4.20
// Loaded before the engine is fully initialized for modules that need to hook into the loading screen before it triggers PreLoadingScreen,
// After the engine has been initialized PostEngineInit,
// These numbers define the banner UE4 version, and are the most significant numbers when ordering two engine versions (that is, a 4.12.* version is always // newer than a 4.11.* version, regardless of the changelist that it was built with) #define ENGINE_MAJOR_VERSION 4 #define ENGINE_MINOR_VERSION 19 #define ENGINE_PATCH_VERSION 0
error LNK2001: unresolved external symbol "struct FLogCategoryLogSerialization LogSerialization" (?LogSerialization@@3UFLogCategoryLogSerialization@@A)
同时,如果出现下列错误:
1
C4577: 'noexcept' used with no exception handling mode specified; termination on exception is not guaranteed. Specify /EHsc
则在*.target.cs中添加:
1
bForceEnableExceptions = true;
即可。
UE4 Package: LogLinker Error: xxxx has an inappropriate outermos
在打包时遇到以下错误:
1 2 3 4 5
UATHelper: Packaging (Windows (64-bit)): LogLinker: Error: HOTRELOADED_INetGameMode_1 has an inappropriate outermost, it was probably saved with a deprecated outer (file: ../../../../../../SanguoWarriors/Content/CoreBP/GamePlayFramework/GameMode/Net_GameMode_VR_Ex.uasset) UATHelper: Packaging (Windows (64-bit)): LogLinker: Error: HOTRELOADED_INetGameMode_1 has an inappropriate outermost, it was probably saved with a deprecated outer (file: ../../../../../../SanguoWarriors/Content/CoreBP/GamePlayFramework/GameMode/Net_GameMode_VR_Ex.uasset) UATHelper: Packaging (Windows (64-bit)): LogLinker: Error: HOTRELOADED_INetGameMode_1 has an inappropriate outermost, it was probably saved with a deprecated outer (file: ../../../../../../SanguoWarriors/Content/CoreBP/GamePlayFramework/GameMode/Net_GameMode_VR_Ex.uasset) UATHelper: Packaging (Windows (64-bit)): LogLinker: Error: HOTRELOADED_INetGameMode_1 has an inappropriate outermost, it was probably saved with a deprecated outer (file: ../../../../../../SanguoWarriors/Content/CoreBP/GamePlayFramework/GameMode/Net_GameMode_VR_Ex.uasset) UATHelper: Packaging (Windows (64-bit)): LogLinker: Error: HOTRELOADED_INetGameMode_1 has an inappropriate outermost, it was probably saved with a deprecated outer (file: ../../../../../../SanguoWarriors/Content/CoreBP/GamePlayFramework/GameMode/Net_GameMode_VR_Ex.uasset)