[erlang-questions] Compiling OTP on Windows

Jaka Bac jakabac@REDACTED
Thu May 16 12:41:29 CEST 2019


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 <andre@REDACTED> 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
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20190516/af72c06b/attachment.htm>


More information about the erlang-questions mailing list