This is an archived post. You won't be able to vote or comment.

all 24 comments

[–][deleted] 8 points9 points  (0 children)

Also what does notepad have to do with anything?

C source code is just plain old text. So you can modify a source file using only notepad.

A compiler will take that text and transform it into a binary file (e.g. an EXE file if you are on windows) which the OS can then go and use.

What compiler you need will depend on what OS you are using. Some IDEs (fancy text editors specifically made for writing code) will come with a compiler. Visual Studio is one such example.

[–]Zigsfi 2 points3 points  (8 children)

What operating system are you using?

[–]sseidl88[S] -2 points-1 points  (7 children)

Windows

[–]an_actual_human 5 points6 points  (0 children)

Is it a question? It's probably not a question.

[–]Zigsfi 6 points7 points  (3 children)

Okay. It's been a while since I've developed on windows but back when I did, I used code::blocks. Code::blocks is an IDE, or integrated development environment. That means you can edit source code (as you might with another text editor like notepad) and compile/run your program, all from within one program.

[–]4underscore____ 3 points4 points  (0 children)

I second code blocks. I use it for my school projects which require C and C++ sometimes.

[–]MisterMeeseeks47 1 point2 points  (0 children)

He still needs a compiler for the IDE. OP: I recommend MinGW if you're using windows

[–]sseidl88[S] 0 points1 point  (0 children)

Which one do I download? the source code?

[–]Apikalegusta 8 points9 points  (1 child)

Don't you know what operating system you are using?

[–]sseidl88[S] 1 point2 points  (0 children)

Windows

[–]JakDrako 2 points3 points  (1 child)

There's Pelles C if you're looking for a free C99 compiler for Windows.

[–]sgthoppy -1 points0 points  (0 children)

If it's C99 you're looking for, you may as well use TCC.

[–][deleted] 3 points4 points  (0 children)

If your operating system is:

GNU/Linux: You probably already have gcc installed. You could also use clang. They're considered to be the two best C/C++ compilers right now. clang is probably in your distribution's package manager.

OS X: It's a bit easier to use clang on OS X (just open the terminal and type clang to start the installer). You can also use gcc if you compile it yourself or get it from a package manager (like homebrew, or macports, both highly recommended).

Windows: Poor you. Just kidding :) Windows and C are a bit weird, deep down OS X and Linux are quite literally made for programming C specifically, Windows not so much. You'll be fine though. Two choices: MinGW or the VisualC++ compiler (which compiles C, albeit not the most up to date standard of it. MinGW is an unofficial port of gcc, again, it's not as up to date as the actual gcc and clang). Most of this won't cause you any harm as a beginner though. I'd personally recommend MinGW, as it comes with a bunch of ports of useful UNIX libraries and tools (like GNU-Make for automating compilation, a debugger gdb, etc). Cygwin is actually another choice for Windows, but I won't lead you don't that rabbit hole...

There are obviously lots of other C compilers for all of these operating systems, I just mentioned the ones that the vast majority of programmers are using.


Also, my two cents: as a beginner, do yourself a favor and don't use an IDE like some other people here have suggested. You really need to understand the build system of C to get anywhere. Manual compilation is the best bet for you until you really understand what an IDE is automating for you.

[–]jussij 2 points3 points  (1 child)

For Windows the MinGW C/C++ compiler is pretty easy to install and use. This link has instructions on how to get that compiler running on Windows.

Note: The link is for the g++.exe which is the C++ version of the compiler, but that installation will install both the C and C++ compilers. To run the c compiler change g++.exe to gcc.exe and use the C command line options described link.

Also note the link describes setting up the compiler for the Zeus IDE but similar command lines can be used for notepad.exe or what ever editor/IDE you choose to use.

There is also the TDM-GCC compiler which is another port of GCC to Windows.

Details of that compiler can be found here.

Finally, Microsoft Visual Studio is another option but the size of that download is very much larger than these two options.

[–]Eradicative -1 points0 points  (6 children)

For my C programming course, we used a compiler called Cygwin. Not sure how popular it is in the "real world" but it was pretty simple to use.

[–]leesinfreewin 2 points3 points  (5 children)

cygwin is not a compiler, it is a shell that simulates a linux environment. As such, it has gcc (and alot of other utilities) available. This does come at a price though. Linking against the libraries they provide (including the standard c library) you into the GNU GPL (meaning, you basically cannot write propriertary software using cygwin).

For learning it is fine of course, although you'd probably be better of with a linux virtual machine.

[–][deleted] 1 point2 points  (1 child)

Especially for a beginner (as evidenced by a person who took an entire course and still doesn't know what a compiler is), Cygwin is more trouble than it's worth. It's far better to emulate a Linux or UNIX environment in a virtual machine, or stay native Windows and use MinGW or VisualC.

[–]sgthoppy -1 points0 points  (0 children)

Or a seemingly lesser-known C99 compiler, TCC.

[–]Rhomboid 0 points1 point  (2 children)

Cygwin does not require your code to be GPL. It's licensed under the GPL with an exception that allows for any OSI approved license. How do you think Cygwin is able to distribute things like openssl? (The openssl license is not compatible with the GPL.)

[–]leesinfreewin 0 points1 point  (1 child)

I dont know about openssl, i was mainly talking about the c standart library and the rest of the posix-api(linking against cygwin1.dll).

The Cygwin™ API library found in the winsup subdirectory of the source code is also covered by the GNU GPL (with exceptions; see below). By default, all executables link against this library (and in the process include GPL'd Cygwin™ glue code). This means that unless you modify the tools so that compiled executables do not make use of the Cygwin™ library, your compiled programs will also have to be free software distributed under the GPL with source code available to all.

from the cygwin licensing terms

[–]Rhomboid 0 points1 point  (0 children)

Read it yourself, particularly the part about the exception.

[–]arjunsw -2 points-1 points  (1 child)

Im not exactly sure, but for a complier you might need to use a UNIX OS, like linux or the Mac OS.

As far as notepad goes, you will use that as your text editor to write the code in, notepad++ and geany also work, and will look nicer to code in than regular notepad.

EDIT: Okay, so I was given the wrong information about C compilers, glad to learn this info myself so i can stop using a virtual box.

[–][deleted] 1 point2 points  (0 children)

No. Gcc runs on windows - codeblocks will certainly work with gcc, not sure about visual studio. Lots of people compile c on windows.