|
|||||||||||
|
Re: [clug-programming] getting started in programming...
From: Mat Kovach <mkovach-clug-programming(at)neolug.org>
Date: Tue Nov 26 2002 - 10:34:38 EST On Tue, Nov 26, 2002 at 06:11:16AM -0800, Joe Frost wrote: } else. Maybe joe. I name everything joe. I hope you don't have any daughters! The original question shows somebody new to UNIX programming (it appears). It might be wise to surf the web a bit a learn about the UNIX programming enviroment (make, etc) which can be a bit confusing to new people (heck, even long time users can get confused). The basic problem this person had was that they used gcc (the c compiler) instead of g++ (the gnu c++ compiler). While he had the correct syntax, he did a few things that warrent a bit of discussion. In UNIX, you don't have to end an executable (or just about any file) with an extention to make it executable. That is handled by providing the correct file mod bits (chmod u+x allows the user to execute it). gcc/g++ will do this for you.
mkovach@neolug:~ > cat test.c
The usage of -lm (to include the math library) is not needed as the man c/c++ libraries (glibc) include the functionality of the old libm, so that is not required. Also, .cc, .c++ or .C is generally the accepted source code extention for C++ programs. I would change the orginal command to: g++ -o cc-test test.c Now, if you still find errors about missing header files it could be possible that you don't have the correct C++ development packages installed. You also might want to consdier learning how to use make, or create some simple compile, make-exe shell files to save you some typing. I'll use something like:
kovachme@dev1:/home/kovachme/projects/base> more compile
#!/bin/sh
kovachme@dev1:/home/kovachme/projects/base> more make-exe
#!/bin/sh
(whose I idea I stole from somebody else). This allows me to compile programs and then create executables.
kovachme@techsrv3:/home/kovachme/projects/base> cat >> hello.c << END
Mat
-*-*-
clug-support -- For all your linux support needs clug-announce -- For all announcements of upcoming CLUG eventsAnd don't forget about our website: http://cleveland.lug.net Received on Tue Nov 26 14:04:10 2002 This archive was generated by hypermail 2.1.8 : Wed Aug 23 2006 - 12:41:05 EDT |
||||||||||
|
|||||||||||