which c++ compiler for linux?

Discussion in 'Linux, BSD and Other OS's' started by zeus, Dec 1, 2006.

  1. zeus

    zeus out of date

    Likes Received:
    0
    Trophy Points:
    36
    Ive been using dev-c++ to compile code in windows but now want to compiile code is linux.

    Whats the best to use? I was trying to find Dev-C++ for linux but apparently its not supported anymore.
     
  2. Addis

    Addis The King

    Likes Received:
    91
    Trophy Points:
    48
    The best C++ compiler for Linux is g++. It is part of GCC, the GNU Compiler Collection. The main compiler of the system is gcc which is the C compiler.

    In the command line, you compile a source file with
    Code:
    g++ main.cpp -o programname
    If you omit the -o its argument, g++ names the program "a.out" which isn't very descriptive.

    I'm guessing you need an IDE as well, I suggest using a text editor like Kate which has brilliant syntax highlighting and indentation features.

    To set up Kate for best C/C++ coding, try in Settings/Configure Kate:
    • Editing section -> Disable show tabulators
    • Editing section -> Enable "Insert spaces instead of tabulators"
    • Indentation section -> Style as "C Style" and enable "Use spaces instead of tabs"
    • Indentation section -> Number of spaces = 4 (most common IMO) and also enable "Adjust clipboard identation"
    • Indentation section -> Insert indent characters when tab is pressed

    Thats just my preferences for C++. If you click the terminal button at the bottom of Kate, you can use the terminal as well as edit the file at the same time.

    Few tips:
    F11 shows line numbers
    Tools menu has options for changing the indentation profile and syntax highlighting for one off occasions. If the C style indentation isn't working how you want it (outside of main() for example) then choose Normal indentation until you get inside a function.
     
  3. zeus

    zeus out of date

    Likes Received:
    0
    Trophy Points:
    36
    Thanks, I'll try it now.
     

Share This Page