Adam Alexandru
Adam Alexandru

Reputation: 21

OpenSSL perl configuration script fails with Strawberry Perl

I'm trying to build OpenSSL but i have one big problem which i couldn't figure it out.

I reinstalled VS 2017, perl, strawberry, nasm but nothing worked.

%PATH% contains perl path, nasm path etc.

I found the same issue on github but still can't fix it. (My setup is x64)

Screenshot

Upvotes: 1

Views: 1660

Answers (1)

Stefan Becker
Stefan Becker

Reputation: 5972

It might be that this line in the OpenSSL code is causing your problem, because if it fails it triggers the error message described in your question:

if (`nasm -v 2>NUL` =~ /NASM version ([0-9]+\.[0-9]+)/ && $1 >= 2.0) {

You could try to debug this issue in your environment with the following stripped down test script:

#!/usr/bin/perl
use warnings;
use strict;

my $output = <<END_OF_STRING;
NASM version 2.14.02 compiled on Dec 26 2018
test
some other junk
END_OF_STRING

if ($output =~ /NASM version ([0-9]+\.[0-9]+)/ && $1 >= 2.0) {
    print "TEST: NASM $1 found\n";
} else {
    die "TEST: NASM not found\n";
}

print "TEST with redirection to NUL: ", `nasm -v 2>NUL`;
print "TEST without redirection to NUL: ", `nasm -v`;

if (`nasm -v 2>NUL` =~ /NASM version ([0-9]+\.[0-9]+)/ && $1 >= 2.0) {
    print "REAL: NASM $1 found\n";
} else {
    die "REAL: NASM not found\n";
}

exit 0;

When I run it on my Linux machine I get:

$ perl dummy.pl
TEST: NASM 2.14 found
TEST with redirection to NUL: NASM version 2.13.03 compiled on Jul 14 2018
TEST without redirection to NUL: NASM version 2.13.03 compiled on Jul 14 2018
REAL: NASM 2.13 found

... and then I realized that I have nasm installed on that machine :-)


Update 1: based on your first run of the test script I would suggest to remove the 2>NUL from the OpenSSL source line, i.e.:

if (`nasm -v` =~ /NASM version ([0-9]+\.[0-9]+)/ && $1 >= 2.0) {

This doesn't modify OpenSSL functionality, but probably helps you over the installation bump...


Update 2: digging a bit further I'm almost certain that the issue here is Strawberry Perl. To quote from the home page:

Straberry Perl is a perl environment for MS Windows containing all you need to run and develop perl applications. It is designed to be as close as possible to perl environment on UNIX systems.

That translates to system(STRING), qx{} or backtick operators calling a UNIX shell, e.g. bash, and not cmd.exe. But

  • the OpenSSL VC-WIN64A configuration hard-codes the cmd.exe command line nasm -v 2>NUL,
  • that command line fails in Strawberry Perl shell,
  • therefore qx{nasm -v 2>NUL} returns an empty string,
  • resulting in the m// regex to fail,
  • leading the configure script to a false negative.

In conclusion: either use the workaround I suggested or dig into the OpenSSL documentation if there is an alternative configuration option for Windows with Strawberry Perl.

Upvotes: 2

Related Questions