0

When I run

perl -e 'which("clang")'

in Windows Command Prompt I get an empty line, but on Linux I get:

Undefined subroutine &main::which called at -e line 1.

I am asking because I am trying to figure out why which does not work in OpenSSL build script:

# see if there is NDK clang on $PATH, "universal" or "standalone"
if (which("clang") =~ m|^$ndk/.*/prebuilt/([^/]+)/|) { ... }

where the condition is always false even if clang is in the PATH.

Alexey Starinsky
  • 3,699
  • 3
  • 21
  • 57
  • 2
    Single quotes are not a special character in Windows cmd. So basically you executed the perl statement `'which(...)'` and not `which(...)` (note the quotes) - i.e. you executed a constant string and thus got an empty line. – Steffen Ullrich Oct 17 '22 at 14:56
  • 1
    Re "*What is which in Perl?*", Perl does not have a `which` builtin. /// Re "*I am trying to figure out why which does not work*", "Does not work" is not an adequate description of the problem. You have not provided enough information for us to answer your question. What problem are you facing? What behviour do you get? What behaviour do you want? What is this `which` sub you're asking about? – ikegami Oct 17 '22 at 15:11
  • 1
    See also [Win32::App::which](https://metacpan.org/pod/Win32::App::which) and [PerlPowerTools](https://metacpan.org/pod/PerlPowerTools) – Håkon Hægland Oct 17 '22 at 15:20
  • @ikegami Looks like the condition is false because the path is in 8.3 format, see https://stackoverflow.com/questions/74099526/how-to-disable-ms-dos-8-3-filenames-in-perl – Alexey Starinsky Oct 17 '22 at 15:21
  • See also https://linux.die.net/man/1/which – ulix Oct 22 '22 at 15:26

1 Answers1

1

which is not a Perl builtin function.

% perl -we 'print which("clang")'
Undefined subroutine &main::which called at -e line 1.

Keep in mind the Windows command line does not use the same quoting rules as the Linux command line, unless you're using something like WSL or bash for Windows.

The subroutine which is defined at https://github.com/openssl/openssl/blob/master/Configure#L3264 (or a similar line in other versions of the code). You'll need to make sure you've got all the build dependencies installed, all the application paths and library/include paths configured correctly, that you're following the installation directions accurately, and that you're doing things in the proper order.

You'll especially want to look in https://github.com/openssl/openssl/blob/af33b200da8040c78dbfd8405878190980727171/NOTES-WINDOWS.md and https://github.com/openssl/openssl/blob/master/NOTES-PERL.md to make sure you're following the OpenSSL project's recommendations for their build system on Windows if native Windows is where you intend to do the builds.