#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2003
    Posts
    8
    Rep Power
    0

    C compiler needed


    I would like to know what it takes to write C programs, compile and run them.

    I think C compiler is required. Can i get it from anywhere for free and would like to know what else is required.
  2. #2
  3. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,172
    Rep Power
    2222
    Oh, yes, a C compiler is a very definite must. As for running the program, compiling it produces an executable file, so you just run that executable at the command line.

    Before we can recommend a free C compiler, we need to know what OS you are running.

    If Linux, then you should already have the GNU C compiler installed, gcc. If not, then it should be on your distro CDs, in which case you will have to install it and its development libraries. If it is not on the distro CD (I encountered that with ManDrake 7.2; gcc was only on the more expensive Power-User distro), then you will need to download it.

    If you are running Mac OS X, then you are actually running FreeBSD. I've not worked with FreeBSD, but I assume that it comes with a C compiler -- I just don't know what it would be called (cc?). You would have to do all this from the terminal, I'm sure.

    Safest bet is that you are running Windows, in which case you have a few options available.

    If you feel more comfortable with a brand name, Borland offers version 5.5 (Aug 2000) of their C++ compiler and command-line tools for free download. Go to http://www.borland.com/products/down..._cbuilder.html . I found their on-line registration a bit of a hassle. In addition, you'll get the 32-bit version of grep and a few other command-line utilities. Note that you will also be able to compile both C and C++ programs with this compiler.

    Another free C compiler is lcc-win32 at http://www.cs.virginia.edu/~lcc-win32/ . Please note that this is C only, not C++. Even if you don't use lcc-win32, a visit to their site would still be worth your while for the documentation and C tutorial that they offer.

    Another free C/C++ development environment that is widely recommended on this forum (that's where I learned about it) is Dev-C++ by Bloodshed Software at http://www.bloodshed.net/ . It's a fairly complete IDE that uses the MinGW port of gcc to Windows.

    If all you want is the compiler itself, then you can download MinGW's gcc directly from their site at http://www.mingw.org/ .

    Share and enjoy!
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2003
    Posts
    8
    Rep Power
    0

    C Compiler


    I am using Windows XP as my operating System. I have Pentium 4. Suggest me the exact procedure. And thank you very much for your help.
  6. #4
  7. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,172
    Rep Power
    2222
    Well, then, that boils it down to Borland, lcc-win32, or Dev-C++. Pick one and perform the installation.

    Borland will be strictly command-line, AKA "DOS" AKA "Command Prompt". You know, that icon that Microsoft keeps burying deeper and deeper trying to hide it from us. You would most likely need to create and use a makefile for it, which adds an extra layer of complexity. So Borland might not be your best bet.

    lcc-win32 and Dev-C++ both provide you with a GUI integrated development environment (IDE), which gives you an editor, dialogs for setting up your projects, allows you to run the compiler from within the IDE, displays error messages, and (usually) takes you straight to the line of code that caused the error. They also usually include a debugger.

    Dev-C++ appears to be used more widely here than lcc-win32, so more help should be available with it. Also, when you want to move on to C++, you'll already have a compiler and IDE that you're familiar with (remember, lcc only does C). And if you want to do it all from the command-line instead (my personal choice, but then I'm an old DOS'er from before Windows v1.0 and a Linux neophyte), then I can step you through that for Dev-C++.

    Dev-C++'s stable version is Version 4 and its Version 5 is in beta. There have been reports here of v5 having problems under XP, whereas others report that they use v4 under XP with no problems at all. So if you go with Dev-C++, I would recommend that you start out with version 4.

    Once you download the software, simply follow the instructions on the web page and/or in the readme file.
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2003
    Posts
    8
    Rep Power
    0

    Error in Dev-C++ 4


    I did download the version 4 and wrote a small C program but while compiling i am getting an error that

    instalation problem, cannot exec 'gcc': No such directory

    can't exec 'gcc': No such file or directory

    Guide me on this one. What can be wrong?
  10. #6
  11. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2003
    Posts
    8
    Rep Power
    0

    Visual Studio 6


    Can i use Visual C++ to write my C programs and run them?
  12. #7
  13. #8
  14. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,172
    Rep Power
    2222
    Originally posted by jayshah11
    I did download the version 4 and wrote a small C program but while compiling i am getting an error that

    instalation problem, cannot exec 'gcc': No such directory

    can't exec 'gcc': No such file or directory

    Guide me on this one. What can be wrong?
    It looks like Dev-C++ cannot find gcc, which doesn't make any sense to me. gcc should have been installed and Dev-C++ should know where to find it.

    Now, I assume that you are doing the compile from within the IDE -- but of course, DOS would report "Bad command or file name", unless they changed that for XP.

    Dev-C++ should have created a directory off the root called dev-c++ . In that directory there should be a subdirectory called bin . Look inside that directory (\dev-c++\bin) and verify that the file, gcc.exe, is there. If it is not, then somehow the installation did not work and you would need to reaccomplish it.

    BTW, if you were trying to run gcc from the command line, then you will need to add \dev-c++\bin with its drive letter to the search path; eg,
    PATH=C:\Dev-C++\bin;%PATH%
    You should not need to do this if you are compiling within Dev-C++.

    Originally posted by jayshah11
    Can i use Visual C++ to write my C programs and run them?
    You had originally specified "free", so I did not mention Visual C++ -- Bill Gates was one of the first ones to strongly advocate non-free software.

    VC++ is strongly oriented towards GUI apps, but you can create console apps with it. When you do a File | New to call up the New dialog, under the Projects tab select "Win32 Console Application", give it a project name and location, and click OK. Select "An empty project" and click on Finish and then OK on the verification dialog. Now create a new text file, save it as a .C file, and add it to the project (Project | Add to Project | Files). When you compile the program, the .exe file will be in the debug subdirectory -- I normally open a DOS window and cd to that subdirectory to run the program.

    That's how I used to do all my network programs until I started using Dev-C++'s gcc -- from the command line, of course.
    Last edited by dwise1_aol; April 24th, 2003 at 10:45 AM.

IMN logo majestic logo threadwatch logo seochat tools logo