-1

A project I am trying to compile has this command:

cc -xc++ -o/dev/null -lc++ -shared

However I am using PowerShell, which has no notion of /dev/null:

PS C:\> cc -xc++ -o/dev/null -lc++ -shared
C:/msys2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../
x86_64-w64-mingw32/bin/ld.exe: cannot open output file /dev/null.exe: No such
file or directory

I tried using -o$null, but it just creates a file $null.exe. I also tried this:

PS C:\> cc -xc++ -o $null -lc++ -shared
cc.exe: fatal error: no input files

Is PowerShell able to handle this use case? Alternatively, it seems the purpose of the test is to just check if libc++ exists. Is another way available to do that?

halfer
  • 19,824
  • 17
  • 99
  • 186
Zombo
  • 1
  • 62
  • 391
  • 407
  • You can `test-path` to return a Boolean for a directory, and I believe the equivalent of `/dev/null` in PowerShell would be having `>> $null` at the end of a command that produces output. Is that what you're looking for? – Andrew Ryan Davis Oct 25 '20 at 20:19
  • Argument `-o/dev/null` would be passed verbatim by cmd, PowerShell, and any POSIX-compatible shell, so the premise of this question is flawed: this can't be PowerShell-specific. `/dev/null` (case-_sensitively_) is the null device on Unix-like platforms, whereas it is `NUL` (case-_insensitively_) on Windows. – mklement0 Oct 27 '20 at 02:37

1 Answers1

0

It appears the issue is specific to GCC. If I get Clang, the same command works with nul:

cc -xc++ -onul -lc++ -shared

but if I try the same thing with GCC, I get this:

C:/msys2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../
x86_64-w64-mingw32/bin/ld.exe: nul.exe: final close failed: file truncated

I have posted bug 97574.

Zombo
  • 1
  • 62
  • 391
  • 407