processone / stun

STUN and TURN library for Erlang / Elixir
http://www.ejabberd.im
Apache License 2.0
244 stars 61 forks source link

Phoenix deps compile fast_tls issue on windows #37

Closed luzaranza closed 2 years ago

luzaranza commented 2 years ago

I was following along to a blog to install an erlang stun component using mix on Windows 10.

ref: https://littlelines.com/blog/2020/07/06/building-a-video-chat-app-in-phoenix-liveview

In brief:

after adding # {:stun, "~> 1.0"} to mix.xs and running mix deps.get then mix compile I received an error message while trying to run what appears to be a batch compile executable called cl.exe that the dependency fast_tls.c, could not be compiled due to missing c (++?) header files (eg stdio.h ...), On further investigation this appeared to be due to the Microsoft Visual Studio MVSC compiler tools not being in place, and after installing some of the Microsoft Visual Studio core, I managed to create a dummy project and access the command line within the Microsoft Visual Studio env and re-ran the mix command. This appeared to advance things a little and the next error was due to the missing openssl src files. I then applied the fix I saw to the Mac homebrew settings:

 export LDFLAGS="-L/usr/local/opt/openssl/lib -L/usr/local/lib -L/usr/local/opt/expat/lib"
 export CFLAGS="-I/usr/local/opt/openssl/include/ -I/usr/local/include -I/usr/local/opt/expat/include"
 export CPPFLAGS="-I/usr/local/opt/openssl/include/ -I/usr/local/include -I/usr/local/opt/expat/include"

for the windows environment. And then re-ran the mix compile. But now it is clear that the MSVC compiler presumable called by the cl.exe batch file will not allow the fast_stl.c source file to compile. Apart from spitting out a host of warnings it stops compilation with essentially these error messages:

c:/Users/Paul/Desktop/phoenix/els_umbrella/deps/fast_tls/c_src/fast_tls.c(484): error C2057: expected constant expression c:/Users/Paul/Desktop/phoenix/els_umbrella/deps/fast_tls/c_src/fast_tls.c(484): error C2466: cannot allocate an array of constant size 0 c:/Users/Paul/Desktop/phoenix/els_umbrella/deps/fast_tls/c_src/fast_tls.c(484): error C2133: 'name': unknown size

This appears to tell me that this particular compiler is too picky when looking a memory allocation for data structures such as arrays?

Well, I was just wondering if there is another way to go to compile this source code on a Windows 10 machine without using Visual Studio? I've tried changing the so-called Platform toolset (to LLVM clang-cl an alternative lib offered by Visual Study) but this has not effect. I don't want to have to doctor the fast_tls.c code since quite clearly it compiles fine on other platforms. Or, has anyone had a similar experience in trying to compile this mix dep on a Windows platform?

Best regards.

Paul.

Originally posted by @philipmoniaga in https://github.com/processone/ejabberd/issues/1107#issuecomment-217828211

Neustradamus commented 2 years ago

@weiss, @prefiks: It has been solved, I think?

weiss commented 2 years ago

Yes, indeed. The problem was with compiling the fast_tls dependency, this has been fixed.

luzaranza commented 2 years ago

Ok, so the solution was to adjust the fast_tls.c code. Many thanks. On Monday, 25 July 2022, 16:55:22 GMT-5, Holger Weiß @.***> wrote:

Closed #37 as completed.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

luzaranza commented 2 years ago

Yes. Many thanks to all. On Monday, 25 July 2022, 16:50:07 GMT-5, Neustradamus @.***> wrote:

@weiss, @prefiks: It has been solved, I think?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>