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.
On Tuesday 16 December 2003 15:32, 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.
The search path for executables does not necessarily include the current directory. Preface the executable name with "./", e.g., "./first", in order to specify that it is found relative to the current directory.
Hello, Try to type './first' instead of 'first' When we want execute a command in the same directory we are, we should type the prefix './' by security reasons. Guillermo. On Tuesday 16 December 2003 21:32, 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.
-- Guillermo Ballester Valor Linux user #117181. See http://counter.li.org/ gbv@oxixares.com http://www.oxixares.com/~gbv/ Ogijares, Granada SPAIN
On Tuesday 16 December 2003 20:32 pm, 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.
You need to make your target file (./first) executable. See man attr if you need to... Dylan -- Sweet moderation Heart of this nation Desert us not We are between the wars - Billy Bragg
* Dylan
You need to make your target file (./first) executable. See man attr if you need to...
That's done by the gcc compiler, so no need to worry about that. -- Mads Martin Joergensen, http://mmj.dk "Why make things difficult, when it is possible to make them cryptic and totally illogical, with just a little bit more effort?" -- A. P. J.
On Tuesday 16 December 2003 21:45 pm, Mads Martin Joergensen wrote:
* Dylan
[Dec 16. 2003 21:58]: You need to make your target file (./first) executable. See man attr if you need to...
That's done by the gcc compiler, so no need to worry about that.
That's another thing learnt! Never actually looked at the permissions, just did the chmod automatically. Less typing next time! Dylan
-- Mads Martin Joergensen, http://mmj.dk "Why make things difficult, when it is possible to make them cryptic and totally illogical, with just a little bit more effort?" -- A. P. J.
-- Sweet moderation Heart of this nation Desert us not We are between the wars - Billy Bragg
On Tue, 16 Dec 2003 15:32:10 EST, KPP52@aol.com wrote:
then I typed: a.out and it gives me the same error message.
what you REALLY mean to do: "./a.out" -- << http://michaeljtobler.homelinux.com/ >> Scientists are people who build the Brooklyn Bridge and then buy it. -- William Buckley
-----Original Message----- From: KPP52@aol.com To: suse-linux-e@suse.com Date: Tue, 16 Dec 2003 15:32:10 EST Subject: [SLE] C Programming in SuSE
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.
Check the permissions of the file and make suree that it is executable. Ken
-----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 Gary gave the correct answer:
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
participants (8)
-
Dylan
-
Gary Gapinski
-
Guillermo Ballester Valor
-
Jerry Feldman
-
Ken Schneider
-
KPP52@aol.com
-
Mads Martin Joergensen
-
mjt