5

Is there any way to compile some Windows API code without installing any development environments to Windows?

Does Windows come with a C Compiler built in that I could just write some code in notepad, and run it through a cmd or a batch file?

unwind
  • 391,730
  • 64
  • 469
  • 606
  • 2
    Windows doesn't come with a C compiler, but Windows with .Net might have a .net compiler in there and there's always scripting. – Skizz Feb 09 '15 at 15:28
  • 1
    Actually not even all Linux distributions come with a C compiler preinstalled these days... – DevSolar Feb 09 '15 at 15:29
  • Does it come with any compilers that can utilize the Windows API, for example winsock? I'm playing around with system calls and socket network programming, and I would like to be able to do it from a base version of Windows. I would probably be using mostly Windows 7 or Windows 8. If there is no way of doing it from a fresh copy of windows, what is the minimum software to do it? – MutantCoder Feb 09 '15 at 16:04
  • 1
    @MutantCoder: I am looking at a XY problem here: The question states "no external software", to which the answer is "no" (problem Y). But you did not state the *source* of your problem, i.e. **why** "no external software" is a requirement (problem X). Because of this, we do not really know what kind of suggestions are appropriate. Is it a cost thing? There are free compilers out there, like [Visual Studio Express](https://duckduckgo.com/l/?kh=-1&uddg=http%3A%2F%2Fwww.visualstudio.com%2Fproducts%2Fvisual-studio-express-vs), [Cygwin](http://www.cygwin.com) or [MinGW](http://www.mingw.org). – DevSolar Feb 10 '15 at 09:25
  • 1
    @MutantCoder: If it's about size constraints, we could suggest space-efficient solutions. You get the idea -- we don't really know what you are *looking* for. Now you accepted an answer that is, IMHO, completely inappropriate to the question, because you specifically asked about the programming language **C**, in the title, the question body, *and* the tags -- but the answer focusses on **C#**, and thus is of limited help for anyone looking at this question in the future. – DevSolar Feb 10 '15 at 09:27
  • The Question was if Windows came with a built in C compiler. The answer shows that it doesn't, but that Windows does come with a pre built C# compiler. It's not a cost thing or a size constraint thing, I was just wondering if you could work with the Windows API without installing anything. It's not a problem to install things, I was just wondering... – MutantCoder Feb 10 '15 at 15:49
  • Actually, one of the computers I'm working with does not come pre-built with csc. I do think you have to install the .NET framework first. However, they all come with usability with Windows Script Host, which has proved useful. – MutantCoder Feb 10 '15 at 16:15

5 Answers5

5

.NET includes a command line compiler for C#. (not exactly what you asked for, but it might suit you.) I believe .NET is preinstalled on modern versions of Windows. Look in the folder \Windows\Microsoft.NET\Framework\v4* and see if you have a file called CSC.EXE. This is the command line compiler for C#.

See

For more information and examples.

You can also get the free version of Visual Studio that supports C++. Download Visual Studio Community 2013

Community
  • 1
  • 1
Michael Levy
  • 13,097
  • 15
  • 66
  • 100
  • Does .NET have access to system calls or different Windows API functions like winsock or something like that? Like an alternative to C? – MutantCoder Feb 09 '15 at 16:00
  • You can think of .NET like you would think of Java. It is languages (C#, VB.NET, and others), it is a runtime (Java has VM, .NET has the CLR), and it is a rich framework class library. The framework class library for NET has extensive support for network functions. There is tons of documentation, see https://msdn.microsoft.com/en-us/library/4as0wz7t(v=vs.110).aspx to start. – Michael Levy Feb 09 '15 at 16:22
  • Thanks, the computers I'm using do have a C# command line compiler. I will have to check out the documentation. This would probably work well, I just wish I could use C instead. – MutantCoder Feb 09 '15 at 16:35
  • These links might be helpful: C# Programming Guide - https://msdn.microsoft.com/en-us/library/67ef8sbd.aspx, Network Programming How-to Topics - https://msdn.microsoft.com/en-us/library/ms172307(v=vs.110).aspx – Michael Levy Feb 09 '15 at 16:38
  • and An Introduction to Socket Programming in .NET using C# - http://www.codeproject.com/Articles/10649/An-Introduction-to-Socket-Programming-in-NET-using – Michael Levy Feb 09 '15 at 16:43
4

No version of Windows I am aware of comes with a C compiler.

inetknght
  • 4,300
  • 1
  • 26
  • 52
2

No, Windows does not come with a C compiler.

And I don't mean to sound patronizing, but why do you think it'd make sense for it to come with one? Sure, it'd be handy --- if it were a decent compiler --- but beside that, it is not required for normal OS operation. An optimizing compiler is a complex piece of software that would not see any use at all from most users (since most users aren't developers --- and even they might prefer using a compiler of their choice instead of something that just happened to be around).

I should note that at least some Linux distros also come without a compiler by default (as long as it's not needed as a dependency for something else --- which, granted, can happen easily).

Tim Čas
  • 10,501
  • 3
  • 26
  • 32
  • I would like to be able to work with the Windows API without having to connect to the internet. It wouldn't be that big of a deal to get a C compiler, I just thought I would ask. – MutantCoder Feb 09 '15 at 16:08
  • 1
    @MutantCoder: Well, you're connected to the internet right now; you could just download the installation file here and install it on whatever computer you're working on. – Tim Čas Feb 09 '15 at 16:16
  • Yeah, I'm just asking for future reference, while I'm working with fresh copies of windows that I can't really add too many files too... – MutantCoder Feb 09 '15 at 16:25
  • 1
    @MutantCoder: Have a look at TCC then (Tiny C Compiler). – Tim Čas Feb 09 '15 at 16:52
  • 1
    @MutantCoder: Just noticed that you were talking about development environments in your question; if you meant IDEs, then you don't need one for *any* compiler. – Tim Čas Feb 09 '15 at 16:59
1

As others have pointed out, Windows does not come with a preinstalled C compiler. There are several good free one available for download (including a freeware version of microsoft visual c), but that does not mean you can't access with Windows API/SDK.

If you need to make API/SDK calls without the requirement you install anything, you can use Windows Script Hosting https://en.wikipedia.org/wiki/Windows_Script_Host. It supports a number of languages out of the box, such as Jscript, VBScript, and has the ability to add even more options. Using Windows Script Hosting you can create any call you require into the Windows API/SDK.

Newer versions of windows have started to move towards powershell which is even more powerful -- but is not yet universally available which might mean having to install addition software (which I assume is what you are trying to avoid).

user590028
  • 11,364
  • 3
  • 40
  • 57
  • Does WSH have access to kernel functions like open, close, read, write? Also, can you do any socket network programming with it? Thanks. – MutantCoder Feb 09 '15 at 16:10
  • 1
    The answer to both is yes. Start with the references at the end of the Wikipedia article. Then do google of WSH+Winsock and WSH+FileIO – user590028 Feb 09 '15 at 17:31
0

I think you may want Visual Studio Express. http://www.visualstudio.com/en-us/products/visual-studio-express-vs.aspx

You do not mention which version of Windows. Also Windows API calls are customarily built with Visual C++. Although you could build with C# or VB.NET and wrap the calls. As another poster mentioned, if your version includes a .NET, then there are command line building tools available

Ben Butzer
  • 915
  • 10
  • 24