4

I'm trying to run GCC on FreeBSD and I get this error:

% gcc
ar: unrecognized option `--plugin'
usage:  ar -d [-Tjsvz] archive file ...
        ar -m [-Tjsvz] archive file ...
        ar -m [-Tabijsvz] position archive file ...
        ar -p [-Tv] archive [file ...]
        ar -q [-TcDjsvz] archive file ...
        ar -r [-TcDjsuvz] archive file ...
        ar -r [-TabcDijsuvz] position archive file ...
        ar -s [-jz] archive
        ar -t [-Tv] archive [file ...]
        ar -x [-CTouv] archive [file ...]
        ar -V

I have installed the following version of GCC using the binary pkg:

% pkg info gcc
gcc-4.7.3_1
Name           : gcc
Version        : 4.7.3_1
Installed on   : Wed Jun 25 15:22:58 CEST 2014
Origin         : lang/gcc
Architecture   : freebsd:10:x86:64
Prefix         : /usr/local
Categories     : lang java
Licenses       : GPLv3RLE and GPLv3
Maintainer     : gerald@FreeBSD.org
WWW            : http://gcc.gnu.org/
Comment        : GNU Compiler Collection 4.7
Options        :
        BOOTSTRAP      : off
        JAVA           : on

I have installed the port version as well with the same results.

What can possibly be wrong?

Anthon
  • 79,293
ase
  • 203

1 Answers1

6

Since FreeBSD 10 Clang is the new default compiler.

You could try to compiler your code with Clang or you need to install a GCC version like you did.

But before the switch to Clang, FreeBSD used version 4.2 of GCC and the binary of this GCC was /usr/bin/gcc, so the newer ports of GCC needed to name there binary differently.

Because of that, all GCC ports have a binary called /usr/local/bin/gccXY, where XY is the version number.

When you install gcc4.7 on FreeBSD you don't get a /usr/local/bin/gcc thanks to the old behaviour, instead you get /usr/local/bin/gcc47`.

Long story short, when you want to compile your code with GCC 4.7 you need to use gcc47 and not gcc.

But maybe you should give Clang a try, since it is always a good idea to compile your code with different compilers to see if your code depends on a compiler. Because if it doesn't compile your code is probably broken or you found a compiler bug which is awesome.

Also take a look at Why is FreeBSD deprecating GCC in favor of Clang/LLVM?