如何在 Linux 上构建和运行 Unreal C++ 项目? [英] How to build&run Unreal C++ project on Linux?

查看:71
本文介绍了如何在 Linux 上构建和运行 Unreal C++ 项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 Linux 上构建我的第一个 Unreal C++ 项目.

我按照

当我按是"时显示此错误消息:

这是日志中的错误消息:

错误:构建将修改以下引擎文件:/media/redacted-disk/UnrealEngine/Engine/Binaries/Linux/Android/UE4Editor.modules/media/redacted-disk/UnrealEngine/Engine/Binaries/Linux/Linux/UE4Editor.modules/media/redacted-disk/UnrealEngine/Engine/Binaries/Linux/UE4Editor.modules/media/redacted-disk/UnrealEngine/Engine/Plugins/2D/Paper2D/Binaries/Linux/UE4Editor.modules/media/redacted-disk/UnrealEngine/Engine/Plugins/AI/AISupport/Binaries/Linux/UE4Editor.modules... 还有很多

我尝试从 IDE 重建 UE4,然后再次构建 - 但错误仍然存​​在.如果我尝试从引擎文件启动 UE4Editor 并从那里打开项目,也会发生同样的事情.

什么会导致这个错误?为什么它甚至在我运行项目时尝试重建引擎?

解决方案

我有以下脚本将引擎脚本和二进制文件的路径添加到我的 PATH:

UNREAL_HOME=/path/to/source/of/UnrealEngine"UNREAL_SCRIPTS=${UNREAL_HOME}/Engine/Build/BatchFiles"UNREAL_SCRIPTS_LINUX=${UNREAL_HOME}/Engine/Build/BatchFiles/Linux"UNREAL_BINS=${UNREAL_HOME}/Engine/Binaries/Linux"PATH=${PATH}:${UNREAL_BINS}:${UNREAL_SCRIPTS}:${UNREAL_SCRIPTS_LINUX}"导出路径

然后我从我的项目目录中运行 UE4Editor '/absolute/path/to/project.uproject'.

我从不在引擎的源代码树中创建项目.路径应该完全不同.

我使用 VS-Code 作为 IDE.根据我的经验,这是最有效的方法.QT-Creator 仅在您创建包含大量 #define 的包含文件时才起作用,而这些文件在由 unreal 创建的 .pro 文件中缺失.

您可以通过安装 C#C/C++ 扩展 将 VS-Code 配置为具有类似完成的智能感知.我必须安装 mono 才能使 OmniSharp 工作(这是处理 VS-Code 自动完成的服务器).这是我的 VS-Code settings.json 文件的摘录:

omnisharp.path":/home/myuser/.vscode/extensions/ms-dotnettools.csharp-1.23.9/.omnisharp/1.37.6/omnisharp/OmniSharp.exe",omnisharp.monoPath":/usr/bin/mono",

您还可以安装 C++ Helper 扩展,这对于创建方法、类等很有用.

I'm trying to build my first Unreal C++ project on Linux.

I built the engine from source in accordance with "Linux Quick Start" guide. Then I installed Qt Creator and followed the "How to Set up Qt Creator for UE4" guide.

I successfully set up and ran UE4Editor, and created a new C++ project. Unfortunately when I try running the project it complains:

And when I press "yes" this error message is shown:

Here's the error message from the logs:

ERROR: Building would modify the following engine files:
       
       /media/redacted-disk/UnrealEngine/Engine/Binaries/Linux/Android/UE4Editor.modules
       /media/redacted-disk/UnrealEngine/Engine/Binaries/Linux/Linux/UE4Editor.modules
       /media/redacted-disk/UnrealEngine/Engine/Binaries/Linux/UE4Editor.modules
       /media/redacted-disk/UnrealEngine/Engine/Plugins/2D/Paper2D/Binaries/Linux/UE4Editor.modules
       /media/redacted-disk/UnrealEngine/Engine/Plugins/AI/AISupport/Binaries/Linux/UE4Editor.modules
      ... many more

I tried rebuilding UE4 from IDE, then building again - but the error still persists. Same thing happens if I try starting UE4Editor from the engine files and opening the project from there.

What could cause this error? Why does it even try to rebuild the engine when I'm tring run a project?

解决方案

I have the following script to add the paths to the engine scripts and binaries to my PATH:

UNREAL_HOME="/path/to/source/of/UnrealEngine"
UNREAL_SCRIPTS="${UNREAL_HOME}/Engine/Build/BatchFiles"
UNREAL_SCRIPTS_LINUX="${UNREAL_HOME}/Engine/Build/BatchFiles/Linux"
UNREAL_BINS="${UNREAL_HOME}/Engine/Binaries/Linux"
PATH="${PATH}:${UNREAL_BINS}:${UNREAL_SCRIPTS}:${UNREAL_SCRIPTS_LINUX}"
export PATH

Then I run UE4Editor '/absolute/path/to/project.uproject' from within the directory of my project.

I never create a project inside the source tree of the engine. Paths should absolutely be different.

I use VS-Code as the IDE. This is what works best from my experience. QT-Creator will work only if you create an include files with lots of #define that are missing from the .pro files created by unreal.

You can configure VS-Code to have an intelli-sense like completion by installing the C# and C/C++ extensions. I had to install mono in order to get OmniSharp working (this is the server than handles the autocompletion for VS-Code). Here is an extract of my VS-Code settings.json file:

"omnisharp.path": "/home/myuser/.vscode/extensions/ms-dotnettools.csharp-1.23.9/.omnisharp/1.37.6/omnisharp/OmniSharp.exe",
"omnisharp.monoPath": "/usr/bin/mono",

You can also install the C++ Helper extensions which is usefull for creating methods, classes, and so on.

这篇关于如何在 Linux 上构建和运行 Unreal C++ 项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆