gcc - Printable Version +- Linux-Noob Forums (https://www.linux-noob.com/forums) +-- Forum: Linux Noob (https://www.linux-noob.com/forums/forum-3.html) +--- Forum: Tips and Tricks (https://www.linux-noob.com/forums/forum-59.html) +---- Forum: Compiling (https://www.linux-noob.com/forums/forum-29.html) +---- Thread: gcc (/thread-3482.html) |
gcc - seeno - 2004-04-08 when i try to compile this simple c++ source Code: #include<iostream.h> with Code: [seeno@localhost seeno]$ gcc helloworld.cpp i get this Code: In file included from /usr/include/c++/3.2.2/backward/iostream.h:31, and when i compile with the -Wno-deprecated option, i just get this Code: [seeno@localhost seeno]$ gcc -Wno-deprecated helloworld.cpp gcc - hijinks - 2004-04-09 you are almost there.. the main function must always return a int value. Now normal functions in C++ are called with void. That means they return no value. If you want them to return a value you call it with int main() {} so try this Code: #include <iostream.h> now don't use gcc as your compiler. That is the C compiler and iostream is a C++ header. You need to use g++ as your compiler Code: g++ -o helloworld helloworld.cpp Also you'll notice my main() includes some arguements. Those aren't needed for a basic hellow world app so you can just use int main() but if you want to make like a console based app where you are passing in flags then thats what those argc and argv values are for. hope it helps.. if you have anymore C++ questions you can reach me on efnet.. under the nick Jy i'm always in fedora and #redhat.. gcc - TormentoR - 2004-04-09 A few things: if you're using 'int main()' you should return an int! so add return 0; to the program to tell linux your program exited with no error. including with .h is deprecated... see the compiler error cout is located in std namespace, so use that namespace or call cout with std::cout Code: #include <iostream> save that file as 'helloworld.cpp' and type 'make helloworld' to compile it. my 2 cents gcc - seeno - 2004-04-10 Thanks alot :) Now i can go ahead and read the tuts without banging my head :P |