Compiling C++

K

Kryyll

Guest
I decided that I wanted to learn a little C++ in my spare time. I started reading some tutorials and made a really simple hello world program (how else would you start!? :D) and for some reason it won't run.
When I enter the command
Code:
gcc -o foo foo.cc
I get a message saying that it canny find the iostream directory.
I know that we don't use iostream.h anymore and have it in the code as
Code:
#include <iostream>
Any ideas?

Also, what language does one use to program with Ncurses?
 


D

DevynCJohnson

Guest
Ncurses can be used with many languages if you have the right bindings and libraries.

As far as your C++ error, I do not know enough yet to solve the issue.
 
K

Kryyll

Guest
I actually figured it out. I'm not sure why but using the gcc command gets that error however if you use
Code:
g++ -o foo foo.cc
it works. Not really sure why.
 
R

ryanvade

Guest
gcc is for the C programming language while g++ is for the C++ programming language. You cannot use the gcc compiler for C++ and vice-versa.
;)
 
K

Kryyll

Guest
Well that would explain the C's in gcc and the pluses in g++... Man linux is hard ;D
 
M

Matesax

Guest
I recommend D language (GDC) - it's more better than C++... (And it's backward compatible with C++.)
 
K

KenJackson

Guest
You cannot use the gcc compiler for C++ and vice-versa.
;)
I'm not interested enough to experiment, but the man page lists an -x switch that lets you choose the language. So you should be able to specify -x c++ to compile C++ with gcc.

Or you could compile ada, go, java, several flavors of fortran and objective-c and others.
 
R

ryanvade

Guest
Code:
  -x language
          Specify explicitly the language for the following input files
          (rather than letting the compiler choose a default based on the
          file name suffix).  This option applies to all following input
          files until the next -x option.  Possible values for language are:

                  c  c-header  cpp-output
                  c++  c++-header  c++-cpp-output
                  objective-c  objective-c-header  objective-c-cpp-output
                  objective-c++ objective-c++-header objective-c++-cpp-output
                  assembler  assembler-with-cpp
                  ada
                  f77  f77-cpp-input f95  f95-cpp-input
                  go
                  java
using the -x switch would probably just run the associated compiler.
 


Staff online

Members online


Latest posts

Top