Page 2 of 2 FirstFirst 12
Results 11 to 14 of 14

Thread: How Exactly do I Install C and C++?

  1. #11

    Re: How Exactly do I Install C and C++?

    3 easy commands: edit, compile, run.

    Code:
    gedit file.c
    (You may replace gedit with your editor of choice.) Write your code in the editor, save it, then
    Code:
    gcc -std=c99 -Wall -Wextra -pedantic file.c
    ./a.out
    Boom. It's a similar process for C++ (although I would suggest you pick one and stick with it for a while; C and C++ are quite different).

    The -std=c99 -Wall -Wextra -pedantic bit is strictly speaking not necessary. Those flags just tell gcc what dialect of C to compile (C99, in this example) and turn on a bunch of warnings that will probably help you avoid some dumb mistakes when getting started. You can alias that whole bit to something shorter; just add the following line to ~/.bash_profile and use "cc file.c" instead:

    Code:
    alias cc="gcc -std=c99 -Wall -Wextra -pedantic"
    Just a few tips. Have fun.

  2. #12
    Join Date
    Apr 2013
    Beans
    13

    Re: How Exactly do I Install C and C++?

    Thank you for the help everyone.

  3. #13
    Join Date
    Jan 2011
    Beans
    193

    Re: How Exactly do I Install C and C++?

    Maybe another tip.
    If not very familiar with C and C++ it would be helpfull to use a developers gui with commandcompletion.

    I used a few days ago the QT- developers suit. That is a real nice tool to create smal and big progs.
    Also some helpfull tutorial files are shiped with it.

    This package is also almost a wysiwyg , at least the gui designer is build-in.
    Last edited by kuifje09; April 29th, 2013 at 12:27 AM.

  4. #14
    Join Date
    Jan 2011
    Beans
    193

    Re: How Exactly do I Install C and C++?

    Would it be better to also add -march="your processor/architecture" to make the fastest executable for you machine.
    And when using the math routines add -lm at the END of the cc/gcc commandline

    Note: this in reaktion to post #11 .

Page 2 of 2 FirstFirst 12

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •