Re: [suse-programming-e] C Programming in Linux
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Tue, 16 Dec 2003 15:32:10 EST KPP52@aol.com wrote:
I have Personal 9.0 I wrote the basic C program first.c then I did: gcc -o first first.c then I tried to run it by typing: first and it gives me a message: bash first no such command. so I tried: gcc first.c there was an a.out file in the directory then I typed: a.out and it gives me the same error message. Is there something I'm missing with the C compiler here? I'm new to SuSE and new to linux in general. I have done some C programming in Unix and this is confusing me tremendously. Any help would be greatly appreciated.
Let me add some clarifications to some of the postings on this. I think that Keo gave the correct answer (This is what I posted to the SuSE English list): gcc -o first first.c This creates the file, first, with the correct executable permissions. gcc first.c This creates a.out with the correct executable permissions. As Gary mentioned, by default SuSE (and nearly every other Linux and Unix system) does not include the current directory in your PATH environment variable for security reasons. For this reason, you must use either absolute or relative path to execute files that are not in your PATH. For this reason, to execute anything in your current directory, you must use the relative path (eg. ./<name of file> ) or the full path (eg. /home/yourusername/<path to current directory>/<filename>). So to execute first: ./first or to execute a.out: ./a,out - - -- Jerry Feldman <gaf@blu.org> Boston Linux and Unix user group http://www.blu.org PGP key id:C5061EA9 PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9 - -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2-rc1-SuSE (GNU/Linux) iD8DBQE/37jz+wA+1cUGHqkRAjzSAJ0bYcV09uCoGQSsKiivq4X7q8BSXACcCaEi KvO3Gwa4YJ9wVwfZNtpmroc= =EyXP - -----END PGP SIGNATURE----- -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2-rc1-SuSE (GNU/Linux) iD8DBQE/37n9+wA+1cUGHqkRAj7FAJ9UNMv+zwLCPXisahxm3v6UJyTiYgCeKAOu /eJ+vCk+vHY8zCBnW1LDzgc= =d8HV -----END PGP SIGNATURE-----
On Tue, 16 Dec 2003, Jerry Feldman wrote:
So to execute first: ../first
or to execute a.out: ../a,out
Should be ./first or ./a.out (only one dot before the slash) if first and a.out are in the current directory. (Two dots, as in ../second, takes you to the directory immediately above.) Do ls . (for the current directory) and ls .. (for the one above) to see this.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 You are absolutely correct, that was a typo. On Tue, 16 Dec 2003 18:39:33 -0800 (PST) Michael Marking <marking@tatanka.com> wrote:
On Tue, 16 Dec 2003, Jerry Feldman wrote:
So to execute first: ../first
or to execute a.out: ../a,out
Should be
./first
or
./a.out
(only one dot before the slash) if first and a.out are in the current directory.
(Two dots, as in ../second, takes you to the directory immediately above.)
- -- Jerry Feldman <gaf@blu.org> Boston Linux and Unix user group http://www.blu.org PGP key id:C5061EA9 PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2-rc1-SuSE (GNU/Linux) iD8DBQE/4FOo+wA+1cUGHqkRAqxuAJ97xBmyjlMStWe0WPQkF7VMawetFQCfbXic Ajy7YyvOrRiaSxU0sG9bsZE= =HRHE -----END PGP SIGNATURE-----
participants (2)
-
Jerry Feldman
-
Michael Marking