github.com/
登录ue4官网,点击个人,然后关联。
(注意有的人是很久之前注册过的,也关联过GitHub账号的,但是没有加入EpicGame的team,导致下载不了源码引擎。可以点解除关联,然后再重新关联,EpicGame会给你发邮箱加入开发者team。)
点击GitHub头像,左下角说明已经加入了ue4的开发者team,可以访问ue4的私有库.
2.选择对应的版本下载即可
在中国大陆地区不建议使用git clone的方式,建议使用下载压缩包
git clone -b v4.27.2 https://github.com/EpicGames/UnrealEngine.git
3.下载代码,修改Setup.bat
代码下载完成后,进行解压缩。修改Setup.bat文件,搜索set PROMPT_ARGUMENT=--prompt ,在其后面增加如下
set PROMPT_ARGUMENT=--prompt --cache=D:\uedepTmpLinux --threads=40 --exclude=iOS --exclude=Android --exclude=Win32 --exclude=osx32 --exclude=osx64
根据需求进行修改,这个代码是开启多线程,进行缓存,排除不需要的依赖
点击Setup.bat,等待一段时间,差不多一个小时左右,主要依赖网络的速度。
4.生成解决方案
点击GenerateProjectFiles.bat,生成UE4.sln解决方案
5.编译UE4工程
打开UE4.sln,选择如下方式,进行编译,差不多需要40分钟左右,具体依赖于电脑的配置。
6.编译完成后,选择UnrealVersionSelector-Win64-Shipping.exe,进行注册
二.Demo的编译与打包
7.编译demo
选择项目进行编译,该demo采用插件的方式,开发了grpc client,可以在游戏的过程中发送grpc请求。
git clone https://github.com/vizor-games/InfraworldRuntimeExample.git
选中InfraworldDemo.uproject,右键选择下图所示的1,即可生成解决方案,选择2可以进行引擎的切换
8.编译InfraworldRuntimeExample
需要把插件放在plugins目录下,也可以下载使用预先编译好的插件。
git clone https://github.com/vizor-games/InfraworldRuntime.git
选择如下编译方式,进行编译
9.编译完成,看效果
具体如下所示(没啥事不要总是点击重新编译,这个会花费很多时间的)
10.Windows平台打包
按照下图所示之后,然后选择文件夹,如WindowsPackage
三.Linux版本的编译与打包
11.UE4打包Linux版本的grpc库
在讨论这个问题的时候,并不是说把grpc版本下载下载,直接使用cmake的方式进行编译,这个是常规C++的项目,进行的操作,我们采用的是UE4加载grpc的方式,需要按照规则进行处理。
下载如下代码
git clone https://github.com/vizor-games/InfraworldRuntime.git
安装需要有些编译的组件
wget http://mirrors.kernel.org/gnu/m4/m4-1.4.13.tar.gz
tar -xzvf m4-1.4.13.tar.gz \
cd m4-1.4.13
./configure –-prefix=/usr/local
make &&sudo make install
安装autoconf
wget http://mirrors.kernel.org/gnu/autoconf/autoconf-2.65.tar.gz
tar -xzvf autoconf-2.65.tar.gz
cd autoconf-2.65
./configure –prefix=/usr/local
make && sudo make install
安装automake
wget http://mirrors.kernel.org/gnu/automake/automake-1.11.tar.gz
tar xzvf automake-1.11.tar.gz
cd automake-1.11 \
./configure –-prefix=/usr/local
make && sudo make install
安装libtool
wget http://mirrors.kernel.org/gnu/libtool/libtool-2.2.6b.tar.gz
tar xzvf libtool-2.2.6b.tar.gz
cd libtool-2.2.6b
./configure –prefix=/usr/local
make && sudo make install
安装golang
wget -c https://dl.google.com/go/go1.17.8.linux-amd64.tar.gz -O - | sudo tar -xz -C /usr/local
vi /etc/profile
#添加路径
export PATH=$PATH:/usr/local/go/bin
#保存之后,让其生效
source /etc/profile
#验证golang环境是搭建好
go version 或者go env
安装完成后修改 Setup.sh代码
#!/bin/bash
set -e
branch=${branch:-v1.23.x}
clean=${clean:-true}
VAR_GIT_BRANCH=$branch
VAR_CLEAR_REPO=$clean
REMOTE_ORIGIN="https://github.com/grpc/grpc.git"
GOSUPPORT_REMOTE_ORIGIN="https://github.com/golang/protobuf.git"
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
GRPC_FOLDER_NAME=grpc
GRPC_ROOT="${SCRIPT_DIR}/${GRPC_FOLDER_NAME}"
DEPS=(git automake autoconf libtool make strip go pkg-config)
UE_ROOT=${UE_ROOT:-"/home/xiedeju/UE4.27/"}
if [ ! -d "$UE_ROOT" ]; then
echo "UE_ROOT directory ${UE_ROOT} does not exist, please set correct UE_ROOT"
exit 1
UE_PREREQUISITES="${UE_ROOT}/Engine/Extras/ThirdPartyNotUE/SDKs/HostLinux/Linux_x64/v19_clang-11.0.1-centos7/x86_64-unknown-linux-gnu"
OPENSSL_LIB="${UE_ROOT}/Engine/Source/ThirdParty/OpenSSL/1.1.1k/lib/Linux/x86_64-unknown-linux-gnu"
OPENSSL_INCLUDE="${UE_ROOT}/Engine/Source/ThirdParty/OpenSSL/1.1.1k/include/Linux/x86_64-unknown-linux-gnu"
echo "SCRIPT_DIR=${SCRIPT_DIR}"
echo "GRPC_ROOT=${GRPC_ROOT}"
for i in ${DEPS[@]}; do
if [ ! "$(which ${i})" ];then
echo "${i} not found, install via 'apt-get install ${i}'" && exit 1
if [ $(uname) != 'Linux' ]; then
echo "Can not work under $(uname) operating system, should be Linux! Exiting..."
exit 1
if [ ! -d "$GRPC_ROOT" ]; then
echo "Cloning repo into ${GRPC_ROOT}"
git clone $REMOTE_ORIGIN $GRPC_ROOT
echo "Pulling repo"
(cd $GRPC_ROOT)
echo "Checking out branch ${VAR_GIT_BRANCH}"
(cd $GRPC_ROOT && git checkout -t origin/$VAR_GIT_BRANCH || true)
(cd $GRPC_ROOT && git submodule update --init)
if [ "$VAR_CLEAR_REPO" = "true" ]; then
echo "Cleaning repo and submodules because VAR_CLEAR_REPO is set to ${VAR_CLEAR_REPO}"
(cd $GRPC_ROOT && make clean)
(cd $GRPC_ROOT && git clean -fdx)
(cd $GRPC_ROOT && git submodule foreach git clean -fdx)
elif [ "$VAR_CLEAR_REPO" = "false" ]; then
echo "Cleaning is not needed!"
echo "Undefined behaviour, VAR_CLEAR_REPO is ${VAR_CLEAR_REPO}!"
exit 1
HEADERS_DIR="${SCRIPT_DIR}/GrpcIncludes"
PROTOBUF_SRC_DIR="${HEADERS_DIR}/third_party/protobuf"
if [ -d "$HEADERS_DIR" ]; then
printf '%s\n' "Removing old $HEADERS_DIR"
rm -rf "$HEADERS_DIR"
mkdir $HEADERS_DIR
mkdir -p $PROTOBUF_SRC_DIR
cp -R "${GRPC_ROOT}/include" $HEADERS_DIR
cp -R "${GRPC_ROOT}/third_party/protobuf/src" $PROTOBUF_SRC_DIR
UNAME_MACH=$(echo $(uname -m) | tr '[:upper:]' '[:lower:]')
UNAME_OS=$(echo $(uname) | tr '[:upper:]' '[:lower:]')
UNAME_ARCH="${UNAME_MACH}-unknown-${UNAME_OS}-gnu"
LIBCXX_UE_DIR="${UE_ROOT}/Engine/Source/ThirdParty/Linux/LibCxx/include"
LIBC_UE_DIR="${UE_ROOT}/Engine/Source/ThirdParty/Linux/LibCxx/include"
export CC="${UE_PREREQUISITES}/bin/clang"
export CC_FOR_BUILD=${CC}
export CXX="${UE_PREREQUISITES}/bin/clang++"
export CXX_FOR_BUILD=${CXX}
if [ ! -e "${UE_PREREQUISITES}/bin/lld-gnu" ]; then
ln -s "${UE_PREREQUISITES}/bin/ld.lld" "${UE_PREREQUISITES}/bin/lld-gnu"
find "${UE_PREREQUISITES}/usr/lib64" -name '*.o' -exec cp -vfs '{}' "${UE_PREREQUISITES}/lib64" ";"
export VALID_CONFIG_gcov=0
export HAS_SYSTEM_CARES=false
export HAS_SYSTEM_PROTOBUF=false
export HAS_SYSTEM_ZLIB=false
export LD="${CC}"
export LDXX="${CXX}"
export DEFAULT_CC="${CC}"
export DEFAULT_CXX="${CXX}"
export CFLAGS="-fPIC -Wno-error --sysroot=${UE_PREREQUISITES}"
export CFLAGS_FOR_BUILD=${CFLAGS}
export CXXFLAGS="-std=c++14 -fPIC -nostdinc++ -Wno-expansion-to-defined -Wno-error -I${LIBCXX_UE_DIR} -I${LIBCXX_UE_DIR}/c++/v1 -I${OPENSSL_INCLUDE}"
export CXXFLAGS_FOR_BUILD=${CXXFLAGS}
export LIBRARY_PATH="${UE_PREREQUISITES}/usr/lib64"
export LDFLAGS="-L${UE_ROOT}/Engine/Source/ThirdParty/Linux/LibCxx/lib/Linux/${UNAME_ARCH} -L${OPENSSL_LIB} -fuse-ld=${UE_PREREQUISITES}/bin/lld-gnu"
export LDFLAGS_FOR_BUILD=${LDFLAGS}
export LDLIBS="-lc++ -lc++abi -lc"
export PROTOBUF_LDFLAGS_EXTRA="${LDFLAGS} ${LDLIBS}"
if [ ! -e "${LIBCXX_UE_DIR}/c++/v1/xlocale.h" ]; then
if [ ! -e "${LIBCXX_UE_DIR}/c++/v1/clocale" ]; then
echo "${LIBCXX_UE_DIR}/c++/v1/clocale must exist in UE src dir. Exiting..." && exit 1
(cd "${LIBCXX_UE_DIR}/c++/v1" && ln -s clocale xlocale.h)
echo "Created an alias to xlocale.h"
echo "CFLAGS=${CFLAGS}, CXXFLAGS=${CXXFLAGS}, LDFLAGS=${LDFLAGS}, LDLIBS=${LDLIBS}, PROTOBUF_LDFLAGS_EXTRA=${PROTOBUF_LDFLAGS_EXTRA}"
(cd $GRPC_ROOT && make CC=${CC} CXX=${CXX})
LIBS_DIR="${SCRIPT_DIR}/GrpcLibraries"
BIN_DIR="${SCRIPT_DIR}/GrpcPrograms"
echo "LIBS_DIR is ${LIBS_DIR}"
echo "BIN_DIR is ${BIN_DIR}"
if [ $(uname) != 'Darwin' ]; then
ARCH_LIBS_DIR="${LIBS_DIR}/"$(uname)
ARCH_BIN_DIR="${BIN_DIR}/"$(uname)
ARCH_LIBS_DIR="${LIBS_DIR}/Mac"
ARCH_BIN_DIR="${BIN_DIR}/Mac"
echo "ARCH_LIBS_DIR is ${ARCH_LIBS_DIR}"
echo "ARCH_BIN_DIR is ${ARCH_BIN_DIR}"
if [ -d "$ARCH_LIBS_DIR" ]; then
printf '%s\n' "Removing old $ARCH_LIBS_DIR"
rm -rf "$ARCH_LIBS_DIR"
if [ -d "$ARCH_BIN_DIR" ]; then
printf '%s\n' "Removing old $ARCH_BIN_DIR"
rm -rf "$ARCH_BIN_DIR"
mkdir -p $ARCH_LIBS_DIR
mkdir -p $ARCH_BIN_DIR
SRC_LIBS_FOLDER_GRPC=$GRPC_ROOT/libs/opt
SRC_LIBS_FOLDER_PROTOBUF=$PROTOBUF_ROOT/src/.libs
if [ -d "$SRC_LIBS_FOLDER_PROTOBUF" ]; then
echo "Copying protobuf libraries from ${SRC_LIBS_FOLDER_PROTOBUF} to ${ARCH_LIBS_DIR}"
(cd $SRC_LIBS_FOLDER_PROTOBUF && find . -name '*.a' -exec cp -vf '{}' $ARCH_LIBS_DIR ";")
if [ -d "$SRC_LIBS_FOLDER_GRPC" ]; then
echo "Copying grpc libraries from ${SRC_LIBS_FOLDER_GRPC} to ${ARCH_LIBS_DIR}"
(cd $SRC_LIBS_FOLDER_GRPC && find . -name '*.a' -exec cp -vf '{}' $ARCH_LIBS_DIR ";")
(cd $ARCH_LIBS_DIR && strip -S *.a)
echo "Copying executables to ${ARCH_BIN_DIR}"
(cp -a "${GRPC_ROOT}/bins/opt/." $ARCH_BIN_DIR)
(cp -a "${GRPC_ROOT}/bins/opt/protobuf/." $ARCH_BIN_DIR)
(cd $ARCH_BIN_DIR && rm -rf protobuf)
GOROOT_DIR="${GRPC_ROOT}/go_packages"
GOPROTO_DIR="${GOROOT_DIR}/src/github.com/golang/protobuf"
echo "Building golang support in ${GOPROTO_DIR}"
if [ ! -d "${GOPROTO_DIR}" ]; then
(cd $GRPC_ROOT && git clone $GOSUPPORT_REMOTE_ORIGIN $GOPROTO_DIR)
(cd $GOPROTO_DIR && git pull)
export GOPATH=$GOROOT_DIR
(cd "${GOPROTO_DIR}/protoc-gen-go" && go build)
(cp "${GOPROTO_DIR}/protoc-gen-go/protoc-gen-go" $ARCH_BIN_DIR)
(cd $ARCH_BIN_DIR && strip -S *)
rm "${LIBCXX_UE_DIR}/c++/v1/xlocale.h"
rm "${UE_PREREQUISITES}/bin/lld-gnu"
find "${UE_PREREQUISITES}/lib64" -name '*.o' -type f -delete
echo 'BUILD DONE!'
执行 ./Setup.sh ,会进行代码下载以及编译。(注意grpc源码下载以及编译问题)
等待执行完成,进行编译后,将会生成如下所示。
提供给外部使用的Linux版本的grpc的库如下所示,只有这15个库,多余的话,可能会产生重定义的情况
12.打包Linux版本的demo
需要依赖windows版本编译出来的UEditor出现的图形界面(UBT命令行也可以编译),进行编译
选择对应的文件夹,然后开始打包
四.报错处理
1.遇到如下错误,是由于代码是从windows上下载下来的
.ibtoolize: error: AC_CONFIG_MACRO_DIRS([m4]) conflicts with ACLOCAL_AMFLAGS=-I m4
可以输入如下命令:
find . -type f -print0 | xargs -0 dos2unix
参考链接1
参考链接2
2.遇到如下报错
Syntax error: "(" unexpected
sudo dpkg-reconfigure dash
3.有时候编译的时候,可能会将部分warning提示error,导致无法进行进行编译
可以在下面的build.cs中增加
bEnableUndefinedIdentifierWarnings = false;
如果还有提示错误,可以考虑将部分warning禁用,增加如下代码,建议将其封装成一个头文件,让plugins下面的头文件,依赖该头文件,可以禁用错误。
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the
* License for the specific language governing permissions and limitations
* under the License.
#if PLATFORM_WINDOWS
#pragma warning(push)
#pragma warning (disable : 4125)
#pragma warning (disable : 4647)
#pragma warning (disable : 4668)
#pragma warning (disable : 4456)
#pragma warning (disable : 4577)
#pragma warning (disable : 4946)
#pragma warning (disable : 4005)
#pragma warning (disable : 4582)
#pragma warning (disable : 4583)
#pragma warning (disable : 4800)
#ifdef WINDOWS_PLATFORM_TYPES_GUARD
#pragma warning(push)
#include "Windows/HideWindowsPlatformTypes.h"
#endif
#elif PLATFORM_COMPILER_CLANG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wundef"
#pragma clang diagnostic ignored "-Wshadow"
#endif
4.遇到符号重定义,可以查看是哪些库函数出现了重定义
切换路径到库所在的路径下面
nm -A * 2>/dev/null | grep "T BN_value_one"
复制代码