c compiling using clang

Polytropon freebsd at edvax.de
Tue Apr 26 22:19:53 UTC 2016


On Tue, 26 Apr 2016 22:19:40 +0530, Arnab Bhowmick wrote:
> I am new to Freebsd. I want to practice c programming for my college
> projects. I have wrote some program but when i am trying to compile the
> program by using
> % cc filename.c its showing % not found.

That's the correct and expected behaviour, as the "%" character
is not part of the command you should enter. It's the shell's prompt
character shown to illustrate that the command should be entered from
a user account (in opposite to the root account where "#" is used).
You will see this way of "implicit documentation" in many places.



> I went through the handbook but
> did not understand the process. Previously i have used clang compiler on
> Ununtu but i think that it is a little bit tricky to compile c under
> freebsd.

It's the same, except on Ubuntu you'll probably see a "$" infront of
command line examples.



> Can anyone say how to resolve this?

Do not enter the "%" character, just the command. To illustrate:

	% cc filename.c
	% ./a.out

or

	% cc -o myprog filename.c
	% ./myprog

Note that the "./" is needed infront of the program name you just compiled
because the current working directory usually is not in $PATH, so the shell
will not execute programs from that location unless explicitely specified.



-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...


More information about the freebsd-questions mailing list