c++ - linking <iostream.h> in linux using gcc -


I'm trying to run my first C ++ program in Linux (linux mint 8). I use both GCC or G ++ with the same problem: the compiler is not able to find the library, which I am trying to import.

I have some doubts as if I should copy the iostream.h file in the work folder (which I do not know), move my file somewhere else to compile or use some option Sort Sort

Thank you for your suggestions.

Here is the GCC command, the C ++ code and the error message:

  GCC -o addition list2 .5.c  

.

  #include & lt; Iostream.h & gt; Int edition (int a, int b) {return (a + b); } Int main () {cout & lt; & Lt; "Results:" & lt; & Lt; Addition (2, 4) & lt; & Lt; "\ N"; Return 0; }  

.

  listing2.5.c: 1: 22: error: iostream.h: No such file or directory is listed.2. Cc: Function in 'Main': listing2.5.c: 10: Error: 'Cout' undeclared (first use in this function) listing.2.5.c: 10: Error: (Each unauthorized identifier is reported only once in the list : 10: Error: appears for each function in it.)  

The code is now compiled, but I can not run it using the command line through the filename. addition: command not found any suggestions?

  • cout is defined in std :: namespace , You just need to use cout instead of std :: cout .
  • If you want to use G ++ to compile C ++ programs, it will link to standard C ++.
  • library. GCC will not have GCC will also compile your code as C code if you have it one. C suffix. Give your files the .cpp suffix.

Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -