# Using Gnu C compiler



## rikotech (Jul 5, 2014)

Can you please tell me how  to run Gnu C Compiler.
Thank you


----------



## jmccue (Jul 5, 2014)

gcc  :e 

I do not know what version of FreeBSD you are on nor what you mean by "run Gnu C Compiler".  I am on 9.x so gcc is the default.  If on 10 then I would have too say you would need to install one of the gcc ports.  

These http://www.freebsd.org/cgi/ports.cgi?query=gcc&stype=all&sektion=lang are the gcc ports

HTH
John


----------



## rikotech (Jul 5, 2014)

Hello.
Thank you for the prompt reply. I know my questions are kind of silly, but here isn't a person to introduce me to FreeBSD.

I am using GCC 8.0 The problem is that I have zero hours experience with FreeBSD, except the installation. Basically I do only Windows so far. Maybe the compiler is the default like you say, but I even don't know how to start it. It is completely different OS from the Windows ones.

May be I should type some command as: open GCC.exe or something like this. I just know nothing about FreeBSD. The C compilers are something I do pretty well, but only upon windows till now.
So any help would be much appreciated.


----------



## estrabd (Jul 5, 2014)

gcc is not part of base as of 9.x, clang is.; to use gcc on newer systems you must install it from Ports.

"open gcc.exe" is nonesense.  Do a "which gcc".


----------



## jmccue (Jul 6, 2014)

> Basically I do only Windows so far


Welcome to FreeBSD  :beergrin 

If you have only used gcc with windows and assuming you are new to a UN*X type environment, you will find the learning experience very rewarding and enjoyable but speckled with a bit of frustration.

Depending upon the version of FreeBSD, a c/c++ compiler is already installed, it will either be gcc or clang.  To execute the compiler just type:

```
cc program.c
```
and the executable will be named a.out.  To 'run' the program if it compiled successfully type

```
./a.out
```
.
For now, which c compiler you are using may not be too important.  If you really want gcc and you are on FreeBSD 10.*, it needs to be installed from ports.

FreeBSD one of the best, if not the best system to learn UN*X, I would spend time looking at the handbook http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/book.html, especially Chapter 4 http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/book.html#basics.  Over the years (and these days) I learned quite a bit by referring to the handbook, one of the best resources I have seen.

John

PS, I do not know if english is your main language, but the handbook has been translated into a few different languages http://www.freebsd.org/doc/


----------



## rikotech (Jul 6, 2014)

> `cc program.c`




```
cc: No such file or directory
cc: No input files specified
```


----------



## wblock@ (Jul 6, 2014)

Where is the source code you wish to compile?


----------



## rikotech (Jul 6, 2014)

I haven't made it yet.
But I think it doesn't mater.
If I succeed to compile "Hello world", I would develop much more comprehensive program.

So The next step after I run the GCC upon freeBSD is to intstall libpcap library.
And then the ultimate goal: THE CREATION OF THE PROGRAM - network sniffer.

Thats why I am doing it step by step:
1. install the freeBSD
2. create and account
3. run/install GCC
4. install libpcap
5. create code to make the net interface to act like a network sniffer.I am on step 3.
Then I get the money ole!


----------



## xibo (Jul 16, 2014)

See the handbook, chapter 5 on how to install additional packages, though if you're new to BSD/Unix you should start at chapter 4 instead.



			
				rikotech said:
			
		

> Hello.
> Thank you for the prompt reply. I know my questions are kind of silly, but here isn't a person to introduce me to FreeBSD.
> 
> I am using GCC 8.0 The problem is that I have zero hours experience with FreeBSD, except the installation. Basically I do only Windows so far. Maybe the compiler is the default like you say, but I even don't know how to start it. It is completely different OS from the Windows ones.
> ...



gcc 8.0 doesn't exist. The newest version officially released is 4.9.1 (released yesterday). You probably mean 4.8.0 ?

An ancient version of gcc is part of the legacy FreeBSD release, and more recent versions are available in the ports(7) collection as others said. The default version used by ports(7) is 4.7.3, the other gcc versions get suffices indicating their release to the binary names, e.g. g++ release 4.8.x installed by the lang/gcc48 package is called g++48.



			
				estrabd said:
			
		

> gcc is not part of base as of 9.x, clang is.; to use gcc on newer systems you must install it from Ports.
> 
> "open gcc.exe" is nonesense.  Do a "which gcc".


While it's been some time since I used FreeBSD-9 the last time, I'm pretty sure it's still around, while the remaining presence of WITH_CLANG_IS_CC in 9-STABLE's build options indicates gcc is not only installed but still the default compiler, too.


----------

