Click to See Complete Forum and Search --> : what are the steps to writing a c++ program for red hat 8?
jimang29
01-13-2003, 10:36 PM
I cant even execute a single program?!!?
I wrote a simple program in emacs and saved it as test.cc. Then i think i typed in gcc tes.cc under shell mode and I got all kinds of errors.
Should I use a different editor?
How should i save the program?
how should i run the program?
Any help appreciated!
bwkaz
01-14-2003, 12:04 AM
Should I use a different editor? Not if you like emacs. Any text editor should do just fine for the job. The one thing to watch out for is, make sure your editor isn't thinking you're doing word processing. But emacs doesn't do that, so it'd work fine.
How should i save the program? Err... just like anything in emacs, there's really only one way to save... I guess I'm not quite sure what you're asking here, or something.
how should i run the program? Like any other, except you'll probably have to give the path. If you call it test.cc and compile to test, you would run the program with ./test, most likely.
When you say "a simple program", what was it? Post the source code, between code tags (they look like [ code ] and [ /code ], but without the spaces). It is possible that there are syntax errors or something.
When you say "I got all kinds of errors", what were they? Post them, ideally word-for-word.
My first guess is either a typo in the program (I know I've done that enough) or something in the environment. Well, wait a minute, it might be that you used gcc as well. g++ is for C++ programs; gcc is for C programs.
jetblackz
01-14-2003, 12:01 PM
>Should I use a different editor?
Doesn't matter. Most Unix/Linux editors save files in plain text format. emacs is probably the most powerful text editor there is.
>How should i save the program?
Save it as .c or .cpp depending on the program.
>how should i run the program?
gcc hello.c -o hello
./hello
ljd65536
01-14-2003, 11:24 PM
For C++, I think you have to type g++ instead of gcc. At least that true on every Linux machine I have used.
If you compile within emacs, you can quickly jump to the line where there are compilation errors on a split window. Also, if you set font-lock-mode, it will fontify your program and help with indents.