首页 > 解决方案 > 如何在 Linux 上手动在虚幻中生成 `.generated.h` 文件?

问题描述

当我尝试打开项目时,它显示“以下模块丢失或使用不同的编辑器版本构建:<项目名称> 你想现在重建它们吗?如果我点击是,它说“<项目名称> 不能编译。尝试手动从源代码重建。”并退出。这是一个新项目,由于此错误尚未打开。(我用不同的模板尝试了几次)

因此,在研究之后,我尝试使用GenerateProjectFiles.sh -cmakefile -game -project <project file>, then cmake, then手动构建make。起初这不起作用,因为它使用的是g ++而不是clang,所以我将其更改为clang,将标准更改为c ++ 14,现在它几乎可以编译,但它抱怨.generated.h文件不存在。考虑到我无法打开编辑器、没有 Visual Studio 并且在 Linux 上工作,如何生成它们?我也无法更改安装文件,因为我没有权限(工作计算机)。

GenerateProjectFiles.sh 输出:

Setting up Unreal Engine 4 project files...

chmod: changing permissions of bin/mcs: Operation not permitted
chmod: changing permissions of bin/xbuild: Operation not permitted
Fixing inconsistent case in filenames.
Setting up Mono
<unreal dir>/Engine/Binaries/ThirdParty/Mono/Linux/lib/mono/xbuild/14.0/bin/Microsoft.Common.targets: error : Access to the path "<unreal dir>/Engine/Source/Programs/DotNETCommon/DotNETUtilities/obj/Development/DotNETUtilities.csproj.FilesWrittenAbsolute.txt" is denied.  at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) [0x0019e] in <98fac219bd4e453693d76fda7bd96ab0>:0 
  at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.IO.FileOptions options, System.String msgPath, System.Boolean bFromProxy, System.Boolean useLongPath, System.Boolean checkHost) [0x00000] in <98fac219bd4e453693d76fda7bd96ab0>:0 
  at (wrapper remoting-invoke-with-check) System.IO.FileStream..ctor(string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare,int,System.IO.FileOptions,string,bool,bool,bool)
  at System.IO.StreamWriter.CreateFile (System.String path, System.Boolean append, System.Boolean checkHost) [0x0001c] in <98fac219bd4e453693d76fda7bd96ab0>:0 
  at System.IO.StreamWriter..ctor (System.String path, System.Boolean append, System.Text.Encoding encoding, System.Int32 bufferSize, System.Boolean checkHost) [0x00055] in <98fac219bd4e453693d76fda7bd96ab0>:0 
  at System.IO.StreamWriter..ctor (System.String path, System.Boolean append, System.Text.Encoding encoding, System.Int32 bufferSize) [0x00000] in <98fac219bd4e453693d76fda7bd96ab0>:0 
  at System.IO.StreamWriter..ctor (System.String path, System.Boolean append) [0x00008] in <98fac219bd4e453693d76fda7bd96ab0>:0 
  at (wrapper remoting-invoke-with-check) System.IO.StreamWriter..ctor(string,bool)
  at Microsoft.Build.Tasks.WriteLinesToFile.Execute () [0x0002e] in <1e06a39ffa2a4ecc9361f5e710a0e7cb>:0 
<unreal dir>/Engine/Binaries/ThirdParty/Mono/Linux/lib/mono/xbuild/14.0/bin/Microsoft.Common.targets: error : Access to the path "<unreal dir>/Engine/Source/Programs/UnrealBuildTool/obj/Development/UnrealBuildTool.csproj.FilesWrittenAbsolute.txt" is denied.  at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) [0x0019e] in <98fac219bd4e453693d76fda7bd96ab0>:0 
  at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.IO.FileOptions options, System.String msgPath, System.Boolean bFromProxy, System.Boolean useLongPath, System.Boolean checkHost) [0x00000] in <98fac219bd4e453693d76fda7bd96ab0>:0 
  at (wrapper remoting-invoke-with-check) System.IO.FileStream..ctor(string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare,int,System.IO.FileOptions,string,bool,bool,bool)
  at System.IO.StreamWriter.CreateFile (System.String path, System.Boolean append, System.Boolean checkHost) [0x0001c] in <98fac219bd4e453693d76fda7bd96ab0>:0 
  at System.IO.StreamWriter..ctor (System.String path, System.Boolean append, System.Text.Encoding encoding, System.Int32 bufferSize, System.Boolean checkHost) [0x00055] in <98fac219bd4e453693d76fda7bd96ab0>:0 
  at System.IO.StreamWriter..ctor (System.String path, System.Boolean append, System.Text.Encoding encoding, System.Int32 bufferSize) [0x00000] in <98fac219bd4e453693d76fda7bd96ab0>:0 
  at System.IO.StreamWriter..ctor (System.String path, System.Boolean append) [0x00008] in <98fac219bd4e453693d76fda7bd96ab0>:0 
  at (wrapper remoting-invoke-with-check) System.IO.StreamWriter..ctor(string,bool)
  at Microsoft.Build.Tasks.WriteLinesToFile.Execute () [0x0002e] in <1e06a39ffa2a4ecc9361f5e710a0e7cb>:0 
Discovering modules, targets and source code for project...
Generating data for project indexing... 100%

犯错误:

    In file included from <project dir>/Source/MyProject2/MyProject2GameMode.cpp:3:
    <project dir>/Source/MyProject2/MyProject2GameMode.h:7:10: fatal error: 
          'MyProject2GameMode.generated.h' file not found
    #include "MyProject2GameMode.generated.h"
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    118 warnings and 1 error generated.
    make[2]: *** [CMakeFiles/FakeTarget.dir/Source/MyProject2/MyProject2GameMode.cpp.o] Error 1
    make[1]: *** [CMakeFiles/FakeTarget.dir/all] Error 2
    make: *** [all] Error 2

标签: linuxmakefilecmakeunreal-engine4

解决方案


推荐阅读