0

It's been a rocky road with compiling openssl-1.1.0e on my Windows 7 VM.

First, some msys2 packages with the following command from inside the msys2 shell;

pacman -S make gcc perl

The source was configured with;

./Configure mingw

Then;

make depend && make

There was a problem with the files;

crypto/init.c
crypto/dso/dso_win32.c

Both complained about Windows functions. Adding;

#include <windows.h>

to both at the top with the other includes solved that problem.

Unfortunately now its complaining a little bit more, and there is nothing on the internet currently that can help. Here is the important stuff;

make[2]: Entering directory '/builds/openssl-1.1.0e'
perl ./util/mkrc.pl libcrypto-1_1.dll | windres --target=pe-i386 -o rc.o
LD_LIBRARY_PATH=: gcc -DOPENSSL_USE_APPLINK -DDSO_WIN32 -DNDEBUG -DOPENSSL_THREADS -DOPENSSL_NO_STATIC_ENGINE -DOPENSSL_PIC  -DOPENSSL_BN_ASM_PART_WORDS -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DRC4_ASM -DMD5_ASM -DRMD160_ASM -DAES_ASM -DVPAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM  -DECP_NISTZ256_ASM -DPADLOCK_ASM -DPOLY1305_ASM -DOPENSSLDIR="/usr/local/ssl" -DENGINESDIR="/usr/local/lib/engines-1_1" -DL_ENDIAN -DWIN32_LEAN_AND_MEAN -DUNICODE -D_UNICODE -m32 -Wall -O3 -fomit-frame-pointer -D_MT -D_WINDLL -static-libgcc -shared -Wl,-Bsymbolic -Wl,--out-implib,libcrypto.dll.a crypto.def rc.o -o ./libcrypto-1_1.dll -Wl,--whole-archive ./libcrypto.a -Wl,--no-whole-archive -lws2_32 -lgdi32 -lcrypt32
Cannot export RAND_event: symbol not defined
Cannot export RAND_screen: symbol not defined
./libcrypto.a(uplink.o):uplink.c:(.text+0x5e): undefined reference to `_sntprintf'
./libcrypto.a(uplink.o):uplink.c:(.text+0x75): undefined reference to `_tcscpy'
./libcrypto.a(uplink.o):uplink.c:(.text+0xcd): undefined reference to `_tcscpy'
./libcrypto.a(uplink.o):uplink.c:(.text+0x14e): undefined reference to `_tcscpy'
./libcrypto.a(uplink.o):uplink.c:(.text+0x179): undefined reference to `_tcscpy'
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile.shared:296: link_shlib.mingw] Error 1
make[2]: Leaving directory '/builds/openssl-1.1.0e'
make[1]: *** [Makefile:725: libcrypto.dll.a] Error 2
make[1]: Leaving directory '/builds/openssl-1.1.0e'
make: *** [Makefile:128: all] Error 2

Honestly I'm at a loss. Any thoughts?

Sam
  • 5
  • 4
  • 1
    Why not just install openssl using pacman? If you really want to build it yourself, you should use the [official MSYS2 openssl PKGBUILD script](https://github.com/Alexpux/MINGW-packages/tree/master/mingw-w64-openssl) as a starting point. – David Grayson May 22 '17 at 22:07

1 Answers1

1

There should be no reason to make changes to the OpenSSL source to get it to work with mingw/msys2. It compiles just fine without such changes - your problems are almost certainly environmental. Get a clean copy of the OpenSSL source and then check the things below.

I note in your question that you have installed msys2 gcc. This is most likely the source of your problem. The whole point of doing a mingw build is to use the mingw compiler to generate a native windows executable/library. Ensure that the mingw compiler appears on your path before any msys2 compiler (you may even want to just remove the msys2 gcc package).

A second thing to be aware of is that there are actually two different mingw targets for the Configure script: mingw and mingw64. You need to make sure you are using the right one, and that it matches the mingw compiler version you are using.

Another thing to check is your perl version. Sometimes, dependant on your PATH, you can pick up the wrong version of perl even though you have installed msys2 perl. If a different version of perl exists on your PATH before the msys2 instance then things can go wrong. Execute perl -v from your msys2 shell and check that it looks something like this:

This is perl 5, version 22, subversion 1 (v5.22.1) built for x86_64-msys-thread-multi

Matt Caswell
  • 8,167
  • 25
  • 28