UnrealEngineHTML5 / Documentation

532 stars 183 forks source link

Compiling on Linux: Missing zlib 1.2.8, libPNG-1.5.27 etc. #64

Open Cygon opened 3 years ago

Cygon commented 3 years ago

I'm trying to build this fork under Linux and I'm running into missing / wrongly set up third-party libraries.

I cloned the git repo:

git clone https://github.com/UnrealEngineHTML5/UnrealEngine \
    --branch 4.24-html5 \
    --single-branch \
    --depth 1 \
    unreal-engine-4.24-html5

(Just to be safe, I then ran git submodule update --init --recursive, but there were no submodules)

I pulled in UE4 dependencies:

./Setup.sh \
    -exclude=Win32 \
    -exclude=Win64 \
    -exclude=WinRT \
    -exclude=Android \
    -exclude=Mac \
    -exclude=IOS \
    -exclude=VS2012 \
    -exclude=VS2013 \
    -exclude=VS2015 \
    -exclude=VS2017 \
    -exclude=VS2019

(The excludes are perhaps a bit excessive, but my Unreal Engine 4.24 install, when built for Linux from Git, is already a honking 59 GiB - I'm currently doing a full checkout to see if this will affect the error, but I suspect not).

I attempted to run HTML5Setup.sh

cd /opt/unreal-engine-4.24-html5/Engine/Platforms/HTML5
./HTML5Setup.sh

But this one encountered issues. First, zlib-1.2.8.tar.gz was missing. I manually downloaded it and put it in the right folder and re-ran HTML5Setup.sh, which brought me a bit further.

Next, libPNG was missing options.awk - the sources were there, but it kept looking for files that weren't there. options.awk was the first problem, so I assume it is the original issue and the rest may be follow-up problems.

++ pwd
+ PNG_HTML5=/opt/unreal-engine-4.24-html5/Engine/Platforms/HTML5/Build/BatchFiles/ThirdParty/libPNG
+ PNG_VERSION=libPNG-1.5.27
+ PNG_HTML5_SRC=/opt/unreal-engine-4.24-html5/Engine/Platforms/HTML5/Build/BatchFiles/../../../../Source/ThirdParty/libPNG/libPNG-1.5.27
+ PNG_HTML5_DST=/opt/unreal-engine-4.24-html5/Engine/Platforms/HTML5/Build/BatchFiles/../../Source/ThirdParty/libPNG/libPNG-1.5.27
+ ZLIB_HTML5_DST=/opt/unreal-engine-4.24-html5/Engine/Platforms/HTML5/Build/BatchFiles/../../Source/ThirdParty/zlib/v1.2.8
+ '[' '!' -d /opt/unreal-engine-4.24-html5/Engine/Platforms/HTML5/Build/BatchFiles/../../Source/ThirdParty/libPNG/libPNG-1.5.27/lib-1.39.0-fc ']'
+ mkdir -p /opt/unreal-engine-4.24-html5/Engine/Platforms/HTML5/Build/BatchFiles/../../Source/ThirdParty/libPNG/libPNG-1.5.27/lib-1.39.0-fc
++ uname
+ SYSTEM=Linux
+ [[ Linux == \D\a\r\w\i\n ]]
+ perl -i -p0e 's/\r\n/\n/g' /opt/unreal-engine-4.24-html5/Engine/Platforms/HTML5/Build/BatchFiles/../../../../Source/ThirdParty/libPNG/libPNG-1.5.27/scripts/options.awk
Can't open /opt/unreal-engine-4.24-html5/Engine/Platforms/HTML5/Build/BatchFiles/../../../../Source/ThirdParty/libPNG/libPNG-1.5.27/scripts/options.awk: No such file or directory.

What might be going wrong?

Any suggestions?

Cygon commented 3 years ago

I downloaded all of the dependencies this time around, and the build goes a lot further (indicating that there's really some ugly grabbing of libraries from other platform's directories happening), but the build still fails:

[100%] Linking C static library libogg.bc
[100%] Linking C static library libogg.bc
[100%] Linking C static library libogg.bc
[100%] Linking CXX static library /opt/unreal-engine-4.24-html5/Engine/Platforms/HTML5/Intermediate/1.39.0-fc-mt/harfbuzz-2.4.0/libharfbuzz.bc
[100%] Linking CXX static library /opt/unreal-engine-4.24-html5/Engine/Platforms/HTML5/Intermediate/1.39.0-fc-mt/harfbuzz-2.4.0/libharfbuzz.bc
[100%] Linking CXX static library /opt/unreal-engine-4.24-html5/Engine/Platforms/HTML5/Intermediate/1.39.0-fc-mt/harfbuzz-2.4.0/libharfbuzz.bc
[100%] Linking C static library libfreetype.bc
[100%] Linking C static library libfreetype.bc
[100%] Linking C static library libfreetype.bc
[ 89%] Linking C static library libpng15.bc
[ 89%] Linking C static library libpng15.bc
[ 89%] Linking C static library libpng15.bc
[100%] Linking C static library libopus.bc
[100%] Linking C static library libopus.bc
[100%] Linking C static library libopus.bc
[100%] Linking CXX static library /opt/unreal-engine-4.24-html5/Engine/Platforms/HTML5/Intermediate/1.39.0-fc-mt/icu4c-64_1/libicu.bc
[100%] Linking CXX static library /opt/unreal-engine-4.24-html5/Engine/Platforms/HTML5/Intermediate/1.39.0-fc-mt/icu4c-64_1/libicu.bc
[100%] Linking CXX static library /opt/unreal-engine-4.24-html5/Engine/Platforms/HTML5/Intermediate/1.39.0-fc-mt/icu4c-64_1/libicu.bc
Success!
./Build_All_HTML5_libs.sh: line 180: play: command not found

Also, re-running HTML5-Setup.sh repeats the whole build from scratch. Is there no build system in place?

The offending statement is in Engine/Platforms/HTML5/Build/BatchFiles/play_audio_feedback(), it calls a unknown tool named play, I assume it's an undeclared dependency on some command-line audio player that may ship by default with some distros. Will try to install or fake that one...

Cygon commented 3 years ago

With a fake play executable it builds.

The console is spammed with messages like these:

  Running UnrealHeaderTool CrashReportClient "/opt/unreal-engine-4.24-html5/Engine/Intermediate/Build/Linux/B4D820EA/CrashReportClient/Shipping/CrashReportClient.uhtmanifest" -LogCmds="loginit warning, logexit warning, logdatabase error" -Unattended -WarningsAsErrors
LogUnixPlatformFile: Warning: Cannot determine whether '/opt/unreal-engine-4.24-html5/Engine/Platforms/HTML5/Intermediate/1.39.0-fc/libPNG-1.5.27/BUILD_Oz/lib/libpng.bc' is a directory - d_type not supported and stat() failed with errno=2 (No such file or directory)
LogUnixPlatformFile: Warning: Cannot determine whether '/opt/unreal-engine-4.24-html5/Engine/Platforms/HTML5/Intermediate/1.39.0-fc/libPNG-1.5.27/BUILD_Oz/lib/libpng-config' is a directory - d_type not supported and stat() failed with errno=2 (No such file or directory)
LogUnixPlatformFile: Warning: Cannot determine whether '/opt/unreal-engine-4.24-html5/Engine/Platforms/HTML5/Intermediate/1.39.0-fc/libPNG-1.5.27/BUILD_Oz/lib/libpng.pc' is a directory - d_type not supported and stat() failed with errno=2 (No such file or directory)

But that seems to have no negative effect. Looking at the reported files, they're symlinks pointing to non-existent files (but the targeted files exist one directory level up).

So UE4-HTML5 compiles and runs now.

Cygon commented 3 years ago

Packaging a test project for HTML5 succeeds, but it doesn't work in my browser (Firefox) and displays the following message:

LinkError: shared memory is disabled

Looks like UE4 is using a feature FireFox disabled in 2018: https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/ It is back in Firefox 79: https://hacks.mozilla.org/2020/07/firefox-79/

The Firefox ESR update channel (which I'm on) is still at Firefox 78, so at least it's not a showstopper, but it'll probably be 2021 until most of the Firefox install base are on 79+.

ZeusLT commented 3 years ago

You can enable sharedmemory in firefox flags on any version of firefox afaik. It is not ideal solution tho. Chrome should work without tinkering,

Cygon commented 3 years ago

Yep, that was my concern, whether it works out-of-the-box for normal Firefox users.

I've upgraded to Firefox 79.0 to test, it does have shared memory enabled by default (and I can also work around it by disabling WebAssembly threading in the build settings), but then my error message merely changes to:

ReferenceError: SharedArrayBuffer is not defined

Googling revealed that SharedArrayBuffer is only enabled for Firefox users on localhost or with https + valid certificate, but since I was on localhost, there probably was another issue... or it's just simply broken.

ZeusLT commented 3 years ago

I am interested in resolving this issue, I've looked around and found that to allow shared memory website where project is hosted need headers:

Cross-Origin-Opener-Policy with same-origin as value 
Cross-Origin-Embedder-Policy with require-corp as value

here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/Planned_changes

Now I am not that experienced in this and I assume we have to modify CORS to meet those requirements, if you have any clue how to do that, let me know, it is giving me a headache.

I use AWS S3 bucket to host my HTML5 project. If you would like to throw out some ideas, I could test them on my end.

pingouin84 commented 3 years ago

hi I also have a problem with libPNG

CMake Error: File I:/ue4-4.24.3-html5/Engine/Source/ThirdParty/libPNG/libPNG-1.5.27/scripts/pnglibconf.h.prebuilt does not exist.
CMake Error at CMakeLists.txt:114 (configure_file):
  configure_file Problem configuring file

CMake Error: File I:/ue4-4.24.3-html5/Engine/Source/ThirdParty/libPNG/libPNG-1.5.27/scripts/genchk.cmake.in does not exist.
CMake Error at CMakeLists.txt:503 (configure_file):
  configure_file Problem configuring file

CMake Error: File I:/ue4-4.24.3-html5/Engine/Source/ThirdParty/libPNG/libPNG-1.5.27/scripts/genout.cmake.in does not exist.
CMake Error at CMakeLists.txt:505 (configure_file):
  configure_file Problem configuring file

CMake Error: File I:/ue4-4.24.3-html5/Engine/Source/ThirdParty/libPNG/libPNG-1.5.27/scripts/gensrc.cmake.in does not exist.
CMake Error at CMakeLists.txt:507 (configure_file):
  configure_file Problem configuring file

CMake Error: File I:/ue4-4.24.3-html5/Engine/Source/ThirdParty/libPNG/libPNG-1.5.27/libpng.pc.in does not exist.
CMake Error at CMakeLists.txt:526 (configure_file):
  configure_file Problem configuring file

failed to create symbolic link 'lib/libpng.pc': No error
failed to create symbolic link 'libpng.pc': No error
CMake Error: File I:/ue4-4.24.3-html5/Engine/Source/ThirdParty/libPNG/libPNG-1.5.27/libpng-config.in does not exist.
CMake Error at CMakeLists.txt:530 (configure_file):
  configure_file Problem configuring file

failed to create symbolic link 'lib/libpng-config': No error
failed to create symbolic link 'libpng-config': No error
CMake Warning (dev) at CMakeLists.txt:581 (get_target_property):
  Policy CMP0026 is not set: Disallow use of the LOCATION target property.
  Run "cmake --help-policy CMP0026" for policy details.  Use the cmake_policy
  command to set the policy and suppress this warning.

  The LOCATION property should not be read from target "png_static".  Use the
  target name directly with add_custom_command, or use the generator
  expression $<TARGET_FILE>, as appropriate.

This warning is for project developers.  Use -Wno-dev to suppress it.

failed to create symbolic link 'lib/libpng.a': No error
failed to create symbolic link 'libpng.a': No error
-- Configuring incomplete, errors occurred!
See also "I:/ue4-4.24.3-html5/Engine/Platforms/HTML5/Intermediate/1.39.18-up/libPNG-1.5.27/BUILD_O2/CMakeFiles/CMakeOutput.log".
configure: cmake -G MinGW Makefiles -DM_LIBRARY= -DZLIB_INCLUDE_DIR=I:/ue4-4.24.3-html5/Engine/Platforms/HTML5/Build/BatchFiles/../../Source/ThirdParty/zlib/v1.2.8/include -DZLIB_LIBRARY=I:/ue4-4.24.3-html5/Engine/Platforms/HTML5/Build/BatchFiles/../../Source/ThirdParty/zlib/v1.2.8/lib-1.39.18-up -DEMSCRIPTEN_GENERATE_BITCODE_STATIC_LIBRARIES=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS_RELEASE=-O2 -DNDEBUG -s WASM=1 -s WASM_OBJECT_FILES=1 -Wno-implicit-function-declaration -I"/i/ue4-4.24.3-html5/Engine/Platforms/HTML5/Build/BatchFiles/../../Source/ThirdParty/zlib/v1.2.8/include"  -DPNG_SHARED=OFF I:/ue4-4.24.3-html5/Engine/Platforms/HTML5/Build/BatchFiles/../../../../Source/ThirdParty/libPNG/libPNG-1.5.27 -DCMAKE_TOOLCHAIN_FILE=I:\ue4-4.24.3-html5\Engine\Platforms\HTML5\Build\emsdk\emsdk-1.39.18\upstream\emscripten\cmake\Modules\Platform\Emscripten.cmake -DCMAKE_CROSSCOMPILING_EMULATOR="I:/ue4-4.24.3-html5/Engine/Platforms/HTML5/Build/emsdk/emsdk-1.39.18/node/12.18.1_64bit/bin/node.exe"