Thread: C IDE / Compiler on Linux?

  1. #1
    Registered User
    Join Date
    Feb 2011
    Posts
    17

    C IDE / Compiler on Linux?

    tl;dr - I have eclipse on Ubuntu 10.04, but when I try to run or debug a C code (I made a project, then a new file within it), I get the error "Launch failed. Binary not found". Apparantly I need a compiler, and am not sure which to get nor how to set it up.

    Hello everyone,

    I am new to the forums as well as programming on Linux. I am somewhat of a beginner, and have little experience with Linux as well, in fact I am using Ubuntu 10.04 which I hear is one of the easiest distros out.

    I currently am having a bit of difficulty figuring out what program (google seems to call it an IDE) I need in order to run the practice codes I am going to be writing (For now I am learning from C Programming - A Modern Approach). When I learned C++ in high school, we used something called Visual C++. So far what I have found is called "Eclipse", but I haven't quite figured out how I am supposed to be setting it up.

    With Visual C++, I remember we would create a new project, and then within that project create a new file and write our code in that.

    I've tried to create and run the very first code using Eclipse (just the basic code that outputs the "To C or not to C" pun), but being unsure of what kind of file or project I should be doing it in, I just tried a couple different ones...all I got when trying to run or debug was an error message:
    Launch failed. Binary not found.

    Apparantly, I need to download a compiler as well, but am not sure which would be best on my system while using Eclipse, nor do I know how to set it up, so if anybody could point me in the right direction, that would be greatly appreciated.

    Thanks in advance.

  2. #2
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    An IDE is just software that integrates a editor (usually a spiffy one with syntax highlighting, code completion, templates, etc), a compiler (often just configuration for using an external one), and a debugging interface, again, this can be an interface to an external tool.

    I think there's a little info on setting up a development environment here on cprogramming.com, but I can't find it at the moment.

    Your Eclipse questions would be best answered on an Eclipse forum (check the Eclipse website or Google). Personally I don't use a IDE when I code in Linux. I use Vi to edit and GDB to debug. I would suspect that's what most of the people who've been around a while do, but Vi comes with a fairly steep learning curve.

    As for a compiler, GCC is the standard C compiler for Linux. It probably is already installed, but if not, use your package manager to get it (Apt/Synaptic I think). There should be GCC forums, and "man gcc" is always a great place for info.

  3. #3
    Third Eye Babkockdood's Avatar
    Join Date
    Apr 2010
    Posts
    352
    How do you not have any compilers on Ubuntu 10.04?

    Just compile your code through the Terminal. Use gedit to edit your source files, it has syntax coloring. The cc command compiles C code. If you get a "command not found" (you shouldn't - it's Linux for god's sake) then enter "sudo apt-get install gcc" to install a C compiler.
    Quote Originally Posted by The Jargon File
    Microsoft Windows - A thirty-two bit extension and graphical shell to a sixteen-bit patch to an eight-bit operating system originally coded for a four-bit microprocessor which was written by a two-bit company that can't stand one bit of competition.

  4. #4
    Registered User
    Join Date
    Feb 2011
    Posts
    17
    Quote Originally Posted by anduril462 View Post
    An IDE is just software that integrates a editor (usually a spiffy one with syntax highlighting, code completion, templates, etc), a compiler (often just configuration for using an external one), and a debugging interface, again, this can be an interface to an external tool.

    I think there's a little info on setting up a development environment here on cprogramming.com, but I can't find it at the moment.

    Your Eclipse questions would be best answered on an Eclipse forum (check the Eclipse website or Google). Personally I don't use a IDE when I code in Linux. I use Vi to edit and GDB to debug. I would suspect that's what most of the people who've been around a while do, but Vi comes with a fairly steep learning curve.

    As for a compiler, GCC is the standard C compiler for Linux. It probably is already installed, but if not, use your package manager to get it (Apt/Synaptic I think). There should be GCC forums, and "man gcc" is always a great place for info.
    Ahh okay, so at the moment I don't even really NEED Eclipse then? Say I were to create all the codes in gEdit then, how would I go about running them?
    Would it be similar to python, how in terminal you type python codename.py? If so, what would be the substitute for "python" in this case, GCC?

  5. #5
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    Quote Originally Posted by Opi8 View Post
    Ahh okay, so at the moment I don't even really NEED Eclipse then? Say I were to create all the codes in gEdit then, how would I go about running them?
    Would it be similar to python, how in terminal you type python codename.py? If so, what would be the substitute for "python" in this case, GCC?
    Nope, C is not a scripting/interpreted language. You have to compile it to get an executable to run. Get yourself a terminal and try the following (assuming your source code is in foo.c):

    cd /directory/to/source/code
    gcc foo.c
    ./a.out

    You really need to read the gcc documentation (type man gcc) and look at all the command line options, so you can give the executables sensible names and turn on all the warnings to make sure you're coding properly as you learn.

  6. #6
    Third Eye Babkockdood's Avatar
    Join Date
    Apr 2010
    Posts
    352
    Quote Originally Posted by The Jargon File
    Microsoft Windows - A thirty-two bit extension and graphical shell to a sixteen-bit patch to an eight-bit operating system originally coded for a four-bit microprocessor which was written by a two-bit company that can't stand one bit of competition.

  7. #7
    Registered User
    Join Date
    Feb 2011
    Posts
    17
    Quote Originally Posted by Babkockdood View Post
    Thank you very much for the link.

  8. #8
    Registered User
    Join Date
    Feb 2011
    Posts
    17
    ./a.out
    could you please explain what this does? Do I have to retype the directory, and then /a.out, what is the purpose of this command, etc?

  9. #9
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    Runs the executable named a.out that is in the current directory (. represents the current directory, / separates the directory from another directory component or file name and a.out is the name of the executable file). GCC produces a.out by default if you don't give it another name to use.

  10. #10
    Registered User
    Join Date
    Feb 2011
    Posts
    17
    Okay thanks, I've got this figured out now. Mod can mark this as solved.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiler dependencies. What are they?
    By shrink_tubing in forum C++ Programming
    Replies: 5
    Last Post: 01-09-2010, 10:57 PM
  2. linux C++ IDE with this particular feature:
    By elninio in forum C++ Programming
    Replies: 10
    Last Post: 06-04-2008, 02:30 PM
  3. Replies: 14
    Last Post: 11-22-2006, 07:18 PM
  4. Linux newbie - trouble with installing a IDE
    By geek@02 in forum Linux Programming
    Replies: 4
    Last Post: 09-10-2005, 10:09 AM
  5. What's your opinion on my IDE and Compiler?
    By drdroid in forum C++ Programming
    Replies: 2
    Last Post: 01-01-2003, 12:38 PM