Compiling OTP on Windows

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Compiling OTP on Windows

Andre Nathan
Hi

Does anyone have a pointer to up to date instructions on how to setup
Windows to build OTP? I tried to follow the guide at [1] but it seems to
be out of date (e.g. I can't find Visual Studio 2013 anymore).

I tried to adapt the steps to the latest Visual Studio but I haven't
used Windows in 20 years and failed miserably.

Alternatively, if someone has a VirtualBox VM set up for development
that I could download, it would be greatly appreciated, though I don't
know if that would be legal...

Thanks in advance,
Andre


[1] http://erlang.org/doc/installation_guide/INSTALL-WIN32.html
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Compiling OTP on Windows

Dmytro Lytovchenko
From what I know the building instructions are pure magic involving MinGW and Visual Studio, and it is dangerous to go alone.

On Tue, 30 Apr 2019 at 17:23, Andre Nathan <[hidden email]> wrote:
Hi

Does anyone have a pointer to up to date instructions on how to setup
Windows to build OTP? I tried to follow the guide at [1] but it seems to
be out of date (e.g. I can't find Visual Studio 2013 anymore).

I tried to adapt the steps to the latest Visual Studio but I haven't
used Windows in 20 years and failed miserably.

Alternatively, if someone has a VirtualBox VM set up for development
that I could download, it would be greatly appreciated, though I don't
know if that would be legal...

Thanks in advance,
Andre


[1] http://erlang.org/doc/installation_guide/INSTALL-WIN32.html
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Compiling OTP on Windows

Andre Nathan
On 4/30/19 12:36 PM, Dmytro Lytovchenko wrote:
>  From what I know the building instructions are pure magic involving
> MinGW and Visual Studio, and it is dangerous to go alone.
> Take this https://visualstudio.microsoft.com/vs/older-downloads/

Yeah, I've found that, but the VS 2013 link leads to a page that says no
downloads are available.

Thanks,
Andre
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Compiling OTP on Windows

Jaka Bac
The windows build process&setup is not "magic" at all....

In fact it is actually possible to build Erlang/OTP with MSVC 2019
My build process (instructions not exact) looked like this:
1. Install MSVC 2019
2. Install MSYS2 and configure it so the msys shell inherits the Windows environment (PATH) when started. Also install all the "Linux" prereqs (GCC,...)
3. Download and build OpenSSL (follow OpenSSL build instructions, I used 1.1.1b version to get all possible ciphers, hashes,...)
4. Download and build wxWidgets (put wxWidgets in /opt/local/pgm and build the static libs there (instructions taken from OTP build guide for WIN, wxWidgets 3.0.4 is also fine):

C:\...\> cd <path\to\pgm>\wxMSW-3.0.3\build\msw
C:\...\> nmake TARGET_CPU=amd64 BUILD=release SHARED=0 DIR_SUFFIX_CPU= -f makefile.vc


5. Apply this patch:
diff --git a/erts/etc/win32/msys_tools/vc/cc.sh b/erts/etc/win32/msys_tools/vc/cc.sh
index 2b0482e876..99db719c38 100644
--- a/erts/etc/win32/msys_tools/vc/cc.sh
+++ b/erts/etc/win32/msys_tools/vc/cc.sh
@@ -242,7 +242,10 @@ for x in $SOURCES; do
     if [ $PREPROCESSING = true ]; then
        output_flag="-E"
     else
+
        output_flag="-FS -c -Fo`cmd //C echo ${output_filename}`"
+       output_flag=`echo $output_flag | sed -e 's/\\//\\\\\\\\/g'`
+       #echo "PATCHED OUTPUT: " $output_flag
     fi
     params="$COMMON_CFLAGS $MD $DEBUG_FLAGS $OPTIMIZE_FLAGS \
            $CMD ${output_flag} $MPATH"

The cc.sh makes cl.exe look like gcc to the OTP build environment. It does fiddling with the paths to translate them from MSYS style to native paths. But it seems that MSVC 2019 does not like absolute paths with / insted of \ (Relative paths work fine with /)

5. Follow the WIN build instructions for OTP (tell configure where your OpenSSL lives):

$ eval `./otp_build env_win32 x64`
$ ./otp_build autoconf
$ ./otp_build configure  --with-ssl=/x/path/to/openssl #you might want to tell it where to find javac also if you want jinterface

Even if configure does not complainabout OpenSSL it seems that everythig is still not as the build environment expects. I had to copy libcrypto_static.lib and libssl_static.lib to c_src folder lib\crypto\c_src while renaming them to crypto.lib and ssl.lib.
Also It seems that I built OpenSSL with newtorking support since the OTP build died while building crypto app with unresolved winsock symbols. To fix it I added 
LDFLAGS += -dll Ws2_32.Lib
to otp\lib\crypto\c_src\win32\Makefile (please keep in mind that this file is probably generated during the build process so this is a dirty hack, I did not feel like digging deeper into the build scripts, makefiles etc...)

$ ./otp_build boot -a
$ ./otp_build release -a

Building the installer expects a pretty ancient NSIS installation. I just removed the version checks in the installer makefile to go through that, but you really don't need the installer...

After ./otp_build release -a completes you will find everything you need in otp\release\win32. This is more or less what the installer will pack.

You can just copy that folder to wherever you want your build to live and run install.exe in that folder as the last step (this is also done by the windows installer)
It will create bin folder and put all the "public" exes there, set up an erl.ini and also copy the boot scripts into bin.

After that you are good to go! 
I did not bother building the docs, but feel free to try that...

I confirmed that wx application is working by running observer and also did limited testing of the crypto app. 

If you get stuck feel free to contact me
Cheers,
Jaka

On Tue, 30 Apr 2019 at 17:50, Andre Nathan <[hidden email]> wrote:
>

> On 4/30/19 12:36 PM, Dmytro Lytovchenko wrote:
> >  From what I know the building instructions are pure magic involving
> > MinGW and Visual Studio, and it is dangerous to go alone.
> > Take this https://visualstudio.microsoft.com/vs/older-downloads/
>
> Yeah, I've found that, but the VS 2013 link leads to a page that says no
> downloads are available.
>
> Thanks,
> Andre
> _______________________________________________
> erlang-questions mailing list
> [hidden email]
> http://erlang.org/mailman/listinfo/erlang-questions
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Compiling OTP on Windows

Oleg Tarasenko
Hi Jaka,

I am trying to follow your steps in order to compile it on Windows 10 (using cygwin instead of msys2, but on msys2 I seem to get the same). For now, getting errors :(.

$ ./otp_build configure
Copying static configure cache /cygdrive/c/Users/oltar/Downloads/otp_src_22.0/erts/autoconf/win32.config.cache.static to /cygdrive/c/Users/oltar/Downloads/otp_src_22.0/erts/autoconf/win32.config.cache
/cygdrive/c/Users/oltar/Downloads/otp_src_22.0/configure --build=x86_64-unknown-cygwin build_alias=win32 --host=win32 --target=win32 --disable-dynamic-ssl-lib  --cache-file=/cygdrive/c/Users/oltar/Downloads/otp_src_22.0/erts/autoconf/win32.config.cache CC=cc\.sh CXX=cc\.sh RANLIB=true AR=ar\.sh
WARNING: Only using config cache file '/cygdrive/c/Users/oltar/Downloads/otp_src_22.0/erts/autoconf/win32.config.cache' as static cache
=== Running configure in /cygdrive/c/Users/oltar/Downloads/otp_src_22.0/erts ===
./configure '--build=x86_64-unknown-cygwin' 'build_alias=win32' '--host=win32' '--target=win32' '--disable-dynamic-ssl-lib' 'CC=cc.sh' 'CXX=cc.sh' 'RANLIB=true' 'AR=ar.sh' --disable-option-checking --cache-file=./local.static.config.cache --srcdir="/cygdrive/c/Users/oltar/Downloads/otp_src_22.0/erts"
configure: loading cache ./local.static.config.cache
checking for win32-gcc... (cached) cc.sh
checking whether the C compiler works... no
configure: error: in `/cygdrive/c/Users/oltar/Downloads/otp_src_22.0/erts':
configure: error: C compiler cannot create executables
See `config.log' for more details
ERROR: /cygdrive/c/Users/oltar/Downloads/otp_src_22.0/erts/configure failed!
./configure: line 343: kill: (-2670) - No such process

I want to ask if you can share the contents of "cc.sh". Also maybe you could advise what might be missing.
Oleg

On Thu, May 16, 2019 at 1:43 PM Jaka Bac <[hidden email]> wrote:
The windows build process&setup is not "magic" at all....

In fact it is actually possible to build Erlang/OTP with MSVC 2019
My build process (instructions not exact) looked like this:
1. Install MSVC 2019
2. Install MSYS2 and configure it so the msys shell inherits the Windows environment (PATH) when started. Also install all the "Linux" prereqs (GCC,...)
3. Download and build OpenSSL (follow OpenSSL build instructions, I used 1.1.1b version to get all possible ciphers, hashes,...)
4. Download and build wxWidgets (put wxWidgets in /opt/local/pgm and build the static libs there (instructions taken from OTP build guide for WIN, wxWidgets 3.0.4 is also fine):

C:\...\> cd <path\to\pgm>\wxMSW-3.0.3\build\msw
C:\...\> nmake TARGET_CPU=amd64 BUILD=release SHARED=0 DIR_SUFFIX_CPU= -f makefile.vc


5. Apply this patch:
diff --git a/erts/etc/win32/msys_tools/vc/cc.sh b/erts/etc/win32/msys_tools/vc/cc.sh
index 2b0482e876..99db719c38 100644
--- a/erts/etc/win32/msys_tools/vc/cc.sh
+++ b/erts/etc/win32/msys_tools/vc/cc.sh
@@ -242,7 +242,10 @@ for x in $SOURCES; do
     if [ $PREPROCESSING = true ]; then
        output_flag="-E"
     else
+
        output_flag="-FS -c -Fo`cmd //C echo ${output_filename}`"
+       output_flag=`echo $output_flag | sed -e 's/\\//\\\\\\\\/g'`
+       #echo "PATCHED OUTPUT: " $output_flag
     fi
     params="$COMMON_CFLAGS $MD $DEBUG_FLAGS $OPTIMIZE_FLAGS \
            $CMD ${output_flag} $MPATH"

The cc.sh makes cl.exe look like gcc to the OTP build environment. It does fiddling with the paths to translate them from MSYS style to native paths. But it seems that MSVC 2019 does not like absolute paths with / insted of \ (Relative paths work fine with /)

5. Follow the WIN build instructions for OTP (tell configure where your OpenSSL lives):

$ eval `./otp_build env_win32 x64`
$ ./otp_build autoconf
$ ./otp_build configure  --with-ssl=/x/path/to/openssl #you might want to tell it where to find javac also if you want jinterface

Even if configure does not complainabout OpenSSL it seems that everythig is still not as the build environment expects. I had to copy libcrypto_static.lib and libssl_static.lib to c_src folder lib\crypto\c_src while renaming them to crypto.lib and ssl.lib.
Also It seems that I built OpenSSL with newtorking support since the OTP build died while building crypto app with unresolved winsock symbols. To fix it I added 
LDFLAGS += -dll Ws2_32.Lib
to otp\lib\crypto\c_src\win32\Makefile (please keep in mind that this file is probably generated during the build process so this is a dirty hack, I did not feel like digging deeper into the build scripts, makefiles etc...)

$ ./otp_build boot -a
$ ./otp_build release -a

Building the installer expects a pretty ancient NSIS installation. I just removed the version checks in the installer makefile to go through that, but you really don't need the installer...

After ./otp_build release -a completes you will find everything you need in otp\release\win32. This is more or less what the installer will pack.

You can just copy that folder to wherever you want your build to live and run install.exe in that folder as the last step (this is also done by the windows installer)
It will create bin folder and put all the "public" exes there, set up an erl.ini and also copy the boot scripts into bin.

After that you are good to go! 
I did not bother building the docs, but feel free to try that...

I confirmed that wx application is working by running observer and also did limited testing of the crypto app. 

If you get stuck feel free to contact me
Cheers,
Jaka

On Tue, 30 Apr 2019 at 17:50, Andre Nathan <[hidden email]> wrote:
>

> On 4/30/19 12:36 PM, Dmytro Lytovchenko wrote:
> >  From what I know the building instructions are pure magic involving
> > MinGW and Visual Studio, and it is dangerous to go alone.
> > Take this https://visualstudio.microsoft.com/vs/older-downloads/
>
> Yeah, I've found that, but the VS 2013 link leads to a page that says no
> downloads are available.
>
> Thanks,
> Andre
> _______________________________________________
> erlang-questions mailing list
> [hidden email]
> http://erlang.org/mailman/listinfo/erlang-questions
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Compiling OTP on Windows

Jaka Bac
Hi Oleg,

I just noticed that I forgot to mention that before running msys shell (which should be configured to inherit the windows environment variables), that you need to run the vcvars64.bat so you have the paths set up for running cl.exe
You can find a shortcut for that in the start menu under "Visual Studio 2019" folder (previous VS versions have the same). Probably this is causing your error.

Before starting the build you make sure that the msys/cygwin shell can actually run cl.exe (just try to run cl)

Otherwise I did not test this with cygwin. But it seems that cygwin has its own cc.sh in erts\etc\win32\cygwin_tools\vc

I will send cc.sh to you in a separate email (to not spam the list), the only change that I did is adding this line:
output_flag=`echo $output_flag | sed -e 's/\\//\\\\\\\\/g'`
after 
output_flag="-FS -c -Fo`cmd //C echo ${output_filename}`" 

Jaka

 

On Mon, 20 May 2019 at 11:51, Oleg Tarasenko <[hidden email]> wrote:
Hi Jaka,

I am trying to follow your steps in order to compile it on Windows 10 (using cygwin instead of msys2, but on msys2 I seem to get the same). For now, getting errors :(.

$ ./otp_build configure
Copying static configure cache /cygdrive/c/Users/oltar/Downloads/otp_src_22.0/erts/autoconf/win32.config.cache.static to /cygdrive/c/Users/oltar/Downloads/otp_src_22.0/erts/autoconf/win32.config.cache
/cygdrive/c/Users/oltar/Downloads/otp_src_22.0/configure --build=x86_64-unknown-cygwin build_alias=win32 --host=win32 --target=win32 --disable-dynamic-ssl-lib  --cache-file=/cygdrive/c/Users/oltar/Downloads/otp_src_22.0/erts/autoconf/win32.config.cache CC=cc\.sh CXX=cc\.sh RANLIB=true AR=ar\.sh
WARNING: Only using config cache file '/cygdrive/c/Users/oltar/Downloads/otp_src_22.0/erts/autoconf/win32.config.cache' as static cache
=== Running configure in /cygdrive/c/Users/oltar/Downloads/otp_src_22.0/erts ===
./configure '--build=x86_64-unknown-cygwin' 'build_alias=win32' '--host=win32' '--target=win32' '--disable-dynamic-ssl-lib' 'CC=cc.sh' 'CXX=cc.sh' 'RANLIB=true' 'AR=ar.sh' --disable-option-checking --cache-file=./local.static.config.cache --srcdir="/cygdrive/c/Users/oltar/Downloads/otp_src_22.0/erts"
configure: loading cache ./local.static.config.cache
checking for win32-gcc... (cached) cc.sh
checking whether the C compiler works... no
configure: error: in `/cygdrive/c/Users/oltar/Downloads/otp_src_22.0/erts':
configure: error: C compiler cannot create executables
See `config.log' for more details
ERROR: /cygdrive/c/Users/oltar/Downloads/otp_src_22.0/erts/configure failed!
./configure: line 343: kill: (-2670) - No such process

I want to ask if you can share the contents of "cc.sh". Also maybe you could advise what might be missing.
Oleg

On Thu, May 16, 2019 at 1:43 PM Jaka Bac <[hidden email]> wrote:
The windows build process&setup is not "magic" at all....

In fact it is actually possible to build Erlang/OTP with MSVC 2019
My build process (instructions not exact) looked like this:
1. Install MSVC 2019
2. Install MSYS2 and configure it so the msys shell inherits the Windows environment (PATH) when started. Also install all the "Linux" prereqs (GCC,...)
3. Download and build OpenSSL (follow OpenSSL build instructions, I used 1.1.1b version to get all possible ciphers, hashes,...)
4. Download and build wxWidgets (put wxWidgets in /opt/local/pgm and build the static libs there (instructions taken from OTP build guide for WIN, wxWidgets 3.0.4 is also fine):

C:\...\> cd <path\to\pgm>\wxMSW-3.0.3\build\msw
C:\...\> nmake TARGET_CPU=amd64 BUILD=release SHARED=0 DIR_SUFFIX_CPU= -f makefile.vc


5. Apply this patch:
diff --git a/erts/etc/win32/msys_tools/vc/cc.sh b/erts/etc/win32/msys_tools/vc/cc.sh
index 2b0482e876..99db719c38 100644
--- a/erts/etc/win32/msys_tools/vc/cc.sh
+++ b/erts/etc/win32/msys_tools/vc/cc.sh
@@ -242,7 +242,10 @@ for x in $SOURCES; do
     if [ $PREPROCESSING = true ]; then
        output_flag="-E"
     else
+
        output_flag="-FS -c -Fo`cmd //C echo ${output_filename}`"
+       output_flag=`echo $output_flag | sed -e 's/\\//\\\\\\\\/g'`
+       #echo "PATCHED OUTPUT: " $output_flag
     fi
     params="$COMMON_CFLAGS $MD $DEBUG_FLAGS $OPTIMIZE_FLAGS \
            $CMD ${output_flag} $MPATH"

The cc.sh makes cl.exe look like gcc to the OTP build environment. It does fiddling with the paths to translate them from MSYS style to native paths. But it seems that MSVC 2019 does not like absolute paths with / insted of \ (Relative paths work fine with /)

5. Follow the WIN build instructions for OTP (tell configure where your OpenSSL lives):

$ eval `./otp_build env_win32 x64`
$ ./otp_build autoconf
$ ./otp_build configure  --with-ssl=/x/path/to/openssl #you might want to tell it where to find javac also if you want jinterface

Even if configure does not complainabout OpenSSL it seems that everythig is still not as the build environment expects. I had to copy libcrypto_static.lib and libssl_static.lib to c_src folder lib\crypto\c_src while renaming them to crypto.lib and ssl.lib.
Also It seems that I built OpenSSL with newtorking support since the OTP build died while building crypto app with unresolved winsock symbols. To fix it I added 
LDFLAGS += -dll Ws2_32.Lib
to otp\lib\crypto\c_src\win32\Makefile (please keep in mind that this file is probably generated during the build process so this is a dirty hack, I did not feel like digging deeper into the build scripts, makefiles etc...)

$ ./otp_build boot -a
$ ./otp_build release -a

Building the installer expects a pretty ancient NSIS installation. I just removed the version checks in the installer makefile to go through that, but you really don't need the installer...

After ./otp_build release -a completes you will find everything you need in otp\release\win32. This is more or less what the installer will pack.

You can just copy that folder to wherever you want your build to live and run install.exe in that folder as the last step (this is also done by the windows installer)
It will create bin folder and put all the "public" exes there, set up an erl.ini and also copy the boot scripts into bin.

After that you are good to go! 
I did not bother building the docs, but feel free to try that...

I confirmed that wx application is working by running observer and also did limited testing of the crypto app. 

If you get stuck feel free to contact me
Cheers,
Jaka

On Tue, 30 Apr 2019 at 17:50, Andre Nathan <[hidden email]> wrote:
>

> On 4/30/19 12:36 PM, Dmytro Lytovchenko wrote:
> >  From what I know the building instructions are pure magic involving
> > MinGW and Visual Studio, and it is dangerous to go alone.
> > Take this https://visualstudio.microsoft.com/vs/older-downloads/
>
> Yeah, I've found that, but the VS 2013 link leads to a page that says no
> downloads are available.
>
> Thanks,
> Andre
> _______________________________________________
> erlang-questions mailing list
> [hidden email]
> http://erlang.org/mailman/listinfo/erlang-questions
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions