C and C++ compiler for windows

A place to discuss the implementation and style of computer programs.

Moderators: phlip, Moderators General, Prelates

v1nsai
Posts: 332
Joined: Tue Feb 03, 2009 4:15 am UTC
Location: Florida

C and C++ compiler for windows

Postby v1nsai » Mon Sep 07, 2009 8:34 pm UTC

I've been trying to get my roommate's laptop set up so I can do homework for my C and C++ classes. It runs Windows so there are many different versions out there and I've so far installed visual c++ (ridiculously complicated) cygwin and gcc (compiled programs won't run in windows environment, kind of hard to test) and lcc (which only does C if I'm reading correctly).

Anyway, I just need a compiler that compiles. Something like gcc that can be called just by using "gcc sourcefile.c -o outputBinary". I've been trying to set up a compiler for an hour, haven't gotten any damn homework done and now the storm is passed so I can just go do this on my linux box and not have to fuck with it but I want to understand it from both platforms, Windows is still kind of popular. I'd really appreciate a suggestion :-D
C:\dos
C:\dos.run
run dos.run

0xBADFEED
Posts: 687
Joined: Mon May 05, 2008 2:14 am UTC

Re: C and C++ compiler for windows

Postby 0xBADFEED » Mon Sep 07, 2009 8:40 pm UTC

What does your instructor say to use? Gcc + cygwin is fine on Windows. What problems are you having? What will your instructor use to compile your programs?

Also
Windows is still kind of popular

Understatement of the century.

User avatar
You, sir, name?
Posts: 6983
Joined: Sun Apr 22, 2007 10:07 am UTC
Location: Chako Paul City
Contact:

Re: C and C++ compiler for windows

Postby You, sir, name? » Mon Sep 07, 2009 8:54 pm UTC

Why can't you just write portable code* in Linux... because let's face it, Windows is about as coding friendly as a keyboard made of broken glass and rusty barbwire in a salt desert. Or maybe I'm doing it wrong, and there is some way of coding in windows without the experience of dread and despair.

*Just compile with "gcc -ansi -pedantic", and there shouldn't be any outstanding portability issues.
I edit my posts a lot and sometimes the words wrong order words appear in sentences get messed up.

v1nsai
Posts: 332
Joined: Tue Feb 03, 2009 4:15 am UTC
Location: Florida

Re: C and C++ compiler for windows

Postby v1nsai » Mon Sep 07, 2009 9:34 pm UTC

haha I'd have to agree with you about the Windows coding environment, it's about as straightforward as trying to use Windows (msconfig totally means startup programs, that doesn't require explanation right?) but it probably won't be going anywhere unless they completely drop the ball on Win7 too. But that's another rant.....

But I was asking because I want to write and test in Windows because it's not my laptop so if I want to code on the couch I have to use Windows -_-

edit:
nice name man haha
C:\dos
C:\dos.run
run dos.run

Unparallelogram
Posts: 336
Joined: Mon Jul 28, 2008 4:16 am UTC

Re: C and C++ compiler for windows

Postby Unparallelogram » Mon Sep 07, 2009 9:51 pm UTC

If that's your issue, totally install a VM.

notallama
Posts: 236
Joined: Fri Jun 01, 2007 4:28 pm UTC

Re: C and C++ compiler for windows

Postby notallama » Mon Sep 07, 2009 10:19 pm UTC

there's mingw.

it's a gcc port to windows. (as in, it compiles into something that runs on windows)
i have not tried it, though, due to windows being such a pain in the ass to work on.

0xBADFEED
Posts: 687
Joined: Mon May 05, 2008 2:14 am UTC

Re: C and C++ compiler for windows

Postby 0xBADFEED » Mon Sep 07, 2009 10:42 pm UTC

In defense of Windows as a (C++) coding environment, once you get past the initial hurdle of learning how to setup and use VisualStudio it is actually quite a good platform. Any other C++ setup on Windows is basically shit though compared to the equivalent on other systems.

If you plan to do coding in Windows (for work or play) it's a good idea to get familiar with VisualStudio.

User avatar
Sc4Freak
Posts: 673
Joined: Thu Jul 12, 2007 4:50 am UTC
Location: Redmond, Washington

Re: C and C++ compiler for windows

Postby Sc4Freak » Mon Sep 07, 2009 10:47 pm UTC

It depends on whether you're looking for an actual IDE or just regular old command-line tools. Command-line tools are a major pain in the @ss to work with on Windows, which is why I'd recommend using an IDE. As others have said, you can use mingw, but it's hardly pleasant to use.

Visual Studio really is the IDE of choice for C++ - but like you said, it does have a steep learning curve. For professional development, you'll want to be using Visual Studio (because the productivity gains outweigh the initial learning curve). But if you're not going to be doing any "real" development or can't be bothered learning the ins-and-outs of VS, a simpler IDE might suffice. If you don't want to use Visual Studio, I recommend trying out Code::Blocks.

v1nsai
Posts: 332
Joined: Tue Feb 03, 2009 4:15 am UTC
Location: Florida

Re: C and C++ compiler for windows

Postby v1nsai » Mon Sep 07, 2009 11:05 pm UTC

Hmm...I definitely want to learn visual studio eventually. I'm coding as a hobby right now but it's a pretty marketable hobby and not learning industry standards is only hurting yourself. I love Linux but it's hard to make money with it.

What if I put Visual Studio in VMWare? Would there be any drawbacks to developing and compiling in a virtualized environment?
C:\dos
C:\dos.run
run dos.run

User avatar
Sc4Freak
Posts: 673
Joined: Thu Jul 12, 2007 4:50 am UTC
Location: Redmond, Washington

Re: C and C++ compiler for windows

Postby Sc4Freak » Mon Sep 07, 2009 11:43 pm UTC

One is performance. As much as I love VS, it runs so slow that it makes me want to punch the screen at times. Running it in a VM will only make it worse. If you're programming anything which requires access to actual hardware (eg. hardware-accelerated 3D graphics) then you can't really run it from within the VM.

But if you're not writing 3D applications, I think it should run just fine in a VM. The performance loss can be overlooked if it's more convenient to run it in a VM, I think.

dosboot
Posts: 143
Joined: Sun Jul 01, 2007 5:26 am UTC

Re: C and C++ compiler for windows

Postby dosboot » Tue Sep 08, 2009 2:34 am UTC

mingw with msys is a very nice environment for windows. Don't listen to everyone until you've tried it. It is likely exactly what you are looking for.

User avatar
laranzu
Posts: 104
Joined: Fri Nov 30, 2007 4:21 pm UTC
Location: Physical: Canberra, Australia
Contact:

Re: C and C++ compiler for windows

Postby laranzu » Tue Sep 08, 2009 5:37 am UTC

v1nsai wrote:I've been trying to get my roommate's laptop set up so I can do homework for my C and C++ classes. It runs Windows so there are many different versions out there and I've so far installed visual c++ (ridiculously complicated) cygwin and gcc (compiled programs won't run in windows environment, kind of hard to test) and lcc (which only does C if I'm reading correctly).

Anyway, I just need a compiler that compiles. Something like gcc that can be called just by using "gcc sourcefile.c -o outputBinary". I've been trying to set up a compiler for an hour, haven't gotten any damn homework done and now the storm is passed so I can just go do this on my linux box and not have to fuck with it but I want to understand it from both platforms, Windows is still kind of popular. I'd really appreciate a suggestion :-D


I'd go for MinGW on MS Windows.

It's pretty much GCC with a minimal DOS/MS Windows wrapper. Still runs from the command prompt, but generates and links with standard MS libraries or DLLs. And it doesn't try to pretend that you can magically turn MSWin into Unix like Cygwin does.

Second choice would be Visual Studio Express. It's free, and you can run it from the command line once you get used to differences such as "make" being renamed "nmake"

Hope this helps.

fazzone
Posts: 186
Joined: Wed Dec 10, 2008 9:38 pm UTC
Location: A boat

Re: C and C++ compiler for windows

Postby fazzone » Tue Sep 08, 2009 10:26 am UTC

I use Dev-C++ whenever I do coding on windows, because (even though it's old) I prefer it to Visual Studio. It comes with a simple but good IDE, and the MinGW toolset, so if you add C:\Dev-cpp to your $PATH, you can invoke gcc from a regular command prompt.
*/

User avatar
thoughtfully
Posts: 2253
Joined: Thu Nov 01, 2007 12:25 am UTC
Location: Minneapolis, MN
Contact:

Re: C and C++ compiler for windows

Postby thoughtfully » Tue Sep 08, 2009 12:03 pm UTC

Is this for when you don't have access to the internet? Most schools give you unix accounts you can compile in.
Image
Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.
-- Antoine de Saint-Exupery

kmatzen
Posts: 214
Joined: Thu Nov 15, 2007 2:55 pm UTC
Location: Ithaca, NY

Re: C and C++ compiler for windows

Postby kmatzen » Tue Sep 08, 2009 12:41 pm UTC

Here are some instructions we use for Visual Studio in order to get as standard behavior as possible. Supposedly, according to MSDN, even putting a .c file in the build path will automatically build it as C89.

http://www.engin.umich.edu/class/eecs38 ... Notes.html

You, sir, name? wrote:Why can't you just write portable code* in Linux... because let's face it, Windows is about as coding friendly as a keyboard made of broken glass and rusty barbwire in a salt desert. Or maybe I'm doing it wrong, and there is some way of coding in windows without the experience of dread and despair.


Yeah, you are doing it wrong. I agree the menus are irritating, but if you open up your solution file in a text editor, all the options are right there for you. Just pretend it's a pretty makefile.

User avatar
Ephphatha
Posts: 625
Joined: Sat Sep 02, 2006 9:03 am UTC
Location: Bathurst, NSW, Australia

Re: C and C++ compiler for windows

Postby Ephphatha » Tue Sep 08, 2009 12:48 pm UTC

You're doing it wrong.

Install either Dev-C++ or Visual Studio 2008 Express using basically the default options at every step. Now, if you are fine using a text editor to write your code and only want a compiler, easy. Assuming you downloaded VS (since I don't have Dev) run it, read the prompts and select the appropriate options (it's fairly straightforward), and then you should be greeted with the start page. Go to file > new > project, select win32 as your project type, and win32 console application as your template. Enter a name, a location to save and uncheck the "create directory for solution" box. Click ok. Click next, check the "Empty Project" box, make sure the console application radio button is selected, and click finish.

If you've done everything correctly you should see the pane on the left change to show "Solution <projectname>". Right click on the bolded line, go down to add > existing item, and find your source files. Next you'll want to click the green arrow near the middle of the toolbar (that runs across the top of the screen). All this should have taken you roughly 50 seconds (not counting install time). That's all you have to do to use it as a compiler. If you get errors they show up in the output window and the error window, if you get runtime errors it unfortunately usually opens the source file and selects the line with the error.
I'm not lazy, I'm just getting in early for Christmas is all...


Return to “Coding”

Who is online

Users browsing this forum: No registered users and 11 guests