godotengine / webrtc-native

The official GDNative WebRTC implementation for non-html exports.
MIT License
210 stars 34 forks source link

Cannot build on Windows #66

Open Anutrix opened 1 year ago

Anutrix commented 1 year ago

Godot version

4(master)

Plugin version

master(1436024f595fd99cd885950319867fd3d371963b)

System information

Windows 11 Pro 22H2 64 bit

Issue description

I get following error when trying to build on Windows with llvm-mingw:

> scons -j1
scons: Reading SConscript files ...
Building for architecture x86_64 on platform windows
scons: done reading SConscript files.
scons: Building targets ...
scons: `godot-cpp\bin\libgodot-cpp.windows.template_debug.x86_64.a' is up to date.
ssl_action(["deps\build\build.windows.template_debug.x86_64.Release.dir\openssl\libssl.a", "deps\build\build.windows.template_debug.x86_64.Release.dir\openssl\libcrypto.a"], ["deps\openssl"])
mkdir -p D:\Repo\webrtc-native\deps/build/build.windows.template_debug.x86_64.Release.dir/openssl
The syntax of the command is incorrect.
scons: *** Error 1
rtc_action(["deps\build\build.windows.template_debug.x86_64.Release.dir\libdatachannel\libdatachannel-static.a", "deps\build\build.windows.template_debug.x86_64.Release.dir\libdatachannel\deps\libjuice\libjuice-static.a", "deps\build\build.windows.template_debug.x86_64.Release.dir\libdatachannel\deps\libsrtp\libsrtp2.a", "deps\build\build.windows.template_debug.x86_64.Release.dir\libdatachannel\deps\usrsctp\usrsctplib\libusrsctp.a"], ["deps\libdatachannel", "deps\build\build.windows.template_debug.x86_64.Release.dir\openssl\libssl.a", "deps\build\build.windows.template_debug.x86_64.Release.dir\openssl\libcrypto.a"])
cmake -B D:\Repo\webrtc-native\deps/build/build.windows.template_debug.x86_64.Release.dir/libdatachannel -DUSE_NICE=0 -DNO_WEBSOCKET=1 -DNO_EXAMPLES=1 -DNO_WEBSOCKET=1 -DNO_TESTS=1 -DOPENSSL_USE_STATIC_LIBS=1 -DOPENSSL_INCLUDE_DIR=D:\Repo\webrtc-native\deps/build/build.windows.template_debug.x86_64.Release.dir/openssl/dest/include -DOPENSSL_SSL_LIBRARY=D:\Repo\webrtc-native\deps/build/build.windows.template_debug.x86_64.Release.dir/openssl/libssl.a -DOPENSSL_CRYPTO_LIBRARY=D:\Repo\webrtc-native\deps/build/build.windows.template_debug.x86_64.Release.dir/openssl/libcrypto.a -DCMAKE_BUILD_TYPE=Release -DOPENSSL_ROOT_DIR=D:\Repo\webrtc-native\deps/build/build.windows.template_debug.x86_64.Release.dir/openssl -G 'Unix Makefiles' -DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc -DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++ -DCMAKE_SYSTEM_NAME=Windows D:\Repo\webrtc-native\deps\libdatachannel
'cmake' is not recognized as an internal or external command,
operable program or batch file.
scons: *** Error 1
g++  -shared -o bin\extension\webrtc\lib\webrtc_native.windows.template_debug.x86_64.dll src\WebRTCLibDataChannel.o src\WebRTCLibPeerConnection.o src\init_gdextension.o $( -Ldeps\build\build.windows.template_debug.x86_64.Release.dir\openssl -Lgodot-cpp\bin -Ldeps\build\build.windows.template_debug.x86_64.Release.dir\libdatachannel $) deps\build\build.windows.template_debug.x86_64.Release.dir\libdatachannel\libdatachannel-static.a deps\build\build.windows.template_debug.x86_64.Release.dir\libdatachannel\deps\libjuice\libjuice-static.a deps\build\build.windows.template_debug.x86_64.Release.dir\libdatachannel\deps\libsrtp\libsrtp2.a deps\build\build.windows.template_debug.x86_64.Release.dir\libdatachannel\deps\usrsctp\usrsctplib\libusrsctp.a -lgodot-cpp.windows.template_debug.x86_64 deps\build\build.windows.template_debug.x86_64.Release.dir\openssl\libssl.a deps\build\build.windows.template_debug.x86_64.Release.dir\openssl\libcrypto.a -liphlpapi -lws2_32 -lbcrypt -Wl,--out-implib,libwebrtc_native.windows.template_debug.x86_64.a
=====
clang-14: error: no such file or directory: 'deps\build\build.windows.template_debug.x86_64.Release.dir\libdatachannel\libdatachannel-static.a'
clang-14: error: no such file or directory: 'deps\build\build.windows.template_debug.x86_64.Release.dir\libdatachannel\deps\libjuice\libjuice-static.a'
clang-14: error: no such file or directory: 'deps\build\build.windows.template_debug.x86_64.Release.dir\libdatachannel\deps\libsrtp\libsrtp2.a'
clang-14: error: no such file or directory: 'deps\build\build.windows.template_debug.x86_64.Release.dir\libdatachannel\deps\usrsctp\usrsctplib\libusrsctp.a'
clang-14: error: no such file or directory: 'deps\build\build.windows.template_debug.x86_64.Release.dir\openssl\libssl.a'
clang-14: error: no such file or directory: 'deps\build\build.windows.template_debug.x86_64.Release.dir\openssl\libcrypto.a'

=====
scons: *** [bin\extension\webrtc\lib\webrtc_native.windows.template_debug.x86_64.dll] Error 1
scons: building terminated because of errors.

I have cmake installed and in path.

Steps to reproduce

  1. Run scons.

Minimal reproduction project

No response

BimDav commented 1 year ago

'cmake' is not recognized as an internal or external command

you have to install cmake

Anutrix commented 1 year ago

I have cmake installed and in path.

Like I said before cmake is in path. Tested it by just running cmake in the terminal too.

Anutrix commented 1 year ago

The path all seems to be hardcoded for *nix systems(i.e, with /).

Perl and NASM seems to be needed to compile openssl. Additional it should be run in an MSYS2 shell.

mattkanwisher commented 1 year ago

It appears their CI uses Ubuntu Linux to compile windows. If you have visual studio 2022 and use Git Bash environment Cmake will be found. However there are other issues with hard coding of Pathing styles inside the python code

"mkdir -p C:\Users\hyper\Documents\LamProject\webrtc-native\deps/build/build.windows.template_debug.x86_64.Release.dir/openssl The syntax of the command is incorrect."

This error tricky to fix cause this thing really only runs in a unix like environment, but its getting some default path that is a windows style path with backslashes and then appending forward slashes to it

Anutrix commented 1 year ago

Some issues got fixed in #74.

Current error with scons use_mingw=yes:

> scons use_mingw=yes
scons: Reading SConscript files ...
Auto-detected 24 CPU cores available for build parallelism. Using 23 cores by default. You can override it with the -j argument.
Building for architecture x86_64 on platform windows
scons: done reading SConscript files.
scons: Building targets ...
g++ -o godot-cpp\src\godot.windows.template_debug.x86_64.o -c -std=c++17 -O2 -DDEBUG_ENABLED -DDEBUG_METHODS_ENABLED -Igodot-cpp\godot-headers -Igodot-cpp\include -Igodot-cpp\gen\include godot-cpp\src\godot.cpp
g++ -o godot-cpp\src\classes\wrapped.windows.template_debug.x86_64.o -c -std=c++17 -O2 -DDEBUG_ENABLED -DDEBUG_METHODS_ENABLED -Igodot-cpp\godot-headers -Igodot-cpp\include -Igodot-cpp\gen\include godot-cpp\src\classes\wrapped.cpp
g++ -o godot-cpp\src\core\class_db.windows.template_debug.x86_64.o -c -std=c++17 -O2 -DDEBUG_ENABLED -DDEBUG_METHODS_ENABLED -Igodot-cpp\godot-headers -Igodot-cpp\include -Igodot-cpp\gen\include godot-cpp\src\core\class_db.cpp
....
....
....
g++ -o godot-cpp\gen\src\variant\utility_functions.windows.template_debug.x86_64.o -c -std=c++17 -O2 -DDEBUG_ENABLED -DDEBUG_METHODS_ENABLED -Igodot-cpp\godot-headers -Igodot-cpp\include -Igodot-cpp\gen\include godot-cpp\gen\src\variant\utility_functions.cpp
ssl_action(["deps\build\build.windows.template_debug.x86_64.Release.dir\openssl\libssl.a", "deps\build\build.windows.template_debug.x86_64.Release.dir\openssl\libcrypto.a"], ["deps\openssl"])
Mkdir("D:\Repo\webrtc-native\deps/build/build.windows.template_debug.x86_64.Release.dir/openssl")
cd D:\Repo\webrtc-native\deps/build/build.windows.template_debug.x86_64.Release.dir/openssl && perl D:\Repo\webrtc-native\deps\openssl/Configure "no-ssl3" "no-weak-ssl-ciphers" "no-legacy" "--prefix=D:\Repo\webrtc-native\deps/build/build.windows.template_debug.x86_64.Release.dir/openssl/dest" "--openssldir=D:\Repo\webrtc-native\deps/build/build.windows.template_debug.x86_64.Release.dir/openssl/dest" "mingw64" "--cross-compile-prefix=x86_64-w64-mingw32-"
scons: *** [deps\build\build.windows.template_debug.x86_64.Release.dir\openssl\libssl.a] The system cannot find the file specified
scons: building terminated because of errors.
Faless commented 1 year ago

As of #100 it should be possible to build using MSVC (worked on my machine :tm: with Visual Studio 2019 and 2022). You will need to install nasm and add its location to the PATH environment variable. You will also need a valid perl installation (tested with Strawberry Perl, which in my case didn't require adding to PATH but YMMV).

MinGW builds might need some more work in upstream godot-cpp (see godotengine/godot-cpp#1147).