Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 7 Jul 1999 12:30:14 +1000
From:      "Andrew Johns" <A_Johns@TurnAround.com.au>
To:        "Rezamys" <rezath@tm.net.my>, <freebsd-questions@FreeBSD.ORG>
Subject:   RE: newbie: how to compile & run C program in 3.2Release?
Message-ID:  <000501bec820$a4c0f3d0$4001a8c0@tasajohns.turnaround.com.au>
In-Reply-To: <3782BC71.C501C08A@tm.net.my>

next in thread | previous in thread | raw e-mail | index | archive | help
See comments below...

> -----Original Message-----
> From: owner-freebsd-questions@FreeBSD.ORG
> [mailto:owner-freebsd-questions@FreeBSD.ORG]On Behalf Of Rezamys
> Sent: Wednesday, 7 July 1999 12:33
> To: freebsd-questions@FreeBSD.ORG
> Subject: newbie: how to compile & run C program in 3.2Release?
>
>
> Hi all,
> This surely sound silly but at least i'm being honest to myself...
> Anyways, i created a simple program e.g "hello world" in the ee editor
> and did a complilation like this:
>
>      bash$  cc hello.c
>
> It gave no error. Fine. When i type:
>
>      bash$  hello.c
>
> The output tells me that "hello.c command not found"...
> I heard from a friend that we have to see the ouput (on the screen)
> "hello world" in your editor and not at your prompt.

hello.c is the c program text file and is not executable.

cc will create an executable by default with the name a.out (I don't
know if the new elf system names it something different - check by doing
an ls after the cc command).

To run the program, you need to add a ./ in front of the file name (ie:
./a.out) as the current directory is _not_ searched for executables (to
prevent accidental running of trojan programs).

To get cc to rename the file, use:
cc hello.c -o hello
and it will create an executable called 'hello' which you could then run
with ./hello

See the man page for cc for other compiler options, and check the -o to
make sure that I remembered it correctly.

Cheers

AJ



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?000501bec820$a4c0f3d0$4001a8c0>