I am beginner unix programmer I have written small c++ program in text editor and I have change it mode to 555 to make it executable file to use it in unix O.P.
#include<iostream.h>
main()
{
cout<<"Hello World";
}
but some syntax erroe came for <<
can any one help me how can I make executable file to use it unix o.p.
$ g++ c.cpp
In file included from /usr/include/c++/3.2.3/backward/iostream.h:31,
from c.cpp:1:
/usr/include/c++/3.2.3/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <sstream> instead of the deprecated header <strstream.h>. To disable this warning use -Wno-deprecated.
Er, no. You cannot change your file's type. Your file still remains a text file with C++ source code which Unix cannot execute. You have to compile the file. In porter's post, the 'g++ c.cpp' command is compiling the file.
Is this your first C/C++ program on any OS? If you have written any programs before, you would know that you need to compile these before executing them.
if the C++ compiler on your system is Gnu C++ then use
g++ c.cpp -o myprogram
and the executable will be in the file "myprogram", if you look at the file attributes you will notice the compiler (linker actually) has already made the file as an executable (+x).