11

I would like to determine whether there is already a compiler installed.

Do you know a command on Windows which I could use in the console to do that?

Community
  • 1
  • 1
Jesus Peralta
  • 661
  • 1
  • 8
  • 18
  • 2
    Windows is not like UNIX where "the OS is the IDE" - so you can't simply do `system("gcc")` or exec a makefile. On Windows you will need to decide what compiler you expect and instruct your users to modify your build script accordingly. – Dai Jan 30 '17 at 10:47
  • 1
    @Dai: That's just as true on UNIX systems. The OS is not the IDE. You're assuming specific pre-installed software. – Lightness Races in Orbit Jan 30 '17 at 10:50
  • @Jesus: Read the tag wiki for tags that you use. [tag:compiler-construction]'s specifically says not to use it in this way. – Lightness Races in Orbit Jan 30 '17 at 10:53
  • Windows doesn't come with a pre-installed compiler. If there is a compiler installed on your system, that's because you did (or your system administrator). Either way, if you attempt to install using an MSI installer, it will let you know, whether this product has been previously installed. – IInspectable Jan 30 '17 at 11:09
  • Use `Regedit.exe` to read value in `Computer\HKEY_CLASSES_ROOT\.cpp`. If the installed C++ compiler associated it's editor with the `*.cpp` then it will be recorded in this registry key – xmojmr Jan 30 '17 at 11:13
  • 1
    @xmojmr: A compiler doesn't need to register file associations with the shell. (And I'm pretty sure the Visual C++ Build Tools do not.) – IInspectable Jan 30 '17 at 11:17
  • _"unless they directly involve tools used primarily for programming"_ This is not off-topic. – Lightness Races in Orbit Jan 30 '17 at 12:29
  • @Lightness: Arguably, the fact that the OP is asking for a compiler is unrelated to the question. The more general question (*"How do I find out that any random program is installed on any given computer?"*) would be off-topic. – IInspectable Jan 30 '17 at 13:27
  • @IInspectable: Right, but the OP isn't asking that more general question. Conceivably (though it ain't so) a computer would be able to tell you whether a compiler's installed, by virtue of it being a compiler. That the answer is "no" doesn't change that! – Lightness Races in Orbit Jan 30 '17 at 13:47

1 Answers1

3

There is no catch-all way to discover whether there is "a" C or C++ compiler installed, because different compilers are invoked in different ways. You could iterate through the common ones (e.g. running g++ from shell) but, really, you should know what software is running on your computer because you installed it. If you did not set up the computer, ask the person who did.

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
  • Trying to run compilers from "the shell" won't actually work with MSVC, because you need the special MSVC build tools shell for that. And arguably MSVC is the most common compiler for Windows. – MSalters Jan 30 '17 at 12:07
  • 1
    sad to know that there is not an easy way to get this info from windows – Jesus Peralta Jan 30 '17 at 12:10
  • 1
    @JesusPeralta: Windows (like any other OS) has no built-in knowledge of what a compiler is. It's just another program, and there are arbitrarily many programs that can be compilers. It's up to the administrator of the computer to know what he or she has installed on to it. – Lightness Races in Orbit Jan 30 '17 at 12:28
  • 4
    So with a standard Windows 10 on a brand new laptop, how would you know what is installed? It's a bit mean saying "ask the person who did it" because there are dozens of programs already installed either by Dell or by Microsoft. Wouldn't it be good if there was a dedicated folder left to storing compilers? – Gregory Fenn Mar 21 '19 at 19:11
  • @GregoryFenn Add/Remove Programs tells you what registered programs are installed, and your toolchain should be in that list. But there is no way for Windows to know what some program in that list _is_ a toolchain, nor should there be! – Lightness Races in Orbit Mar 22 '19 at 11:19